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

Commit96e16d7

Browse files
committed
Fix incorrect logic for excluding range constructor functions in pg_dump.
Faulty AND/OR nesting in the WHERE clause of getFuncs' SQL query led todumping range constructor functions if they are part of an extensionand we're in binary-upgrade mode. Actually, we don't want to dump themseparately even then, since CREATE TYPE AS RANGE will create the range'sconstructor functions regardless. Per report from Andrew Dunstan.It looks like this mistake was introduced by me, in commitb985d48, inperhaps-overzealous refactoring to reduce code duplication. I'm suitablyembarrassed.Report: <34854939-02d7-f591-5677-ce2994104599@dunslane.net>
1 parenteda5e90 commit96e16d7

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4481,19 +4481,22 @@ getFuncs(Archive *fout, int *numFuncs)
44814481
selectSourceSchema(fout,"pg_catalog");
44824482

44834483
/*
4484-
* Find all user-defined functions. Normally we can exclude functions in
4485-
* pg_catalog, which is worth doing since there are several thousand of
4486-
* 'em. However, there are some extensions that create functions in
4487-
* pg_catalog. In normal dumps we can still ignore those --- but in
4488-
* binary-upgrade mode, we must dump the member objects of the extension,
4489-
* so be sure to fetch any such functions.
4484+
* Find all interesting functions. This is a bit complicated:
44904485
*
4491-
* Also, in 9.2 and up, exclude functions that are internally dependent on
4492-
* something else, since presumably those will be created as a result of
4493-
* creating the something else. This currently only acts to suppress
4494-
* constructor functions for range types. Note that this is OK only
4495-
* because the constructors don't have any dependencies the range type
4496-
* doesn't have; otherwise we might not get creation ordering correct.
4486+
* 1. Always exclude aggregates; those are handled elsewhere.
4487+
*
4488+
* 2. Always exclude functions that are internally dependent on something
4489+
* else, since presumably those will be created as a result of creating
4490+
* the something else. This currently acts only to suppress constructor
4491+
* functions for range types (so we only need it in 9.2 and up). Note
4492+
* this is OK only because the constructors don't have any dependencies
4493+
* the range type doesn't have; otherwise we might not get creation
4494+
* ordering correct.
4495+
*
4496+
* 3. Otherwise, we normally exclude functions in pg_catalog. However, if
4497+
* they're members of extensions and we are in binary-upgrade mode then
4498+
* include them, since we want to dump extension members individually in
4499+
* that mode.
44974500
*/
44984501

44994502
if (fout->remoteVersion >=70300)
@@ -4504,16 +4507,18 @@ getFuncs(Archive *fout, int *numFuncs)
45044507
"pronamespace, "
45054508
"(%s proowner) AS rolname "
45064509
"FROM pg_proc p "
4507-
"WHERE NOT proisagg AND ("
4508-
"pronamespace != "
4509-
"(SELECT oid FROM pg_namespace "
4510-
"WHERE nspname = 'pg_catalog')",
4510+
"WHERE NOT proisagg",
45114511
username_subquery);
45124512
if (fout->remoteVersion >=90200)
45134513
appendPQExpBufferStr(query,
45144514
"\n AND NOT EXISTS (SELECT 1 FROM pg_depend "
45154515
"WHERE classid = 'pg_proc'::regclass AND "
45164516
"objid = p.oid AND deptype = 'i')");
4517+
appendPQExpBufferStr(query,
4518+
"\n AND ("
4519+
"\n pronamespace != "
4520+
"(SELECT oid FROM pg_namespace "
4521+
"WHERE nspname = 'pg_catalog')");
45174522
if (dopt->binary_upgrade&&fout->remoteVersion >=90100)
45184523
appendPQExpBufferStr(query,
45194524
"\n OR EXISTS(SELECT 1 FROM pg_depend WHERE "

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp