Skip to content

Commit 9a540c1

Browse files
committed
Fix core dump in pg_dump --binary-upgrade on zero-column composite type.
This reverts nearly all of commit 28f6cab in favor of just using the typrelid we already have in pg_dump's TypeInfo struct for the composite type. As coded, it'd crash if the composite type had no attributes, since then the query would return no rows. Back-patch to all supported versions. It seems to not really be a problem in 9.0 because that version rejects the syntax "create type t as ()", but we might as well keep the logic similar in all affected branches. Report and fix by Rushabh Lathia.
1 parent 137e7c1 commit 9a540c1

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8853,7 +8853,6 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
88538853
int i_attalign;
88548854
int i_attisdropped;
88558855
int i_attcollation;
8856-
int i_typrelid;
88578856
int i;
88588857
int actual_atts;
88598858

@@ -8874,8 +8873,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
88748873
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
88758874
"a.attlen, a.attalign, a.attisdropped, "
88768875
"CASE WHEN a.attcollation <> at.typcollation "
8877-
"THEN a.attcollation ELSE 0 END AS attcollation, "
8878-
"ct.typrelid "
8876+
"THEN a.attcollation ELSE 0 END AS attcollation "
88798877
"FROM pg_catalog.pg_type ct "
88808878
"JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
88818879
"LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
@@ -8893,8 +8891,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
88938891
appendPQExpBuffer(query, "SELECT a.attname, "
88948892
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
88958893
"a.attlen, a.attalign, a.attisdropped, "
8896-
"0 AS attcollation, "
8897-
"ct.typrelid "
8894+
"0 AS attcollation "
88988895
"FROM pg_catalog.pg_type ct, pg_catalog.pg_attribute a "
88998896
"WHERE ct.oid = '%u'::pg_catalog.oid "
89008897
"AND a.attrelid = ct.typrelid "
@@ -8912,15 +8909,12 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
89128909
i_attalign = PQfnumber(res, "attalign");
89138910
i_attisdropped = PQfnumber(res, "attisdropped");
89148911
i_attcollation = PQfnumber(res, "attcollation");
8915-
i_typrelid = PQfnumber(res, "typrelid");
89168912

89178913
if (binary_upgrade)
89188914
{
8919-
Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid));
8920-
89218915
binary_upgrade_set_type_oids_by_type_oid(fout, q,
89228916
tyinfo->dobj.catId.oid);
8923-
binary_upgrade_set_pg_class_oids(fout, q, typrelid, false);
8917+
binary_upgrade_set_pg_class_oids(fout, q, tyinfo->typrelid, false);
89248918
}
89258919

89268920
qtypname = pg_strdup(fmtId(tyinfo->dobj.name));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy