Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4806f26

Browse files
committed
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 23f34fa). Amit Langote and Tom Lane Discussion: <0a3e7a0e-37bd-8427-29bd-958135862f0a@lab.ntt.co.jp>
1 parent 0d4d7d6 commit 4806f26

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/bin/pg_dump/pg_dump.c

+9-8
Original file line numberDiff line numberDiff line change
@@ -2875,19 +2875,20 @@ getBlobs(Archive *fout)
28752875
else if (fout->remoteVersion >= 90000)
28762876
appendPQExpBuffer(blobQry,
28772877
"SELECT oid, (%s lomowner) AS rolname, lomacl, "
2878-
"NULL AS rlomacl, NULL as initlomacl, "
2879-
"NULL as initrlomacl "
2878+
"NULL AS rlomacl, NULL AS initlomacl, "
2879+
"NULL AS initrlomacl "
28802880
" FROM pg_largeobject_metadata",
28812881
username_subquery);
28822882
else if (fout->remoteVersion >= 70100)
28832883
appendPQExpBufferStr(blobQry,
2884-
"SELECT DISTINCT loid, NULL::oid, NULL, "
2885-
"NULL AS rlomacl, NULL AS initlomacl, "
2886-
"NULL AS initrlomacl "
2884+
"SELECT DISTINCT loid AS oid, "
2885+
"NULL::name AS rolname, NULL::oid AS lomacl, "
2886+
"NULL::oid AS rlomacl, NULL::oid AS initlomacl, "
2887+
"NULL::oid AS initrlomacl "
28872888
" FROM pg_largeobject");
28882889
else
28892890
appendPQExpBufferStr(blobQry,
2890-
"SELECT oid, NULL::oid, NULL, "
2891+
"SELECT oid, NULL AS rolname, NULL AS lomacl, "
28912892
"NULL AS rlomacl, NULL AS initlomacl, "
28922893
"NULL AS initrlomacl "
28932894
" FROM pg_class WHERE relkind = 'l'");
@@ -2922,11 +2923,11 @@ getBlobs(Archive *fout)
29222923
binfo[i].initblobacl = pg_strdup(PQgetvalue(res, i, i_initlomacl));
29232924
binfo[i].initrblobacl = pg_strdup(PQgetvalue(res, i, i_initrlomacl));
29242925

2925-
if (PQgetisnull(res, i, i_lomacl) && PQgetisnull(res, i, i_rlomacl) &&
2926+
if (PQgetisnull(res, i, i_lomacl) &&
2927+
PQgetisnull(res, i, i_rlomacl) &&
29262928
PQgetisnull(res, i, i_initlomacl) &&
29272929
PQgetisnull(res, i, i_initrlomacl))
29282930
binfo[i].dobj.dump &= ~DUMP_COMPONENT_ACL;
2929-
29302931
}
29312932

29322933
/*

0 commit comments

Comments
 (0)