diff options
author | Adam Chlipala <adamc@hcoop.net> | 2009-07-16 18:10:29 -0400 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2009-07-16 18:10:29 -0400 |
commit | c01c7e97334a180b55b11a1bba93cf046628948d (patch) | |
tree | e68fb2c7ffcd8dd34ff69f24a48de2ada1c06684 /src/postgres.sml | |
parent | 4289cd07dd2467dfbad297cf21ad7cfaedc08f2b (diff) |
Demo working with MySQL
Diffstat (limited to 'src/postgres.sml')
-rw-r--r-- | src/postgres.sml | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/postgres.sml b/src/postgres.sml index 24166258..e1ef0514 100644 --- a/src/postgres.sml +++ b/src/postgres.sml @@ -247,7 +247,21 @@ fun checkRel (table, checkNullable) (s, xts) = fun init {dbstring, prepared = ss, tables, views, sequences} = box [if #persistent (currentProtocol ()) then - box [string "void uw_client_init(void) { }", + box [string "void uw_client_init(void) {", + newline, + box [string "uw_sqlfmtInt = \"%lld::int8%n\";", + newline, + string "uw_sqlfmtFloat = \"%g::float8%n\";", + newline, + string "uw_Estrings = 1;", + newline, + string "uw_sqlsuffixString = \"::text\";", + newline, + string "uw_sqlsuffixBlob = \"::bytea\";", + newline, + string "uw_sqlfmtUint4 = \"%u::int4%n\";", + newline], + string "}", newline, newline, @@ -639,7 +653,7 @@ fun p_ensql t e = p_ensql t (box [string "(*", e, string ")"]), string ")"] -fun queryPrepared {loc, id, query, inputs, cols, doCols} = +fun queryPrepared {loc, id, query, inputs, cols, doCols, nested = _} = box [string "PGconn *conn = uw_get_db(ctx);", newline, string "const int paramFormats[] = { ", @@ -782,8 +796,6 @@ fun nextvalCommon {loc, query} = newline, newline, - string "uw_end_region(ctx);", - newline, string "n = PQntuples(res);", newline, string "if (n != 1) {", @@ -811,7 +823,7 @@ fun nextval {loc, seqE, seqName} = let val query = case seqName of SOME s => - string ("SELECT NEXTVAL('" ^ s ^ "')") + string ("\"SELECT NEXTVAL('" ^ s ^ "')\"") | _ => box [string "uw_Basis_strcat(ctx, \"SELECT NEXTVAL('\", uw_Basis_strcat(ctx, ", seqE, string ", \"')\"))"] @@ -878,7 +890,8 @@ val () = addDbms {name = "postgres", supportsDeleteAs = true, createSequence = fn s => "CREATE SEQUENCE " ^ s, textKeysNeedLengths = false, - supportsNextval = true} + supportsNextval = true, + supportsNestedPrepared = true} val () = setDbms "postgres" |