[Ur] More questions
Marc Weber
marco-oweber at gmx.de
Sun Dec 12 18:46:39 EST 2010
Excerpts from Adam Chlipala's message of Mon Dec 13 00:16:13 +0100 2010:
> Marc Weber wrote:
> I don't see any obvious problem in the above that would lead to no rows
> being inserted, but I don't know which code for [Enum.to] you have in
> mind. I'd guess there's a bug where it's returning an empty list.
The code can be found in the library playground (-> wiki).
You can see that I added {[show numbers]} and the page showed
0 :: 1 :: 2 [...] :: 10 :: Nil
or such.
postgresql server says:
LOG: statement: BEGIN ISOLATION LEVEL SERIALIZABLE
LOG: execute uw2: DELETE FROM uw_Main_st AS T_T WHERE (1::int8 = 1::int8)
LOG: execute uw3: INSERT INTO uw_Main_st (uw_A, uw_B, uw_C, uw_Id) VALUES (E'TEXT A'::text, E'TEXT B'::text, $1::text, (- 20::int8))
DETAIL: parameters: $1 = '1 :: 2 :: 3 :: 4 :: 5 :: 6 :: 7 :: 8 :: 9 :: 10 :: []'
LOG: statement: COMMIT
for this code (pay attention to the last lonely INSERT which inserts the
list itself to proof that its not empty):
table st : {Id : int, A : string, B: string, C: string}
fun speed_test_insert () =
let
val numbers = Enum.to 1 10
in
dml (DELETE FROM st WHERE 1 = 1);
list <- (List.mapM (fn i => dml (INSERT INTO st (Id, A, B, C) VALUES ({[i]}, {["TEXT A"]}, {["TEXT B"]}, {["TEXT C"]}) ) ) numbers);
dml (INSERT INTO st (Id, A, B, C) VALUES (-20, {["TEXT A"]}, {["TEXT B"]}, {[show numbers]}) );
return (page "refreshed" <xml>{[show numbers]}</xml>)
end
So would you mind running the same test on your machine?
> BTW, you could write [TRUE] instead of [1 = 1]. IMO, it's slightly
> nicer looking.
I'd say ur could support DELETE without dummy where. That would be even
prettier :)
> > 2)
> > Tree demo:
> > A witness that key belongs to the type class sql_injectable_prim,
> > which indicates that both key and option key are fair game to use with SQL
> >
> > What does this exactly mean?
>
> [sql_injectable] is an abstract type family. This means that its
[...] I'll delay trying to understand all details. I tried asking: Why
is this line necessary. I would have no chance coming up with that line
myself. Shouldn't the information whether a key is nullable be encoded
in the type ?
The code looks like this:
functor Make(M : sig
type key
[...]
val key_inj : sql_injectable_prim key
Marc Weber
More information about the Ur
mailing list