Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb2ef892

Browse files
committed
Fix binary upgrade of altered typed tables
Instead of dumping them as CREATE TABLE ... OF, dump them as normaltables with the usual special processing for dropped columns, and thenattach them to the type afterward, using ALTER TABLE ... OF. This isanalogous to the existing handling of inherited tables.
1 parent6693fec commitb2ef892

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12004,7 +12004,11 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1200412004
"UNLOGGED " :"",
1200512005
reltypename,
1200612006
fmtId(tbinfo->dobj.name));
12007-
if (tbinfo->reloftype)
12007+
/*
12008+
* In case of a binary upgrade, we dump the table normally and attach
12009+
* it to the type afterward.
12010+
*/
12011+
if (tbinfo->reloftype&& !binary_upgrade)
1200812012
appendPQExpBuffer(q," OF %s",tbinfo->reloftype);
1200912013
actual_atts=0;
1201012014
for (j=0;j<tbinfo->numatts;j++)
@@ -12032,7 +12036,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1203212036
boolhas_notnull= (tbinfo->notnull[j]
1203312037
&& (!tbinfo->inhNotNull[j]||binary_upgrade));
1203412038

12035-
if (tbinfo->reloftype&& !has_default&& !has_notnull)
12039+
if (tbinfo->reloftype&& !has_default&& !has_notnull&& !binary_upgrade)
1203612040
continue;
1203712041

1203812042
/* Format properly if not first attr */
@@ -12060,7 +12064,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1206012064
}
1206112065

1206212066
/* Attribute type */
12063-
if (tbinfo->reloftype)
12067+
if (tbinfo->reloftype&& !binary_upgrade)
1206412068
{
1206512069
appendPQExpBuffer(q,"WITH OPTIONS");
1206612070
}
@@ -12126,7 +12130,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1212612130

1212712131
if (actual_atts)
1212812132
appendPQExpBuffer(q,"\n)");
12129-
elseif (!tbinfo->reloftype)
12133+
elseif (!(tbinfo->reloftype&& !binary_upgrade))
1213012134
{
1213112135
/*
1213212136
* We must have a parenthesized attribute list, even though empty,
@@ -12192,6 +12196,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1219212196
* an INHERITS clause --- the latter would possibly mess up the column
1219312197
* order. That also means we have to take care about setting
1219412198
* attislocal correctly, plus fix up any inherited CHECK constraints.
12199+
* Analogously, we set up typed tables using ALTER TABLE / OF here.
1219512200
*/
1219612201
if (binary_upgrade&&tbinfo->relkind==RELKIND_RELATION)
1219712202
{
@@ -12268,6 +12273,14 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1226812273
}
1226912274
}
1227012275

12276+
if (tbinfo->reloftype)
12277+
{
12278+
appendPQExpBuffer(q,"\n-- For binary upgrade, set up typed tables this way.\n");
12279+
appendPQExpBuffer(q,"ALTER TABLE ONLY %s OF %s;\n",
12280+
fmtId(tbinfo->dobj.name),
12281+
tbinfo->reloftype);
12282+
}
12283+
1227112284
appendPQExpBuffer(q,"\n-- For binary upgrade, set heap's relfrozenxid\n");
1227212285
appendPQExpBuffer(q,"UPDATE pg_catalog.pg_class\n"
1227312286
"SET relfrozenxid = '%u'\n"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp