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

Commit0f33261

Browse files
committed
In pg_upgrade, report pre-PG 8.1 plpython helper functions left in the
public schema that no longer point to valid shared object libraries, andsuggest a solution.Backpatch to 9.1 (already in head)
1 parentaf97980 commit0f33261

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

‎contrib/pg_upgrade/function.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ get_loadable_libraries(void)
130130
PGresult**ress;
131131
inttotaltups;
132132
intdbnum;
133+
boolfound_public_plpython_handler= false;
133134

134135
ress= (PGresult**)
135136
pg_malloc(old_cluster.dbarr.ndbs*sizeof(PGresult*));
@@ -151,9 +152,67 @@ get_loadable_libraries(void)
151152
FirstNormalObjectId);
152153
totaltups+=PQntuples(ress[dbnum]);
153154

155+
/*
156+
*Systems that install plpython before 8.1 have
157+
*plpython_call_handler() defined in the "public" schema, causing
158+
*pg_dumpall to dump it. However that function still references
159+
*"plpython" (no "2"), so it throws an error on restore. This code
160+
*checks for the problem function, reports affected databases to the
161+
*user and explains how to remove them.
162+
*8.1 git commit: e0dedd0559f005d60c69c9772163e69c204bac69
163+
*http://archives.postgresql.org/pgsql-hackers/2012-03/msg01101.php
164+
*http://archives.postgresql.org/pgsql-bugs/2012-05/msg00206.php
165+
*/
166+
if (GET_MAJOR_VERSION(old_cluster.major_version)<901)
167+
{
168+
PGresult*res;
169+
170+
res=executeQueryOrDie(conn,
171+
"SELECT 1 "
172+
"FROMpg_catalog.pg_proc JOIN pg_namespace "
173+
"ON pronamespace = pg_namespace.oid "
174+
"WHERE proname = 'plpython_call_handler' AND "
175+
"nspname = 'public' AND "
176+
"prolang = 13 /* C */ AND "
177+
"probin = '$libdir/plpython' AND "
178+
"pg_proc.oid >= %u;",
179+
FirstNormalObjectId);
180+
if (PQntuples(res)>0)
181+
{
182+
if (!found_public_plpython_handler)
183+
{
184+
pg_log(PG_WARNING,
185+
"\nThe old cluster has a \"plpython_call_handler\" function defined\n"
186+
"in the \"public\" schema which is a duplicate of the one defined\n"
187+
"in the \"pg_catalog\" schema. You can confirm this by executing\n"
188+
"in psql:\n"
189+
"\n"
190+
"\\df *.plpython_call_handler\n"
191+
"\n"
192+
"The \"public\" schema version of this function was created by a\n"
193+
"pre-8.1 install of plpython, and must be removed for pg_upgrade\n"
194+
"to complete because it references a now-obsolete \"plpython\"\n"
195+
"shared object file. You can remove the \"public\" schema version\n"
196+
"of this function by running the following command:\n"
197+
"\n"
198+
"DROP FUNCTION public.plpython_call_handler()\n"
199+
"\n"
200+
"in each affected database:\n"
201+
"\n");
202+
}
203+
pg_log(PG_WARNING,"%s\n",active_db->db_name);
204+
found_public_plpython_handler= true;
205+
}
206+
PQclear(res);
207+
}
208+
154209
PQfinish(conn);
155210
}
156211

212+
if (found_public_plpython_handler)
213+
pg_log(PG_FATAL,
214+
"Remove the problem functions from the old cluster to continue.\n");
215+
157216
totaltups++;/* reserve for pg_upgrade_support */
158217

159218
/* Allocate what's certainly enough space */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp