Mercurial > urweb
diff src/postgres.sml @ 878:a8952047e1d3
Sequence code compiles in MySQL
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 16 Jul 2009 16:29:13 -0400 |
parents | dae141d911d9 |
children | b2a175a0f2ef |
line wrap: on
line diff
--- a/src/postgres.sml Thu Jul 16 13:59:30 2009 -0400 +++ b/src/postgres.sml Thu Jul 16 16:29:13 2009 -0400 @@ -805,13 +805,28 @@ string "PQclear(res);", newline] -fun nextval loc = - box [string "PGconn *conn = uw_get_db(ctx);", - newline, - string "PGresult *res = PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);", - newline, - newline, - nextvalCommon {loc = loc, query = string "query"}] +open Cjr + +fun nextval {loc, seqE, seqName} = + let + val query = case seqName of + SOME s => + string ("SELECT NEXTVAL('" ^ s ^ "')") + | _ => box [string "uw_Basis_strcat(ctx, \"SELECT NEXTVAL('\", uw_Basis_strcat(ctx, ", + seqE, + string ", \"')\"))"] + in + box [string "char *query = ", + query, + string ";", + newline, + string "PGconn *conn = uw_get_db(ctx);", + newline, + string "PGresult *res = PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);", + newline, + newline, + nextvalCommon {loc = loc, query = string "query"}] + end fun nextvalPrepared {loc, id, query} = box [string "PGconn *conn = uw_get_db(ctx);", @@ -862,7 +877,8 @@ p_blank = p_blank, supportsDeleteAs = true, createSequence = fn s => "CREATE SEQUENCE " ^ s, - textKeysNeedLengths = false} + textKeysNeedLengths = false, + supportsNextval = true} val () = setDbms "postgres"