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

Commit05aeeb5

Browse files
committed
Ensure schema qualification in pg_restore DISABLE/ENABLE TRIGGER commands.
Previously, this code blindly followed the common coding pattern ofpassing PQserverVersion(AH->connection) as the server-version parameterof fmtQualifiedId. That works as long as we have a connection; but inpg_restore with text output, we don't. Instead we got a zero fromPQserverVersion, which fmtQualifiedId interpreted as "server is too old tohave schemas", and so the name went unqualified. That still accidentallymanaged to work in many cases, which is probably why this ancient bug wentundetected for so long. It only became obvious in the wake of the changesto force dump/restore to execute with restricted search_path.In HEAD/v11, let's deal with this by ripping out fmtQualifiedId's server-version behavioral dependency, and just making it schema-qualify all thetime. We no longer support pg_dump from servers old enough to need theability to omit schema name, let alone restoring to them. (Also, the fewcallers outside pg_dump already didn't work with pre-schema servers.)In older branches, that's not an acceptable solution, so instead justtweak the DISABLE/ENABLE TRIGGER logic to ensure it will schema-qualifyits output regardless of server version.Per bug #15338 from Oleg somebody. Back-patch to all supported branches.Discussion:https://postgr.es/m/153452458706.1316.5328079417086507743@wrigleys.postgresql.org
1 parentd31ebbf commit05aeeb5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -992,10 +992,12 @@ _disableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te)
992992
_becomeUser(AH,ropt->superuser);
993993

994994
/*
995-
* Disable them.
995+
* Disable them. Assume that the table name should be schema-qualified
996+
* (we can't look at PQserverVersion, since we might not have any
997+
* connection; and anyway we don't promise our output will load pre-7.3).
996998
*/
997999
ahprintf(AH,"ALTER TABLE %s DISABLE TRIGGER ALL;\n\n",
998-
fmtQualifiedId(PQserverVersion(AH->connection),
1000+
fmtQualifiedId(70300,
9991001
te->namespace,
10001002
te->tag));
10011003
}
@@ -1020,10 +1022,10 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te)
10201022
_becomeUser(AH,ropt->superuser);
10211023

10221024
/*
1023-
* Enable them.
1025+
* Enable them. As above, force schema qualification.
10241026
*/
10251027
ahprintf(AH,"ALTER TABLE %s ENABLE TRIGGER ALL;\n\n",
1026-
fmtQualifiedId(PQserverVersion(AH->connection),
1028+
fmtQualifiedId(70300,
10271029
te->namespace,
10281030
te->tag));
10291031
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp