diff options
author | Adam Chlipala <adam@chlipala.net> | 2012-01-02 17:08:39 -0500 |
---|---|---|
committer | Adam Chlipala <adam@chlipala.net> | 2012-01-02 17:08:39 -0500 |
commit | 415f477a62e6bf0776eec2ba13fc2ae05cf77735 (patch) | |
tree | fd1b94c909fc8c4b2c176406f157cbe8812f5984 /src/postgres.sml | |
parent | 7599d4cacde93b7dac3d1dea2b147f6e49425072 (diff) |
Fix handling of quotes in generating C literals
Diffstat (limited to 'src/postgres.sml')
-rw-r--r-- | src/postgres.sml | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/postgres.sml b/src/postgres.sml index c180e38f..3a2fd40d 100644 --- a/src/postgres.sml +++ b/src/postgres.sml @@ -337,7 +337,7 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = box [string "res = PQprepare(conn, \"uw", string (Int.toString i), string "\", \"", - string (String.toCString s), + string (Prim.toCString s), string "\", ", string (Int.toString n), string ", NULL);", @@ -355,7 +355,7 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = string "PQfinish(conn);", newline, string "uw_error(ctx, FATAL, \"Unable to create prepared statement:\\n", - string (String.toCString s), + string (Prim.toCString s), string "\\n%s\", msg);", newline], string "}", @@ -481,7 +481,7 @@ fun init {dbstring, prepared = ss, tables, views, sequences} = string "char *env_db_str = getenv(\"URWEB_PQ_CON\");", newline, string "PGconn *conn = PQconnectdb(env_db_str == NULL ? \"", - string (String.toCString dbstring), + string (Prim.toCString dbstring), string "\" : env_db_str);", newline, string "if (conn == NULL) uw_error(ctx, FATAL, ", @@ -732,14 +732,14 @@ fun queryPrepared {loc, id, query, inputs, cols, doCols, nested = _} = string ", paramValues, paramLengths, paramFormats, 0);"] else box [string "PQexecParams(conn, \"", - string (String.toCString query), + string (Prim.toCString query), string "\", ", string (Int.toString (length inputs)), string ", NULL, paramValues, paramLengths, paramFormats, 0);"], newline, newline, queryCommon {loc = loc, cols = cols, doCols = doCols, query = box [string "\"", - string (String.toCString query), + string (Prim.toCString query), string "\""]}] fun dmlCommon {loc, dml, mode} = @@ -888,14 +888,14 @@ fun dmlPrepared {loc, id, dml, inputs, mode} = string ", paramValues, paramLengths, paramFormats, 0);"] else box [string "PQexecParams(conn, \"", - string (String.toCString dml), + string (Prim.toCString dml), string "\", ", string (Int.toString (length inputs)), string ", NULL, paramValues, paramLengths, paramFormats, 0);"], newline, newline, dmlCommon {loc = loc, dml = box [string "\"", - string (String.toCString dml), + string (Prim.toCString dml), string "\""], mode = mode}] fun nextvalCommon {loc, query} = @@ -972,12 +972,12 @@ fun nextvalPrepared {loc, id, query} = string "\", 0, NULL, NULL, NULL, 0);"] else box [string "PQexecParams(conn, \"", - string (String.toCString query), + string (Prim.toCString query), string "\", 0, NULL, NULL, NULL, NULL, 0);"], newline, newline, nextvalCommon {loc = loc, query = box [string "\"", - string (String.toCString query), + string (Prim.toCString query), string "\""]}] fun setvalCommon {loc, query} = @@ -1030,7 +1030,7 @@ fun sqlifyString s = "E'" ^ String.translate (fn #"'" => "\\'" else "\\" ^ StringCvt.padLeft #"0" 3 (Int.fmt StringCvt.OCT (ord ch))) - (String.toCString s) ^ "'::text" + (Prim.toCString s) ^ "'::text" fun p_cast (s, t) = s ^ "::" ^ p_sql_type t |