@@ -468,3 +468,81 @@ old_11_check_for_sql_identifier_data_type_usage(ClusterInfo *cluster)
468
468
else
469
469
check_ok ();
470
470
}
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
+ int dbnum ;
481
+ FILE * script = NULL ;
482
+ bool found = 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
+ bool db_used = false;
491
+ int ntups ;
492
+ int rowno ;
493
+ int i_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
+ PQExpBufferData connectbuf ;
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