@@ -234,13 +234,22 @@ issue_warnings_and_set_wal_level(void)
234
234
235
235
236
236
void
237
- output_completion_banner (char * analyze_script_file_name ,
238
- char * deletion_script_file_name )
237
+ output_completion_banner (char * deletion_script_file_name )
239
238
{
239
+ PQExpBufferData user_specification ;
240
+
241
+ initPQExpBuffer (& user_specification );
242
+ if (os_info .user_specified )
243
+ {
244
+ appendPQExpBufferStr (& user_specification , "-U " );
245
+ appendShellString (& user_specification , os_info .user );
246
+ appendPQExpBufferChar (& user_specification , ' ' );
247
+ }
248
+
240
249
pg_log (PG_REPORT ,
241
250
"Optimizer statistics are not transferred by pg_upgrade so,\n"
242
251
"once you start the new server, consider running:\n"
243
- " %s\n\n" , analyze_script_file_name );
252
+ " %s/vacuumdb %s--all --analyze-in-stages \n\n" , new_cluster . bindir , user_specification . data );
244
253
245
254
if (deletion_script_file_name )
246
255
pg_log (PG_REPORT ,
@@ -253,6 +262,8 @@ output_completion_banner(char *analyze_script_file_name,
253
262
"because user-defined tablespaces or the new cluster's data directory\n"
254
263
"exist in the old cluster directory. The old cluster's contents must\n"
255
264
"be deleted manually.\n" );
265
+
266
+ termPQExpBuffer (& user_specification );
256
267
}
257
268
258
269
@@ -446,90 +457,6 @@ check_databases_are_compatible(void)
446
457
}
447
458
}
448
459
449
-
450
- /*
451
- * create_script_for_cluster_analyze()
452
- *
453
- * This incrementally generates better optimizer statistics
454
- */
455
- void
456
- create_script_for_cluster_analyze (char * * analyze_script_file_name )
457
- {
458
- FILE * script = NULL ;
459
- PQExpBufferData user_specification ;
460
-
461
- prep_status ("Creating script to analyze new cluster" );
462
-
463
- initPQExpBuffer (& user_specification );
464
- if (os_info .user_specified )
465
- {
466
- appendPQExpBufferStr (& user_specification , "-U " );
467
- appendShellString (& user_specification , os_info .user );
468
- appendPQExpBufferChar (& user_specification , ' ' );
469
- }
470
-
471
- * analyze_script_file_name = psprintf ("%sanalyze_new_cluster.%s" ,
472
- SCRIPT_PREFIX , SCRIPT_EXT );
473
-
474
- if ((script = fopen_priv (* analyze_script_file_name , "w" )) == NULL )
475
- pg_fatal ("could not open file \"%s\": %s\n" ,
476
- * analyze_script_file_name , strerror (errno ));
477
-
478
- #ifndef WIN32
479
- /* add shebang header */
480
- fprintf (script , "#!/bin/sh\n\n" );
481
- #else
482
- /* suppress command echoing */
483
- fprintf (script , "@echo off\n" );
484
- #endif
485
-
486
- fprintf (script , "echo %sThis script will generate minimal optimizer statistics rapidly%s\n" ,
487
- ECHO_QUOTE , ECHO_QUOTE );
488
- fprintf (script , "echo %sso your system is usable, and then gather statistics twice more%s\n" ,
489
- ECHO_QUOTE , ECHO_QUOTE );
490
- fprintf (script , "echo %swith increasing accuracy. When it is done, your system will%s\n" ,
491
- ECHO_QUOTE , ECHO_QUOTE );
492
- fprintf (script , "echo %shave the default level of optimizer statistics.%s\n" ,
493
- ECHO_QUOTE , ECHO_QUOTE );
494
- fprintf (script , "echo%s\n\n" , ECHO_BLANK );
495
-
496
- fprintf (script , "echo %sIf you have used ALTER TABLE to modify the statistics target for%s\n" ,
497
- ECHO_QUOTE , ECHO_QUOTE );
498
- fprintf (script , "echo %sany tables, you might want to remove them and restore them after%s\n" ,
499
- ECHO_QUOTE , ECHO_QUOTE );
500
- fprintf (script , "echo %srunning this script because they will delay fast statistics generation.%s\n" ,
501
- ECHO_QUOTE , ECHO_QUOTE );
502
- fprintf (script , "echo%s\n\n" , ECHO_BLANK );
503
-
504
- fprintf (script , "echo %sIf you would like default statistics as quickly as possible, cancel%s\n" ,
505
- ECHO_QUOTE , ECHO_QUOTE );
506
- fprintf (script , "echo %sthis script and run:%s\n" ,
507
- ECHO_QUOTE , ECHO_QUOTE );
508
- fprintf (script , "echo %s \"%s/vacuumdb\" %s--all --analyze-only%s\n" , ECHO_QUOTE ,
509
- new_cluster .bindir , user_specification .data , ECHO_QUOTE );
510
- fprintf (script , "echo%s\n\n" , ECHO_BLANK );
511
-
512
- fprintf (script , "\"%s/vacuumdb\" %s--all --analyze-in-stages\n" ,
513
- new_cluster .bindir , user_specification .data );
514
-
515
- fprintf (script , "echo%s\n\n" , ECHO_BLANK );
516
- fprintf (script , "echo %sDone%s\n" ,
517
- ECHO_QUOTE , ECHO_QUOTE );
518
-
519
- fclose (script );
520
-
521
- #ifndef WIN32
522
- if (chmod (* analyze_script_file_name , S_IRWXU ) != 0 )
523
- pg_fatal ("could not add execute permission to file \"%s\": %s\n" ,
524
- * analyze_script_file_name , strerror (errno ));
525
- #endif
526
-
527
- termPQExpBuffer (& user_specification );
528
-
529
- check_ok ();
530
- }
531
-
532
-
533
460
/*
534
461
* A previous run of pg_upgrade might have failed and the new cluster
535
462
* directory recreated, but they might have forgotten to remove
0 commit comments