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

Commita81c71e

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 parent0e6cf3c commita81c71e

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
@@ -223,6 +223,8 @@ issue_warnings_and_set_wal_level(void)
223223
if (GET_MAJOR_VERSION(old_cluster.major_version) <=906)
224224
old_9_6_invalidate_hash_indexes(&new_cluster, false);
225225

226+
report_extension_updates(&new_cluster);
227+
226228
stop_postmaster(false);
227229
}
228230

‎src/bin/pg_upgrade/pg_upgrade.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ voidold_9_6_invalidate_hash_indexes(ClusterInfo *cluster,
457457
boolcheck_mode);
458458

459459
voidold_11_check_for_sql_identifier_data_type_usage(ClusterInfo*cluster);
460+
voidreport_extension_updates(ClusterInfo*cluster);
460461

461462
/* parallel.c */
462463
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
@@ -466,3 +466,81 @@ old_11_check_for_sql_identifier_data_type_usage(ClusterInfo *cluster)
466466
else
467467
check_ok();
468468
}
469+
470+
471+
/*
472+
* report_extension_updates()
473+
*Report extensions that should be updated.
474+
*/
475+
void
476+
report_extension_updates(ClusterInfo*cluster)
477+
{
478+
intdbnum;
479+
FILE*script=NULL;
480+
boolfound= false;
481+
char*output_path="update_extensions.sql";
482+
483+
prep_status("Checking for extension updates");
484+
485+
for (dbnum=0;dbnum<cluster->dbarr.ndbs;dbnum++)
486+
{
487+
PGresult*res;
488+
booldb_used= false;
489+
intntups;
490+
introwno;
491+
inti_name;
492+
DbInfo*active_db=&cluster->dbarr.dbs[dbnum];
493+
PGconn*conn=connectToServer(cluster,active_db->db_name);
494+
495+
/* find hash indexes */
496+
res=executeQueryOrDie(conn,
497+
"SELECT name "
498+
"FROM pg_available_extensions "
499+
"WHERE installed_version != default_version"
500+
);
501+
502+
ntups=PQntuples(res);
503+
i_name=PQfnumber(res,"name");
504+
for (rowno=0;rowno<ntups;rowno++)
505+
{
506+
found= true;
507+
508+
if (script==NULL&& (script=fopen_priv(output_path,"w"))==NULL)
509+
pg_fatal("could not open file \"%s\": %s\n",output_path,
510+
strerror(errno));
511+
if (!db_used)
512+
{
513+
PQExpBufferDataconnectbuf;
514+
515+
initPQExpBuffer(&connectbuf);
516+
appendPsqlMetaConnect(&connectbuf,active_db->db_name);
517+
fputs(connectbuf.data,script);
518+
termPQExpBuffer(&connectbuf);
519+
db_used= true;
520+
}
521+
fprintf(script,"ALTER EXTENSION %s UPDATE;\n",
522+
quote_identifier(PQgetvalue(res,rowno,i_name)));
523+
}
524+
525+
PQclear(res);
526+
527+
PQfinish(conn);
528+
}
529+
530+
if (script)
531+
fclose(script);
532+
533+
if (found)
534+
{
535+
report_status(PG_REPORT,"notice");
536+
pg_log(PG_REPORT,"\n"
537+
"Your installation contains extensions that should be updated\n"
538+
"with the ALTER EXTENSION command. The file\n"
539+
" %s\n"
540+
"when executed by psql by the database superuser will update\n"
541+
"these extensions.\n\n",
542+
output_path);
543+
}
544+
else
545+
check_ok();
546+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp