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

Commit8cdd620

Browse files
committed
In pg_upgrade, disallow migration of 8.3 clusters using contrib/ltree
because its internal format was changed in 8.4.Backpatch to 9.0 and 9.1.Report by depesz, diagnosis by Tom.
1 parent673dfe9 commit8cdd620

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

‎contrib/pg_upgrade/check.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ check_old_cluster(bool live_check,
7777
{
7878
old_8_3_check_for_name_data_type_usage(&old_cluster);
7979
old_8_3_check_for_tsquery_usage(&old_cluster);
80+
old_8_3_check_ltree_usage(&old_cluster);
8081
if (user_opts.check)
8182
{
8283
old_8_3_rebuild_tsvector_tables(&old_cluster, true);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ void new_9_0_populate_pg_largeobject_metadata(ClusterInfo *cluster,
390390

391391
voidold_8_3_check_for_name_data_type_usage(ClusterInfo*cluster);
392392
voidold_8_3_check_for_tsquery_usage(ClusterInfo*cluster);
393+
voidold_8_3_check_ltree_usage(ClusterInfo*cluster);
393394
voidold_8_3_rebuild_tsvector_tables(ClusterInfo*cluster,boolcheck_mode);
394395
voidold_8_3_invalidate_hash_gin_indexes(ClusterInfo*cluster,boolcheck_mode);
395396
voidold_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo*cluster,

‎contrib/pg_upgrade/version_old_8_3.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,87 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
201201
}
202202

203203

204+
/*
205+
*old_8_3_check_ltree_usage()
206+
*8.3 -> 8.4
207+
*The internal ltree structure was changed in 8.4 so upgrading is impossible.
208+
*/
209+
void
210+
old_8_3_check_ltree_usage(ClusterInfo*cluster)
211+
{
212+
intdbnum;
213+
FILE*script=NULL;
214+
boolfound= false;
215+
charoutput_path[MAXPGPATH];
216+
217+
prep_status("Checking for contrib/ltree");
218+
219+
snprintf(output_path,sizeof(output_path),"%s/contrib_ltree.txt",
220+
os_info.cwd);
221+
222+
for (dbnum=0;dbnum<cluster->dbarr.ndbs;dbnum++)
223+
{
224+
PGresult*res;
225+
booldb_used= false;
226+
intntups;
227+
introwno;
228+
inti_nspname,
229+
i_proname;
230+
DbInfo*active_db=&cluster->dbarr.dbs[dbnum];
231+
PGconn*conn=connectToServer(cluster,active_db->db_name);
232+
233+
/* Find any functions coming from contrib/ltree */
234+
res=executeQueryOrDie(conn,
235+
"SELECT n.nspname, p.proname "
236+
"FROMpg_catalog.pg_proc p, "
237+
"pg_catalog.pg_namespace n "
238+
"WHEREp.pronamespace = n.oid AND "
239+
"p.probin = '$libdir/ltree'");
240+
241+
ntups=PQntuples(res);
242+
i_nspname=PQfnumber(res,"nspname");
243+
i_proname=PQfnumber(res,"proname");
244+
for (rowno=0;rowno<ntups;rowno++)
245+
{
246+
found= true;
247+
if (script==NULL&& (script=fopen(output_path,"w"))==NULL)
248+
pg_log(PG_FATAL,"Could not open file \"%s\": %s\n",
249+
output_path,getErrorText(errno));
250+
if (!db_used)
251+
{
252+
fprintf(script,"Database: %s\n",active_db->db_name);
253+
db_used= true;
254+
}
255+
fprintf(script," %s.%s\n",
256+
PQgetvalue(res,rowno,i_nspname),
257+
PQgetvalue(res,rowno,i_proname));
258+
}
259+
260+
PQclear(res);
261+
262+
PQfinish(conn);
263+
}
264+
265+
if (script)
266+
fclose(script);
267+
268+
if (found)
269+
{
270+
pg_log(PG_REPORT,"fatal\n");
271+
pg_log(PG_FATAL,
272+
"Your installation contains the \"ltree\" data type. This data type\n"
273+
"changed its internal storage format between your old and new clusters so this\n"
274+
"cluster cannot currently be upgraded. You can manually upgrade databases\n"
275+
"that use \"contrib/ltree\" facilities and remove \"contrib/ltree\" from the old\n"
276+
"cluster and restart the upgrade. A list of the problem functions is in the\n"
277+
"file:\n"
278+
" %s\n\n",output_path);
279+
}
280+
else
281+
check_ok();
282+
}
283+
284+
204285
/*
205286
* old_8_3_rebuild_tsvector_tables()
206287
*8.3 -> 8.4

‎doc/src/sgml/pgupgrade.sgml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,11 @@ psql --username postgres --file script.sql postgres
485485
You must drop any such columns and upgrade them manually.
486486
</para>
487487

488+
<para>
489+
pg_upgrade will not work if the <filename>ltree</>
490+
contrib module is installed in a database.
491+
</para>
492+
488493
<para>
489494
pg_upgrade will require a table rebuild if:
490495
<itemizedlist>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp