mirror of
https://github.com/postgres/postgres.git
synced 2025-06-23 14:01:44 +03:00
Remove analyze_new_cluster script from pg_upgrade
Since this script just runs vacuumdb anyway, remove the script and replace the instructions to run it with instructions to run vacuumdb directly. Reviewed-By: Michael Paquier Discussion: https://postgr.es/m/CABUevEwg5LDFzthhxzSj7sZGMiVsZe0VVNbzzwTQOHJ=rN7+5A@mail.gmail.com
This commit is contained in:
2
src/bin/pg_upgrade/.gitignore
vendored
2
src/bin/pg_upgrade/.gitignore
vendored
@ -1,9 +1,7 @@
|
|||||||
/pg_upgrade
|
/pg_upgrade
|
||||||
# Generated by test suite
|
# Generated by test suite
|
||||||
/pg_upgrade_internal.log
|
/pg_upgrade_internal.log
|
||||||
/analyze_new_cluster.sh
|
|
||||||
/delete_old_cluster.sh
|
/delete_old_cluster.sh
|
||||||
/analyze_new_cluster.bat
|
|
||||||
/delete_old_cluster.bat
|
/delete_old_cluster.bat
|
||||||
/reindex_hash.sql
|
/reindex_hash.sql
|
||||||
/loadable_libraries.txt
|
/loadable_libraries.txt
|
||||||
|
@ -44,7 +44,7 @@ uninstall:
|
|||||||
|
|
||||||
clean distclean maintainer-clean:
|
clean distclean maintainer-clean:
|
||||||
rm -f pg_upgrade$(X) $(OBJS)
|
rm -f pg_upgrade$(X) $(OBJS)
|
||||||
rm -rf analyze_new_cluster.sh delete_old_cluster.sh log/ tmp_check/ \
|
rm -rf delete_old_cluster.sh log/ tmp_check/ \
|
||||||
loadable_libraries.txt reindex_hash.sql \
|
loadable_libraries.txt reindex_hash.sql \
|
||||||
pg_upgrade_dump_globals.sql \
|
pg_upgrade_dump_globals.sql \
|
||||||
pg_upgrade_dump_*.custom pg_upgrade_*.log
|
pg_upgrade_dump_*.custom pg_upgrade_*.log
|
||||||
|
@ -234,13 +234,22 @@ issue_warnings_and_set_wal_level(void)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
output_completion_banner(char *analyze_script_file_name,
|
output_completion_banner(char *deletion_script_file_name)
|
||||||
char *deletion_script_file_name)
|
|
||||||
{
|
{
|
||||||
|
PQExpBufferData user_specification;
|
||||||
|
|
||||||
|
initPQExpBuffer(&user_specification);
|
||||||
|
if (os_info.user_specified)
|
||||||
|
{
|
||||||
|
appendPQExpBufferStr(&user_specification, "-U ");
|
||||||
|
appendShellString(&user_specification, os_info.user);
|
||||||
|
appendPQExpBufferChar(&user_specification, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
pg_log(PG_REPORT,
|
pg_log(PG_REPORT,
|
||||||
"Optimizer statistics are not transferred by pg_upgrade so,\n"
|
"Optimizer statistics are not transferred by pg_upgrade so,\n"
|
||||||
"once you start the new server, consider running:\n"
|
"once you start the new server, consider running:\n"
|
||||||
" %s\n\n", analyze_script_file_name);
|
" %s/vacuumdb %s--all --analyze-in-stages\n\n", new_cluster.bindir, user_specification.data);
|
||||||
|
|
||||||
if (deletion_script_file_name)
|
if (deletion_script_file_name)
|
||||||
pg_log(PG_REPORT,
|
pg_log(PG_REPORT,
|
||||||
@ -253,6 +262,8 @@ output_completion_banner(char *analyze_script_file_name,
|
|||||||
"because user-defined tablespaces or the new cluster's data directory\n"
|
"because user-defined tablespaces or the new cluster's data directory\n"
|
||||||
"exist in the old cluster directory. The old cluster's contents must\n"
|
"exist in the old cluster directory. The old cluster's contents must\n"
|
||||||
"be deleted manually.\n");
|
"be deleted manually.\n");
|
||||||
|
|
||||||
|
termPQExpBuffer(&user_specification);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -446,90 +457,6 @@ check_databases_are_compatible(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* create_script_for_cluster_analyze()
|
|
||||||
*
|
|
||||||
* This incrementally generates better optimizer statistics
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
create_script_for_cluster_analyze(char **analyze_script_file_name)
|
|
||||||
{
|
|
||||||
FILE *script = NULL;
|
|
||||||
PQExpBufferData user_specification;
|
|
||||||
|
|
||||||
prep_status("Creating script to analyze new cluster");
|
|
||||||
|
|
||||||
initPQExpBuffer(&user_specification);
|
|
||||||
if (os_info.user_specified)
|
|
||||||
{
|
|
||||||
appendPQExpBufferStr(&user_specification, "-U ");
|
|
||||||
appendShellString(&user_specification, os_info.user);
|
|
||||||
appendPQExpBufferChar(&user_specification, ' ');
|
|
||||||
}
|
|
||||||
|
|
||||||
*analyze_script_file_name = psprintf("%sanalyze_new_cluster.%s",
|
|
||||||
SCRIPT_PREFIX, SCRIPT_EXT);
|
|
||||||
|
|
||||||
if ((script = fopen_priv(*analyze_script_file_name, "w")) == NULL)
|
|
||||||
pg_fatal("could not open file \"%s\": %s\n",
|
|
||||||
*analyze_script_file_name, strerror(errno));
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
/* add shebang header */
|
|
||||||
fprintf(script, "#!/bin/sh\n\n");
|
|
||||||
#else
|
|
||||||
/* suppress command echoing */
|
|
||||||
fprintf(script, "@echo off\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(script, "echo %sThis script will generate minimal optimizer statistics rapidly%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo %sso your system is usable, and then gather statistics twice more%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo %swith increasing accuracy. When it is done, your system will%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo %shave the default level of optimizer statistics.%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo%s\n\n", ECHO_BLANK);
|
|
||||||
|
|
||||||
fprintf(script, "echo %sIf you have used ALTER TABLE to modify the statistics target for%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo %sany tables, you might want to remove them and restore them after%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo %srunning this script because they will delay fast statistics generation.%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo%s\n\n", ECHO_BLANK);
|
|
||||||
|
|
||||||
fprintf(script, "echo %sIf you would like default statistics as quickly as possible, cancel%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo %sthis script and run:%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo %s \"%s/vacuumdb\" %s--all --analyze-only%s\n", ECHO_QUOTE,
|
|
||||||
new_cluster.bindir, user_specification.data, ECHO_QUOTE);
|
|
||||||
fprintf(script, "echo%s\n\n", ECHO_BLANK);
|
|
||||||
|
|
||||||
fprintf(script, "\"%s/vacuumdb\" %s--all --analyze-in-stages\n",
|
|
||||||
new_cluster.bindir, user_specification.data);
|
|
||||||
|
|
||||||
fprintf(script, "echo%s\n\n", ECHO_BLANK);
|
|
||||||
fprintf(script, "echo %sDone%s\n",
|
|
||||||
ECHO_QUOTE, ECHO_QUOTE);
|
|
||||||
|
|
||||||
fclose(script);
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
if (chmod(*analyze_script_file_name, S_IRWXU) != 0)
|
|
||||||
pg_fatal("could not add execute permission to file \"%s\": %s\n",
|
|
||||||
*analyze_script_file_name, strerror(errno));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
termPQExpBuffer(&user_specification);
|
|
||||||
|
|
||||||
check_ok();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* A previous run of pg_upgrade might have failed and the new cluster
|
* A previous run of pg_upgrade might have failed and the new cluster
|
||||||
* directory recreated, but they might have forgotten to remove
|
* directory recreated, but they might have forgotten to remove
|
||||||
|
@ -75,7 +75,6 @@ char *output_files[] = {
|
|||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *analyze_script_file_name = NULL;
|
|
||||||
char *deletion_script_file_name = NULL;
|
char *deletion_script_file_name = NULL;
|
||||||
bool live_check = false;
|
bool live_check = false;
|
||||||
|
|
||||||
@ -176,7 +175,6 @@ main(int argc, char **argv)
|
|||||||
new_cluster.pgdata);
|
new_cluster.pgdata);
|
||||||
check_ok();
|
check_ok();
|
||||||
|
|
||||||
create_script_for_cluster_analyze(&analyze_script_file_name);
|
|
||||||
create_script_for_old_cluster_deletion(&deletion_script_file_name);
|
create_script_for_old_cluster_deletion(&deletion_script_file_name);
|
||||||
|
|
||||||
issue_warnings_and_set_wal_level();
|
issue_warnings_and_set_wal_level();
|
||||||
@ -186,10 +184,8 @@ main(int argc, char **argv)
|
|||||||
"Upgrade Complete\n"
|
"Upgrade Complete\n"
|
||||||
"----------------\n");
|
"----------------\n");
|
||||||
|
|
||||||
output_completion_banner(analyze_script_file_name,
|
output_completion_banner(deletion_script_file_name);
|
||||||
deletion_script_file_name);
|
|
||||||
|
|
||||||
pg_free(analyze_script_file_name);
|
|
||||||
pg_free(deletion_script_file_name);
|
pg_free(deletion_script_file_name);
|
||||||
|
|
||||||
cleanup();
|
cleanup();
|
||||||
|
@ -334,12 +334,10 @@ void check_and_dump_old_cluster(bool live_check);
|
|||||||
void check_new_cluster(void);
|
void check_new_cluster(void);
|
||||||
void report_clusters_compatible(void);
|
void report_clusters_compatible(void);
|
||||||
void issue_warnings_and_set_wal_level(void);
|
void issue_warnings_and_set_wal_level(void);
|
||||||
void output_completion_banner(char *analyze_script_file_name,
|
void output_completion_banner(char *deletion_script_file_name);
|
||||||
char *deletion_script_file_name);
|
|
||||||
void check_cluster_versions(void);
|
void check_cluster_versions(void);
|
||||||
void check_cluster_compatibility(bool live_check);
|
void check_cluster_compatibility(bool live_check);
|
||||||
void create_script_for_old_cluster_deletion(char **deletion_script_file_name);
|
void create_script_for_old_cluster_deletion(char **deletion_script_file_name);
|
||||||
void create_script_for_cluster_analyze(char **analyze_script_file_name);
|
|
||||||
|
|
||||||
|
|
||||||
/* controldata.c */
|
/* controldata.c */
|
||||||
|
@ -243,13 +243,7 @@ esac
|
|||||||
|
|
||||||
pg_ctl start -l "$logdir/postmaster2.log" -o "$POSTMASTER_OPTS" -w
|
pg_ctl start -l "$logdir/postmaster2.log" -o "$POSTMASTER_OPTS" -w
|
||||||
|
|
||||||
# In the commands below we inhibit msys2 from converting the "/c" switch
|
vacuumdb --all --analyze-in-stages
|
||||||
# in "cmd /c" to a file system path.
|
|
||||||
|
|
||||||
case $testhost in
|
|
||||||
MINGW*) MSYS2_ARG_CONV_EXCL=/c cmd /c analyze_new_cluster.bat ;;
|
|
||||||
*) sh ./analyze_new_cluster.sh ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
pg_dumpall --no-sync -f "$temp_root"/dump2.sql || pg_dumpall2_status=$?
|
pg_dumpall --no-sync -f "$temp_root"/dump2.sql || pg_dumpall2_status=$?
|
||||||
pg_ctl -m fast stop
|
pg_ctl -m fast stop
|
||||||
|
@ -607,7 +607,8 @@ sub upgradecheck
|
|||||||
@args = ('pg_ctl', '-l', "$logdir/postmaster2.log", 'start');
|
@args = ('pg_ctl', '-l', "$logdir/postmaster2.log", 'start');
|
||||||
system(@args) == 0 or exit 1;
|
system(@args) == 0 or exit 1;
|
||||||
print "\nSetting up stats on new cluster\n\n";
|
print "\nSetting up stats on new cluster\n\n";
|
||||||
system(".\\analyze_new_cluster.bat") == 0 or exit 1;
|
@args = ('vacuumdb', '--all', '--analyze-in-stages');
|
||||||
|
system(@args) == 0 or exit 1;
|
||||||
print "\nDumping new cluster\n\n";
|
print "\nDumping new cluster\n\n";
|
||||||
@args = ('pg_dumpall', '-f', "$tmp_root/dump2.sql");
|
@args = ('pg_dumpall', '-f', "$tmp_root/dump2.sql");
|
||||||
system(@args) == 0 or exit 1;
|
system(@args) == 0 or exit 1;
|
||||||
|
Reference in New Issue
Block a user