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

Commite462856

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 parent5090d70 commite462856

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
@@ -241,6 +241,8 @@ issue_warnings_and_set_wal_level(void)
241241
if (GET_MAJOR_VERSION(old_cluster.major_version) <=906)
242242
old_9_6_invalidate_hash_indexes(&new_cluster, false);
243243

244+
report_extension_updates(&new_cluster);
245+
244246
stop_postmaster(false);
245247
}
246248

‎src/bin/pg_upgrade/pg_upgrade.h

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

457457
voidold_11_check_for_sql_identifier_data_type_usage(ClusterInfo*cluster);
458+
voidreport_extension_updates(ClusterInfo*cluster);
458459

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp