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

Commit89c29c0

Browse files
committed
Fix corner case for binary upgrade: extension functions in pg_catalog.
Normally, pg_dump summarily excludes functions in pg_catalog fromconsideration. However, some extensions may create functions in pg_catalog(adminpack already does that, and extensions for procedural languages willlikely do it too). In binary-upgrade mode, we have to dump such functions,or the extension will be incomplete after upgrading. Per experimentationwith adminpack.
1 parent8b25575 commit89c29c0

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

‎src/bin/pg_dump/pg_dump.c

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,7 +3462,10 @@ getAggregates(int *numAggs)
34623462
/* Make sure we are in proper schema */
34633463
selectSourceSchema("pg_catalog");
34643464

3465-
/* find all user-defined aggregates */
3465+
/*
3466+
* Find all user-defined aggregates. See comment in getFuncs() for the
3467+
* rationale behind the filtering logic.
3468+
*/
34663469

34673470
if (g_fout->remoteVersion >=80200)
34683471
{
@@ -3471,11 +3474,20 @@ getAggregates(int *numAggs)
34713474
"pronargs, proargtypes, "
34723475
"(%s proowner) AS rolname, "
34733476
"proacl AS aggacl "
3474-
"FROM pg_proc "
3475-
"WHERE proisagg "
3476-
"AND pronamespace != "
3477-
"(SELECT oid FROM pg_namespace WHERE nspname = 'pg_catalog')",
3477+
"FROM pg_proc p "
3478+
"WHERE proisagg AND ("
3479+
"pronamespace != "
3480+
"(SELECT oid FROM pg_namespace "
3481+
"WHERE nspname = 'pg_catalog')",
34783482
username_subquery);
3483+
if (binary_upgrade&&g_fout->remoteVersion >=90100)
3484+
appendPQExpBuffer(query,
3485+
" OR EXISTS(SELECT 1 FROM pg_depend WHERE "
3486+
"classid = 'pg_proc'::regclass AND "
3487+
"objid = p.oid AND "
3488+
"refclassid = 'pg_extension'::regclass AND "
3489+
"deptype = 'e')");
3490+
appendPQExpBuffer(query,")");
34793491
}
34803492
elseif (g_fout->remoteVersion >=70300)
34813493
{
@@ -3608,7 +3620,14 @@ getFuncs(int *numFuncs)
36083620
/* Make sure we are in proper schema */
36093621
selectSourceSchema("pg_catalog");
36103622

3611-
/* find all user-defined funcs */
3623+
/*
3624+
* Find all user-defined functions. Normally we can exclude functions
3625+
* in pg_catalog, which is worth doing since there are several thousand
3626+
* of 'em. However, there are some extensions that create functions in
3627+
* pg_catalog. In normal dumps we can still ignore those --- but in
3628+
* binary-upgrade mode, we must dump the member objects of the extension,
3629+
* so be sure to fetch any such functions.
3630+
*/
36123631

36133632
if (g_fout->remoteVersion >=70300)
36143633
{
@@ -3617,12 +3636,20 @@ getFuncs(int *numFuncs)
36173636
"pronargs, proargtypes, prorettype, proacl, "
36183637
"pronamespace, "
36193638
"(%s proowner) AS rolname "
3620-
"FROM pg_proc "
3621-
"WHERE NOT proisagg "
3622-
"ANDpronamespace != "
3639+
"FROM pg_procp"
3640+
"WHERE NOT proisaggAND ("
3641+
"pronamespace != "
36233642
"(SELECT oid FROM pg_namespace "
36243643
"WHERE nspname = 'pg_catalog')",
36253644
username_subquery);
3645+
if (binary_upgrade&&g_fout->remoteVersion >=90100)
3646+
appendPQExpBuffer(query,
3647+
" OR EXISTS(SELECT 1 FROM pg_depend WHERE "
3648+
"classid = 'pg_proc'::regclass AND "
3649+
"objid = p.oid AND "
3650+
"refclassid = 'pg_extension'::regclass AND "
3651+
"deptype = 'e')");
3652+
appendPQExpBuffer(query,")");
36263653
}
36273654
elseif (g_fout->remoteVersion >=70100)
36283655
{
@@ -13319,6 +13346,8 @@ getExtensionMembership(ExtensionInfo extinfo[], int numExtensions)
1331913346
*/
1332013347
if (!binary_upgrade)
1332113348
dobj->dump= false;
13349+
else
13350+
dobj->dump=refdobj->dump;
1332213351
}
1332313352

1332413353
PQclear(res);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp