Skip to content

Commit 0c9391e

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 2784b68 commit 0c9391e

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
@@ -8085,7 +8085,6 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
80858085
int i_attalign;
80868086
int i_attisdropped;
80878087
int i_attcollation;
8088-
int i_typrelid;
80898088
int i;
80908089
int actual_atts;
80918090

@@ -8106,8 +8105,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
81068105
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
81078106
"a.attlen, a.attalign, a.attisdropped, "
81088107
"CASE WHEN a.attcollation <> at.typcollation "
8109-
"THEN a.attcollation ELSE 0 END AS attcollation, "
8110-
"ct.typrelid "
8108+
"THEN a.attcollation ELSE 0 END AS attcollation "
81118109
"FROM pg_catalog.pg_type ct "
81128110
"JOIN pg_catalog.pg_attribute a ON a.attrelid = ct.typrelid "
81138111
"LEFT JOIN pg_catalog.pg_type at ON at.oid = a.atttypid "
@@ -8125,8 +8123,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
81258123
appendPQExpBuffer(query, "SELECT a.attname, "
81268124
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
81278125
"a.attlen, a.attalign, a.attisdropped, "
8128-
"0 AS attcollation, "
8129-
"ct.typrelid "
8126+
"0 AS attcollation "
81308127
"FROM pg_catalog.pg_type ct, pg_catalog.pg_attribute a "
81318128
"WHERE ct.oid = '%u'::pg_catalog.oid "
81328129
"AND a.attrelid = ct.typrelid "
@@ -8145,14 +8142,11 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
81458142
i_attalign = PQfnumber(res, "attalign");
81468143
i_attisdropped = PQfnumber(res, "attisdropped");
81478144
i_attcollation = PQfnumber(res, "attcollation");
8148-
i_typrelid = PQfnumber(res, "typrelid");
81498145

81508146
if (binary_upgrade)
81518147
{
8152-
Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid));
8153-
81548148
binary_upgrade_set_type_oids_by_type_oid(q, tyinfo->dobj.catId.oid);
8155-
binary_upgrade_set_pg_class_oids(q, typrelid, false);
8149+
binary_upgrade_set_pg_class_oids(q, tyinfo->typrelid, false);
81568150
}
81578151

81588152
appendPQExpBuffer(q, "CREATE TYPE %s AS (",

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