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

Commitc3106a3

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 parent336059f commitc3106a3

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
@@ -72,6 +72,7 @@ check_old_cluster(migratorContext *ctx, bool live_check,
7272
{
7373
old_8_3_check_for_name_data_type_usage(ctx,CLUSTER_OLD);
7474
old_8_3_check_for_tsquery_usage(ctx,CLUSTER_OLD);
75+
old_8_3_check_ltree_usage(ctx,CLUSTER_OLD);
7576
if (ctx->check)
7677
{
7778
old_8_3_rebuild_tsvector_tables(ctx, true,CLUSTER_OLD);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ void old_8_3_check_for_name_data_type_usage(migratorContext *ctx,
394394
ClusterwhichCluster);
395395
voidold_8_3_check_for_tsquery_usage(migratorContext*ctx,
396396
ClusterwhichCluster);
397+
voidold_8_3_check_ltree_usage(migratorContext*ctx,
398+
ClusterwhichCluster);
397399
voidold_8_3_rebuild_tsvector_tables(migratorContext*ctx,
398400
boolcheck_mode,ClusterwhichCluster);
399401
voidold_8_3_invalidate_hash_gin_indexes(migratorContext*ctx,

‎contrib/pg_upgrade/version_old_8_3.c

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,86 @@ old_8_3_check_for_tsquery_usage(migratorContext *ctx, Cluster whichCluster)
203203
}
204204

205205

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

‎doc/src/sgml/pgupgrade.sgml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,11 @@ psql --username postgres --file script.sql postgres
464464
</itemizedlist>
465465
</para>
466466

467+
<para>
468+
pg_upgrade will not work if the <filename>ltree</>
469+
contrib module is installed in a database.
470+
</para>
471+
467472
<para>
468473
You must drop any such columns and migrate them manually.
469474
</para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp