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

Commit3d2b6cd

Browse files
committed
pg_upgrade: warn about extensions that need updating
Also create a script that can be run to update them.Reported-by: Dave CramerDiscussion:https://postgr.es/m/CADK3HHKawwbOcGwMGnDuAf3-U8YfvTcS8jqDv3UM=niijs3MMA@mail.gmail.comBackpatch-through: 9.6
1 parentcc7091d commit3d2b6cd

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

‎src/bin/pg_upgrade/check.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ issue_warnings_and_set_wal_level(void)
199199
if (GET_MAJOR_VERSION(old_cluster.major_version) <=906)
200200
old_9_6_invalidate_hash_indexes(&new_cluster, false);
201201

202+
report_extension_updates(&new_cluster);
203+
202204
stop_postmaster(false);
203205
}
204206

‎src/bin/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ voidold_9_3_check_for_line_data_type_usage(ClusterInfo *cluster);
454454
voidold_9_6_check_for_unknown_data_type_usage(ClusterInfo*cluster);
455455
voidold_9_6_invalidate_hash_indexes(ClusterInfo*cluster,
456456
boolcheck_mode);
457+
voidreport_extension_updates(ClusterInfo*cluster);
457458

458459
/* parallel.c */
459460
voidparallel_exec_prog(constchar*log_file,constchar*opt_log_file,

‎src/bin/pg_upgrade/version.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,81 @@ old_9_6_invalidate_hash_indexes(ClusterInfo *cluster, bool check_mode)
437437
else
438438
check_ok();
439439
}
440+
441+
442+
/*
443+
* report_extension_updates()
444+
*Report extensions that should be updated.
445+
*/
446+
void
447+
report_extension_updates(ClusterInfo*cluster)
448+
{
449+
intdbnum;
450+
FILE*script=NULL;
451+
boolfound= false;
452+
char*output_path="update_extensions.sql";
453+
454+
prep_status("Checking for extension updates");
455+
456+
for (dbnum=0;dbnum<cluster->dbarr.ndbs;dbnum++)
457+
{
458+
PGresult*res;
459+
booldb_used= false;
460+
intntups;
461+
introwno;
462+
inti_name;
463+
DbInfo*active_db=&cluster->dbarr.dbs[dbnum];
464+
PGconn*conn=connectToServer(cluster,active_db->db_name);
465+
466+
/* find hash indexes */
467+
res=executeQueryOrDie(conn,
468+
"SELECT name "
469+
"FROM pg_available_extensions "
470+
"WHERE installed_version != default_version"
471+
);
472+
473+
ntups=PQntuples(res);
474+
i_name=PQfnumber(res,"name");
475+
for (rowno=0;rowno<ntups;rowno++)
476+
{
477+
found= true;
478+
479+
if (script==NULL&& (script=fopen_priv(output_path,"w"))==NULL)
480+
pg_fatal("could not open file \"%s\": %s\n",output_path,
481+
strerror(errno));
482+
if (!db_used)
483+
{
484+
PQExpBufferDataconnectbuf;
485+
486+
initPQExpBuffer(&connectbuf);
487+
appendPsqlMetaConnect(&connectbuf,active_db->db_name);
488+
fputs(connectbuf.data,script);
489+
termPQExpBuffer(&connectbuf);
490+
db_used= true;
491+
}
492+
fprintf(script,"ALTER EXTENSION %s UPDATE;\n",
493+
quote_identifier(PQgetvalue(res,rowno,i_name)));
494+
}
495+
496+
PQclear(res);
497+
498+
PQfinish(conn);
499+
}
500+
501+
if (script)
502+
fclose(script);
503+
504+
if (found)
505+
{
506+
report_status(PG_REPORT,"notice");
507+
pg_log(PG_REPORT,"\n"
508+
"Your installation contains extensions that should be updated\n"
509+
"with the ALTER EXTENSION command. The file\n"
510+
" %s\n"
511+
"when executed by psql by the database superuser will update\n"
512+
"these extensions.\n\n",
513+
output_path);
514+
}
515+
else
516+
check_ok();
517+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp