On Mon, Nov 9, 2020 at 8:53 AM Michael Paquier <[email protected]> wrote:
>
> On Mon, Nov 02, 2020 at 02:18:32PM +0100, Magnus Hagander wrote:
> > On Fri, Oct 30, 2020 at 5:10 PM Georgios Kokolatos
> > <[email protected]> wrote:
> >> I did notice that the cfbot [1] is failing for this patch.
> >> Please try to address the issues for the upcoming Commitfest.
> >
> > Thanks for the notice -- PFA a rebased version!
>
> No objections to remove this script from me.
>
> I have spotted one small-ish thing. This patch is missing to update
> the following code in vcregress.pl:
> print "\nSetting up stats on new cluster\n\n";
> system(".\\analyze_new_cluster.bat") == 0 or exit 1;
Ah, nice catch -- thanks! I guess this is unfortunately not a test
that's part of what cfbot tests.
Untested on Windows, but following the patterns of the rows before it.
I will go ahead and push this version in a bit.
--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/
diff --git a/src/bin/pg_upgrade/.gitignore b/src/bin/pg_upgrade/.gitignore
index 9edea5c98f..2d3bfeaa50 100644
--- a/src/bin/pg_upgrade/.gitignore
+++ b/src/bin/pg_upgrade/.gitignore
@@ -1,9 +1,7 @@
/pg_upgrade
# Generated by test suite
/pg_upgrade_internal.log
-/analyze_new_cluster.sh
/delete_old_cluster.sh
-/analyze_new_cluster.bat
/delete_old_cluster.bat
/reindex_hash.sql
/loadable_libraries.txt
diff --git a/src/bin/pg_upgrade/Makefile b/src/bin/pg_upgrade/Makefile
index 0360c37bf9..44d06be5a6 100644
--- a/src/bin/pg_upgrade/Makefile
+++ b/src/bin/pg_upgrade/Makefile
@@ -44,7 +44,7 @@ uninstall:
clean distclean maintainer-clean:
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 \
pg_upgrade_dump_globals.sql \
pg_upgrade_dump_*.custom pg_upgrade_*.log
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 05e6bf7f2c..6685d517ff 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -234,13 +234,22 @@ issue_warnings_and_set_wal_level(void)
void
-output_completion_banner(char *analyze_script_file_name,
- char *deletion_script_file_name)
+output_completion_banner(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,
"Optimizer statistics are not transferred by pg_upgrade so,\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)
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"
"exist in the old cluster directory. The old cluster's contents must\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
* directory recreated, but they might have forgotten to remove
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 1bc86e4205..e2253ecd5d 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -75,7 +75,6 @@ char *output_files[] = {
int
main(int argc, char **argv)
{
- char *analyze_script_file_name = NULL;
char *deletion_script_file_name = NULL;
bool live_check = false;
@@ -176,7 +175,6 @@ main(int argc, char **argv)
new_cluster.pgdata);
check_ok();
- create_script_for_cluster_analyze(&analyze_script_file_name);
create_script_for_old_cluster_deletion(&deletion_script_file_name);
issue_warnings_and_set_wal_level();
@@ -186,10 +184,8 @@ main(int argc, char **argv)
"Upgrade Complete\n"
"----------------\n");
- output_completion_banner(analyze_script_file_name,
- deletion_script_file_name);
+ output_completion_banner(deletion_script_file_name);
- pg_free(analyze_script_file_name);
pg_free(deletion_script_file_name);
cleanup();
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 19c64513b0..ee70243c2e 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -334,12 +334,10 @@ void check_and_dump_old_cluster(bool live_check);
void check_new_cluster(void);
void report_clusters_compatible(void);
void issue_warnings_and_set_wal_level(void);
-void output_completion_banner(char *analyze_script_file_name,
- char *deletion_script_file_name);
+void output_completion_banner(char *deletion_script_file_name);
void check_cluster_versions(void);
void check_cluster_compatibility(bool live_check);
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 */
diff --git a/src/bin/pg_upgrade/test.sh b/src/bin/pg_upgrade/test.sh
index 7ff06de6d1..551ac8a5c2 100644
--- a/src/bin/pg_upgrade/test.sh
+++ b/src/bin/pg_upgrade/test.sh
@@ -243,13 +243,7 @@ esac
pg_ctl start -l "$logdir/postmaster2.log" -o "$POSTMASTER_OPTS" -w
-# In the commands below we inhibit msys2 from converting the "/c" switch
-# 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
+vacuumdb --all --analyze-in-stages
pg_dumpall --no-sync -f "$temp_root"/dump2.sql || pg_dumpall2_status=$?
pg_ctl -m fast stop
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 3365ee578c..9799c5f54b 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -607,7 +607,8 @@ sub upgradecheck
@args = ('pg_ctl', '-l', "$logdir/postmaster2.log", 'start');
system(@args) == 0 or exit 1;
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";
@args = ('pg_dumpall', '-f', "$tmp_root/dump2.sql");
system(@args) == 0 or exit 1;