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

Commit 3205b30

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 4b3b44b commit 3205b30

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/bin/pg_dump/pg_dump.c

+3-9
Original file line numberDiff line numberDiff line change
@@ -8978,7 +8978,6 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
89788978
int i_attalign;
89798979
int i_attisdropped;
89808980
int i_attcollation;
8981-
int i_typrelid;
89828981
int i;
89838982
int actual_atts;
89848983

@@ -8999,8 +8998,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
89998998
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
90008999
"a.attlen, a.attalign, a.attisdropped, "
90019000
"CASE WHEN a.attcollation <> at.typcollation "
9002-
"THEN a.attcollation ELSE 0 END AS attcollation, "
9003-
"ct.typrelid "
9001+
"THEN a.attcollation ELSE 0 END AS attcollation "
90049002
"FROM pg_catalog.pg_type ct "
90059003
"JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
90069004
"LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
@@ -9018,8 +9016,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
90189016
appendPQExpBuffer(query, "SELECT a.attname, "
90199017
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
90209018
"a.attlen, a.attalign, a.attisdropped, "
9021-
"0 AS attcollation, "
9022-
"ct.typrelid "
9019+
"0 AS attcollation "
90239020
"FROM pg_catalog.pg_type ct, pg_catalog.pg_attribute a "
90249021
"WHERE ct.oid = '%u'::pg_catalog.oid "
90259022
"AND a.attrelid = ct.typrelid "
@@ -9037,15 +9034,12 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
90379034
i_attalign = PQfnumber(res, "attalign");
90389035
i_attisdropped = PQfnumber(res, "attisdropped");
90399036
i_attcollation = PQfnumber(res, "attcollation");
9040-
i_typrelid = PQfnumber(res, "typrelid");
90419037

90429038
if (binary_upgrade)
90439039
{
9044-
Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid));
9045-
90469040
binary_upgrade_set_type_oids_by_type_oid(fout, q,
90479041
tyinfo->dobj.catId.oid);
9048-
binary_upgrade_set_pg_class_oids(fout, q, typrelid, false);
9042+
binary_upgrade_set_pg_class_oids(fout, q, tyinfo->typrelid, false);
90499043
}
90509044

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

0 commit comments

Comments
 (0)