summaryrefslogtreecommitdiff
path: root/src/postgres.sml
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@mit.edu>2018-06-17 09:12:52 -0400
committerGravatar Benjamin Barenblat <bbaren@mit.edu>2018-06-17 09:12:52 -0400
commit095c2640aa2070ed4e2765875238d5e6e6673856 (patch)
tree9306beb3fef29a99d9436dc00e2d8c57fb3e0c7b /src/postgres.sml
parent8c58ba2e1db6e97ca1f18fd9ca52ffead53e4a4f (diff)
parent34eb9eba9a724433f9c37c39cf43e9e10cf55220 (diff)
Merge branch 'upstream' into dfsg_clean20180616+dfsg
Diffstat (limited to 'src/postgres.sml')
-rw-r--r--src/postgres.sml14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/postgres.sml b/src/postgres.sml
index 404384d2..2b6bee8c 100644
--- a/src/postgres.sml
+++ b/src/postgres.sml
@@ -612,6 +612,13 @@ fun p_getcol {loc, wontLeakStrings, col = i, typ = t} =
getter t
end
+(* We turn 0-output queries into 1-output queries to satisfy SQL.
+ * This function adjusts our length expectations. *)
+fun bumpedLength ls =
+ case ls of
+ [] => 1
+ | _ => length ls
+
fun queryCommon {loc, query, cols, doCols} =
box [string "int n, i;",
newline,
@@ -658,7 +665,7 @@ fun queryCommon {loc, query, cols, doCols} =
newline,
string "if (PQnfields(res) != ",
- string (Int.toString (length cols)),
+ string (Int.toString (bumpedLength cols)),
string ") {",
newline,
box [string "int nf = PQnfields(res);",
@@ -668,7 +675,7 @@ fun queryCommon {loc, query, cols, doCols} =
string "uw_error(ctx, FATAL, \"",
string (ErrorMsg.spanToString loc),
string ": Query returned %d columns instead of ",
- string (Int.toString (length cols)),
+ string (Int.toString (bumpedLength cols)),
string ":\\n%s\\n%s\", nf, ",
query,
string ", PQerrorMessage(conn));",
@@ -1146,7 +1153,8 @@ val () = addDbms {name = "postgres",
onlyUnion = false,
nestedRelops = true,
windowFunctions = true,
- supportsIsDistinctFrom = true}
+ supportsIsDistinctFrom = true,
+ supportsSHA512 = true}
val () = setDbms "postgres"