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

Commit81166a2

Browse files
committed
Properly dump dropped foreign table cols in binary-upgrade mode.
In binary upgrade mode, we need to recreate and then drop droppedcolumns so that all the columns get the right attribute number. This istrue for foreign tables as well as for native tables. For foreigntables we have been getting the first part right but not the second,leading to bogus columns in the upgraded database. Fix this all the wayback to 9.1, where foreign tables were introduced.
1 parent985bd7d commit81166a2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13126,7 +13126,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1312613126
* attislocal correctly, plus fix up any inherited CHECK constraints.
1312713127
* Analogously, we set up typed tables using ALTER TABLE / OF here.
1312813128
*/
13129-
if (binary_upgrade&&tbinfo->relkind==RELKIND_RELATION)
13129+
if (binary_upgrade&& (tbinfo->relkind==RELKIND_RELATION||
13130+
tbinfo->relkind==RELKIND_FOREIGN_TABLE) )
1313013131
{
1313113132
for (j=0;j<tbinfo->numatts;j++)
1313213133
{
@@ -13144,13 +13145,19 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1314413145
appendStringLiteralAH(q,fmtId(tbinfo->dobj.name),fout);
1314513146
appendPQExpBuffer(q,"::pg_catalog.regclass;\n");
1314613147

13147-
appendPQExpBuffer(q,"ALTER TABLE ONLY %s ",
13148-
fmtId(tbinfo->dobj.name));
13148+
if (tbinfo->relkind==RELKIND_RELATION)
13149+
appendPQExpBuffer(q,"ALTER TABLE ONLY %s ",
13150+
fmtId(tbinfo->dobj.name));
13151+
else
13152+
appendPQExpBuffer(q,"ALTER FOREIGN TABLE %s ",
13153+
fmtId(tbinfo->dobj.name));
13154+
1314913155
appendPQExpBuffer(q,"DROP COLUMN %s;\n",
1315013156
fmtId(tbinfo->attnames[j]));
1315113157
}
1315213158
elseif (!tbinfo->attislocal[j])
1315313159
{
13160+
Assert(tbinfo->relkind!=RELKIND_FOREIGN_TABLE);
1315413161
appendPQExpBuffer(q,"\n-- For binary upgrade, recreate inherited column.\n");
1315513162
appendPQExpBuffer(q,"UPDATE pg_catalog.pg_attribute\n"
1315613163
"SET attislocal = false\n"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp