aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-10-07 09:51:18 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-10-07 09:51:28 -0400
commit1749332ec9e5017ca7ebfa245597cc765b4553fd (patch)
treec71d9d3ad6e214c7c4819ff26fa1e0a27ca806fb
parent2933ed0362ae5fbc9e0c28035286318b4d299492 (diff)
downloadpostgresql-1749332ec9e5017ca7ebfa245597cc765b4553fd.tar.gz
postgresql-1749332ec9e5017ca7ebfa245597cc765b4553fd.zip
Fix pg_dump to work against pre-9.0 servers again.
getBlobs' queries for pre-9.0 servers were broken in two ways: the 7.x/8.x query uses DISTINCT so it can't have unspecified-type NULLs in the target list, and both that query and the 7.0 one failed to provide the correct output column labels, so that the subsequent code to extract data from the PGresult would fail. Back-patch to 9.6 where the breakage was introduced (by commit 23f34fa4b). Amit Langote and Tom Lane Discussion: <0a3e7a0e-37bd-8427-29bd-958135862f0a@lab.ntt.co.jp>
-rw-r--r--src/bin/pg_dump/pg_dump.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 299e88788e1..fde7f59c3d0 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -2875,19 +2875,20 @@ getBlobs(Archive *fout)
else if (fout->remoteVersion >= 90000)
appendPQExpBuffer(blobQry,
"SELECT oid, (%s lomowner) AS rolname, lomacl, "
- "NULL AS rlomacl, NULL as initlomacl, "
- "NULL as initrlomacl "
+ "NULL AS rlomacl, NULL AS initlomacl, "
+ "NULL AS initrlomacl "
" FROM pg_largeobject_metadata",
username_subquery);
else if (fout->remoteVersion >= 70100)
appendPQExpBufferStr(blobQry,
- "SELECT DISTINCT loid, NULL::oid, NULL, "
- "NULL AS rlomacl, NULL AS initlomacl, "
- "NULL AS initrlomacl "
+ "SELECT DISTINCT loid AS oid, "
+ "NULL::name AS rolname, NULL::oid AS lomacl, "
+ "NULL::oid AS rlomacl, NULL::oid AS initlomacl, "
+ "NULL::oid AS initrlomacl "
" FROM pg_largeobject");
else
appendPQExpBufferStr(blobQry,
- "SELECT oid, NULL::oid, NULL, "
+ "SELECT oid, NULL AS rolname, NULL AS lomacl, "
"NULL AS rlomacl, NULL AS initlomacl, "
"NULL AS initrlomacl "
" FROM pg_class WHERE relkind = 'l'");
@@ -2922,11 +2923,11 @@ getBlobs(Archive *fout)
binfo[i].initblobacl = pg_strdup(PQgetvalue(res, i, i_initlomacl));
binfo[i].initrblobacl = pg_strdup(PQgetvalue(res, i, i_initrlomacl));
- if (PQgetisnull(res, i, i_lomacl) && PQgetisnull(res, i, i_rlomacl) &&
+ if (PQgetisnull(res, i, i_lomacl) &&
+ PQgetisnull(res, i, i_rlomacl) &&
PQgetisnull(res, i, i_initlomacl) &&
PQgetisnull(res, i, i_initrlomacl))
binfo[i].dobj.dump &= ~DUMP_COMPONENT_ACL;
-
}
/*