Mercurial > urweb
comparison 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 |
comparison
equal
deleted
inserted
replaced
877:dae141d911d9 | 878:a8952047e1d3 |
---|---|
803 string "n = uw_Basis_stringToInt_error(ctx, PQgetvalue(res, 0, 0));", | 803 string "n = uw_Basis_stringToInt_error(ctx, PQgetvalue(res, 0, 0));", |
804 newline, | 804 newline, |
805 string "PQclear(res);", | 805 string "PQclear(res);", |
806 newline] | 806 newline] |
807 | 807 |
808 fun nextval loc = | 808 open Cjr |
809 box [string "PGconn *conn = uw_get_db(ctx);", | 809 |
810 newline, | 810 fun nextval {loc, seqE, seqName} = |
811 string "PGresult *res = PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);", | 811 let |
812 newline, | 812 val query = case seqName of |
813 newline, | 813 SOME s => |
814 nextvalCommon {loc = loc, query = string "query"}] | 814 string ("SELECT NEXTVAL('" ^ s ^ "')") |
815 | _ => box [string "uw_Basis_strcat(ctx, \"SELECT NEXTVAL('\", uw_Basis_strcat(ctx, ", | |
816 seqE, | |
817 string ", \"')\"))"] | |
818 in | |
819 box [string "char *query = ", | |
820 query, | |
821 string ";", | |
822 newline, | |
823 string "PGconn *conn = uw_get_db(ctx);", | |
824 newline, | |
825 string "PGresult *res = PQexecParams(conn, query, 0, NULL, NULL, NULL, NULL, 0);", | |
826 newline, | |
827 newline, | |
828 nextvalCommon {loc = loc, query = string "query"}] | |
829 end | |
815 | 830 |
816 fun nextvalPrepared {loc, id, query} = | 831 fun nextvalPrepared {loc, id, query} = |
817 box [string "PGconn *conn = uw_get_db(ctx);", | 832 box [string "PGconn *conn = uw_get_db(ctx);", |
818 newline, | 833 newline, |
819 newline, | 834 newline, |
860 sqlifyString = sqlifyString, | 875 sqlifyString = sqlifyString, |
861 p_cast = p_cast, | 876 p_cast = p_cast, |
862 p_blank = p_blank, | 877 p_blank = p_blank, |
863 supportsDeleteAs = true, | 878 supportsDeleteAs = true, |
864 createSequence = fn s => "CREATE SEQUENCE " ^ s, | 879 createSequence = fn s => "CREATE SEQUENCE " ^ s, |
865 textKeysNeedLengths = false} | 880 textKeysNeedLengths = false, |
881 supportsNextval = true} | |
866 | 882 |
867 val () = setDbms "postgres" | 883 val () = setDbms "postgres" |
868 | 884 |
869 end | 885 end |