mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Run pgindent on 9.2 source tree in preparation for first 9.3
commit-fest.
This commit is contained in:
@ -168,7 +168,7 @@ issue_warnings(char *sequence_script_file_name)
|
||||
SYSTEMQUOTE "\"%s/psql\" --echo-queries "
|
||||
"--set ON_ERROR_STOP=on "
|
||||
"--no-psqlrc --port %d --username \"%s\" "
|
||||
"-f \"%s\" --dbname template1 >> \"%s\" 2>&1" SYSTEMQUOTE,
|
||||
"-f \"%s\" --dbname template1 >> \"%s\" 2>&1" SYSTEMQUOTE,
|
||||
new_cluster.bindir, new_cluster.port, os_info.user,
|
||||
sequence_script_file_name, UTILITY_LOG_FILE);
|
||||
unlink(sequence_script_file_name);
|
||||
@ -204,7 +204,7 @@ output_completion_banner(char *analyze_script_file_name,
|
||||
else
|
||||
pg_log(PG_REPORT,
|
||||
"Optimizer statistics and free space information are not transferred\n"
|
||||
"by pg_upgrade so, once you start the new server, consider running:\n"
|
||||
"by pg_upgrade so, once you start the new server, consider running:\n"
|
||||
" %s\n\n", analyze_script_file_name);
|
||||
|
||||
pg_log(PG_REPORT,
|
||||
@ -238,7 +238,8 @@ check_cluster_versions(void)
|
||||
|
||||
/*
|
||||
* We can't allow downgrading because we use the target pg_dumpall, and
|
||||
* pg_dumpall cannot operate on new database versions, only older versions.
|
||||
* pg_dumpall cannot operate on new database versions, only older
|
||||
* versions.
|
||||
*/
|
||||
if (old_cluster.major_version > new_cluster.major_version)
|
||||
pg_log(PG_FATAL, "This utility cannot be used to downgrade to older major PostgreSQL versions.\n");
|
||||
@ -402,31 +403,31 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
|
||||
#endif
|
||||
|
||||
fprintf(script, "echo %sThis script will generate minimal optimizer statistics rapidly%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %sso your system is usable, and then gather statistics twice more%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %swith increasing accuracy. When it is done, your system will%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %shave the default level of optimizer statistics.%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo\n\n");
|
||||
|
||||
fprintf(script, "echo %sIf you have used ALTER TABLE to modify the statistics target for%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
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);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %srunning this script because they will delay fast statistics generation.%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo\n\n");
|
||||
|
||||
fprintf(script, "echo %sIf you would like default statistics as quickly as possible, cancel%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %sthis script and run:%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %s vacuumdb --all %s%s\n", ECHO_QUOTE,
|
||||
/* Did we copy the free space files? */
|
||||
(GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ?
|
||||
"--analyze-only" : "--analyze", ECHO_QUOTE);
|
||||
/* Did we copy the free space files? */
|
||||
(GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ?
|
||||
"--analyze-only" : "--analyze", ECHO_QUOTE);
|
||||
fprintf(script, "echo\n\n");
|
||||
|
||||
#ifndef WIN32
|
||||
@ -441,15 +442,15 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
|
||||
#endif
|
||||
|
||||
fprintf(script, "echo %sGenerating minimal optimizer statistics (1 target)%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %s--------------------------------------------------%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "vacuumdb --all --analyze-only\n");
|
||||
fprintf(script, "echo\n");
|
||||
fprintf(script, "echo %sThe server is now available with minimal optimizer statistics.%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %sQuery performance will be optimal once this script completes.%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo\n\n");
|
||||
|
||||
#ifndef WIN32
|
||||
@ -462,9 +463,9 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
|
||||
#endif
|
||||
|
||||
fprintf(script, "echo %sGenerating medium optimizer statistics (10 targets)%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %s---------------------------------------------------%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "vacuumdb --all --analyze-only\n");
|
||||
fprintf(script, "echo\n\n");
|
||||
|
||||
@ -475,17 +476,17 @@ create_script_for_cluster_analyze(char **analyze_script_file_name)
|
||||
#endif
|
||||
|
||||
fprintf(script, "echo %sGenerating default (full) optimizer statistics (100 targets?)%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "echo %s-------------------------------------------------------------%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
fprintf(script, "vacuumdb --all %s\n",
|
||||
/* Did we copy the free space files? */
|
||||
(GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ?
|
||||
"--analyze-only" : "--analyze");
|
||||
/* Did we copy the free space files? */
|
||||
(GET_MAJOR_VERSION(old_cluster.major_version) >= 804) ?
|
||||
"--analyze-only" : "--analyze");
|
||||
|
||||
fprintf(script, "echo\n\n");
|
||||
fprintf(script, "echo %sDone%s\n",
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
ECHO_QUOTE, ECHO_QUOTE);
|
||||
|
||||
fclose(script);
|
||||
|
||||
@ -716,8 +717,8 @@ check_for_isn_and_int8_passing_mismatch(ClusterInfo *cluster)
|
||||
pg_log(PG_REPORT, "fatal\n");
|
||||
pg_log(PG_FATAL,
|
||||
"Your installation contains \"contrib/isn\" functions which rely on the\n"
|
||||
"bigint data type. Your old and new clusters pass bigint values\n"
|
||||
"differently so this cluster cannot currently be upgraded. You can\n"
|
||||
"bigint data type. Your old and new clusters pass bigint values\n"
|
||||
"differently so this cluster cannot currently be upgraded. You can\n"
|
||||
"manually upgrade databases that use \"contrib/isn\" facilities and remove\n"
|
||||
"\"contrib/isn\" from the old cluster and restart the upgrade. A list of\n"
|
||||
"the problem functions is in the file:\n"
|
||||
@ -764,9 +765,9 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
|
||||
PGconn *conn = connectToServer(cluster, active_db->db_name);
|
||||
|
||||
/*
|
||||
* While several relkinds don't store any data, e.g. views, they
|
||||
* can be used to define data types of other columns, so we
|
||||
* check all relkinds.
|
||||
* While several relkinds don't store any data, e.g. views, they can
|
||||
* be used to define data types of other columns, so we check all
|
||||
* relkinds.
|
||||
*/
|
||||
res = executeQueryOrDie(conn,
|
||||
"SELECT n.nspname, c.relname, a.attname "
|
||||
@ -777,16 +778,16 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
|
||||
" NOT a.attisdropped AND "
|
||||
" a.atttypid IN ( "
|
||||
" 'pg_catalog.regproc'::pg_catalog.regtype, "
|
||||
" 'pg_catalog.regprocedure'::pg_catalog.regtype, "
|
||||
" 'pg_catalog.regprocedure'::pg_catalog.regtype, "
|
||||
" 'pg_catalog.regoper'::pg_catalog.regtype, "
|
||||
" 'pg_catalog.regoperator'::pg_catalog.regtype, "
|
||||
" 'pg_catalog.regoperator'::pg_catalog.regtype, "
|
||||
/* regclass.oid is preserved, so 'regclass' is OK */
|
||||
/* regtype.oid is preserved, so 'regtype' is OK */
|
||||
" 'pg_catalog.regconfig'::pg_catalog.regtype, "
|
||||
" 'pg_catalog.regdictionary'::pg_catalog.regtype) AND "
|
||||
" c.relnamespace = n.oid AND "
|
||||
" n.nspname != 'pg_catalog' AND "
|
||||
" n.nspname != 'information_schema'");
|
||||
" 'pg_catalog.regconfig'::pg_catalog.regtype, "
|
||||
" 'pg_catalog.regdictionary'::pg_catalog.regtype) AND "
|
||||
" c.relnamespace = n.oid AND "
|
||||
" n.nspname != 'pg_catalog' AND "
|
||||
" n.nspname != 'information_schema'");
|
||||
|
||||
ntups = PQntuples(res);
|
||||
i_nspname = PQfnumber(res, "nspname");
|
||||
@ -822,8 +823,8 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
|
||||
pg_log(PG_REPORT, "fatal\n");
|
||||
pg_log(PG_FATAL,
|
||||
"Your installation contains one of the reg* data types in user tables.\n"
|
||||
"These data types reference system OIDs that are not preserved by\n"
|
||||
"pg_upgrade, so this cluster cannot currently be upgraded. You can\n"
|
||||
"These data types reference system OIDs that are not preserved by\n"
|
||||
"pg_upgrade, so this cluster cannot currently be upgraded. You can\n"
|
||||
"remove the problem tables and restart the upgrade. A list of the problem\n"
|
||||
"columns is in the file:\n"
|
||||
" %s\n\n", output_path);
|
||||
@ -836,9 +837,11 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
|
||||
static void
|
||||
get_bin_version(ClusterInfo *cluster)
|
||||
{
|
||||
char cmd[MAXPGPATH], cmd_output[MAX_STRING];
|
||||
char cmd[MAXPGPATH],
|
||||
cmd_output[MAX_STRING];
|
||||
FILE *output;
|
||||
int pre_dot, post_dot;
|
||||
int pre_dot,
|
||||
post_dot;
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "\"%s/pg_ctl\" --version", cluster->bindir);
|
||||
|
||||
@ -858,4 +861,3 @@ get_bin_version(ClusterInfo *cluster)
|
||||
|
||||
cluster->bin_version = (pre_dot * 100 + post_dot) * 100;
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
|
||||
pg_log(PG_VERBOSE, "%s", bufin);
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
/*
|
||||
* Due to an installer bug, LANG=C doesn't work for PG 8.3.3, but does
|
||||
* work 8.2.6 and 8.3.7, so check for non-ASCII output and suggest a
|
||||
@ -506,7 +507,7 @@ check_control_data(ControlData *oldctrl,
|
||||
* This is a common 8.3 -> 8.4 upgrade problem, so we are more verbose
|
||||
*/
|
||||
pg_log(PG_FATAL,
|
||||
"You will need to rebuild the new server with configure option\n"
|
||||
"You will need to rebuild the new server with configure option\n"
|
||||
"--disable-integer-datetimes or get server binaries built with those\n"
|
||||
"options.\n");
|
||||
}
|
||||
@ -531,6 +532,6 @@ disable_old_cluster(void)
|
||||
pg_log(PG_REPORT, "\n"
|
||||
"If you want to start the old cluster, you will need to remove\n"
|
||||
"the \".old\" suffix from %s/global/pg_control.old.\n"
|
||||
"Because \"link\" mode was used, the old cluster cannot be safely\n"
|
||||
"started once the new cluster has been started.\n\n", old_cluster.pgdata);
|
||||
"Because \"link\" mode was used, the old cluster cannot be safely\n"
|
||||
"started once the new cluster has been started.\n\n", old_cluster.pgdata);
|
||||
}
|
||||
|
@ -18,8 +18,9 @@
|
||||
static void check_data_dir(const char *pg_data);
|
||||
static void check_bin_dir(ClusterInfo *cluster);
|
||||
static void validate_exec(const char *dir, const char *cmdName);
|
||||
|
||||
#ifdef WIN32
|
||||
static int win32_check_directory_write_permissions(void);
|
||||
static int win32_check_directory_write_permissions(void);
|
||||
#endif
|
||||
|
||||
|
||||
@ -64,7 +65,7 @@ exec_prog(bool throw_error, bool is_priv,
|
||||
pg_log(throw_error ? PG_FATAL : PG_REPORT,
|
||||
"Consult the last few lines of \"%s\" for\n"
|
||||
"the probable cause of the failure.\n",
|
||||
log_file);
|
||||
log_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -142,12 +143,12 @@ verify_directories(void)
|
||||
static int
|
||||
win32_check_directory_write_permissions(void)
|
||||
{
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
/*
|
||||
* We open a file we would normally create anyway. We do this even in
|
||||
* 'check' mode, which isn't ideal, but this is the best we can do.
|
||||
*/
|
||||
* We open a file we would normally create anyway. We do this even in
|
||||
* 'check' mode, which isn't ideal, but this is the best we can do.
|
||||
*/
|
||||
if ((fd = open(GLOBALS_DUMP_FILE, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) < 0)
|
||||
return -1;
|
||||
close(fd);
|
||||
@ -184,7 +185,7 @@ check_data_dir(const char *pg_data)
|
||||
struct stat statBuf;
|
||||
|
||||
snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data,
|
||||
/* Win32 can't stat() a directory with a trailing slash. */
|
||||
/* Win32 can't stat() a directory with a trailing slash. */
|
||||
*requiredSubdirs[subdirnum] ? "/" : "",
|
||||
requiredSubdirs[subdirnum]);
|
||||
|
||||
|
@ -233,7 +233,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
|
||||
* large number of times.
|
||||
*/
|
||||
int
|
||||
load_directory(const char *dirname, struct dirent ***namelist)
|
||||
load_directory(const char *dirname, struct dirent *** namelist)
|
||||
{
|
||||
DIR *dirdesc;
|
||||
struct dirent *direntry;
|
||||
@ -251,7 +251,7 @@ load_directory(const char *dirname, struct dirent ***namelist)
|
||||
count++;
|
||||
|
||||
*namelist = (struct dirent **) realloc((void *) (*namelist),
|
||||
(size_t) ((name_num + 1) * sizeof(struct dirent *)));
|
||||
(size_t) ((name_num + 1) * sizeof(struct dirent *)));
|
||||
|
||||
if (*namelist == NULL)
|
||||
{
|
||||
@ -314,7 +314,6 @@ win32_pghardlink(const char *src, const char *dst)
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -322,13 +321,11 @@ win32_pghardlink(const char *src, const char *dst)
|
||||
FILE *
|
||||
fopen_priv(const char *path, const char *mode)
|
||||
{
|
||||
mode_t old_umask = umask(S_IRWXG | S_IRWXO);
|
||||
FILE *fp;
|
||||
mode_t old_umask = umask(S_IRWXG | S_IRWXO);
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen(path, mode);
|
||||
umask(old_umask);
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
||||
|
||||
|
@ -133,7 +133,7 @@ get_loadable_libraries(void)
|
||||
int totaltups;
|
||||
int dbnum;
|
||||
bool found_public_plpython_handler = false;
|
||||
|
||||
|
||||
ress = (PGresult **) pg_malloc(old_cluster.dbarr.ndbs * sizeof(PGresult *));
|
||||
totaltups = 0;
|
||||
|
||||
@ -144,10 +144,10 @@ get_loadable_libraries(void)
|
||||
PGconn *conn = connectToServer(&old_cluster, active_db->db_name);
|
||||
|
||||
/*
|
||||
* Fetch all libraries referenced in this DB. We can't exclude
|
||||
* the "pg_catalog" schema because, while such functions are not
|
||||
* explicitly dumped by pg_dump, they do reference implicit objects
|
||||
* that pg_dump does dump, e.g. CREATE LANGUAGE plperl.
|
||||
* Fetch all libraries referenced in this DB. We can't exclude the
|
||||
* "pg_catalog" schema because, while such functions are not
|
||||
* explicitly dumped by pg_dump, they do reference implicit objects
|
||||
* that pg_dump does dump, e.g. CREATE LANGUAGE plperl.
|
||||
*/
|
||||
ress[dbnum] = executeQueryOrDie(conn,
|
||||
"SELECT DISTINCT probin "
|
||||
@ -158,26 +158,26 @@ get_loadable_libraries(void)
|
||||
FirstNormalObjectId);
|
||||
totaltups += PQntuples(ress[dbnum]);
|
||||
|
||||
/*
|
||||
* Systems that install plpython before 8.1 have
|
||||
* plpython_call_handler() defined in the "public" schema, causing
|
||||
* pg_dumpall to dump it. However that function still references
|
||||
* "plpython" (no "2"), so it throws an error on restore. This code
|
||||
* checks for the problem function, reports affected databases to the
|
||||
* user and explains how to remove them.
|
||||
* 8.1 git commit: e0dedd0559f005d60c69c9772163e69c204bac69
|
||||
* http://archives.postgresql.org/pgsql-hackers/2012-03/msg01101.php
|
||||
* http://archives.postgresql.org/pgsql-bugs/2012-05/msg00206.php
|
||||
*/
|
||||
/*
|
||||
* Systems that install plpython before 8.1 have
|
||||
* plpython_call_handler() defined in the "public" schema, causing
|
||||
* pg_dumpall to dump it. However that function still references
|
||||
* "plpython" (no "2"), so it throws an error on restore. This code
|
||||
* checks for the problem function, reports affected databases to the
|
||||
* user and explains how to remove them. 8.1 git commit:
|
||||
* e0dedd0559f005d60c69c9772163e69c204bac69
|
||||
* http://archives.postgresql.org/pgsql-hackers/2012-03/msg01101.php
|
||||
* http://archives.postgresql.org/pgsql-bugs/2012-05/msg00206.php
|
||||
*/
|
||||
if (GET_MAJOR_VERSION(old_cluster.major_version) < 901)
|
||||
{
|
||||
PGresult *res;
|
||||
PGresult *res;
|
||||
|
||||
res = executeQueryOrDie(conn,
|
||||
"SELECT 1 "
|
||||
"FROM pg_catalog.pg_proc JOIN pg_namespace "
|
||||
" ON pronamespace = pg_namespace.oid "
|
||||
"WHERE proname = 'plpython_call_handler' AND "
|
||||
"FROM pg_catalog.pg_proc JOIN pg_namespace "
|
||||
" ON pronamespace = pg_namespace.oid "
|
||||
"WHERE proname = 'plpython_call_handler' AND "
|
||||
"nspname = 'public' AND "
|
||||
"prolang = 13 /* C */ AND "
|
||||
"probin = '$libdir/plpython' AND "
|
||||
@ -188,23 +188,23 @@ get_loadable_libraries(void)
|
||||
if (!found_public_plpython_handler)
|
||||
{
|
||||
pg_log(PG_WARNING,
|
||||
"\nThe old cluster has a \"plpython_call_handler\" function defined\n"
|
||||
"in the \"public\" schema which is a duplicate of the one defined\n"
|
||||
"in the \"pg_catalog\" schema. You can confirm this by executing\n"
|
||||
"in psql:\n"
|
||||
"\n"
|
||||
" \\df *.plpython_call_handler\n"
|
||||
"\n"
|
||||
"The \"public\" schema version of this function was created by a\n"
|
||||
"pre-8.1 install of plpython, and must be removed for pg_upgrade\n"
|
||||
"to complete because it references a now-obsolete \"plpython\"\n"
|
||||
"shared object file. You can remove the \"public\" schema version\n"
|
||||
"of this function by running the following command:\n"
|
||||
"\n"
|
||||
" DROP FUNCTION public.plpython_call_handler()\n"
|
||||
"\n"
|
||||
"in each affected database:\n"
|
||||
"\n");
|
||||
"\nThe old cluster has a \"plpython_call_handler\" function defined\n"
|
||||
"in the \"public\" schema which is a duplicate of the one defined\n"
|
||||
"in the \"pg_catalog\" schema. You can confirm this by executing\n"
|
||||
"in psql:\n"
|
||||
"\n"
|
||||
" \\df *.plpython_call_handler\n"
|
||||
"\n"
|
||||
"The \"public\" schema version of this function was created by a\n"
|
||||
"pre-8.1 install of plpython, and must be removed for pg_upgrade\n"
|
||||
"to complete because it references a now-obsolete \"plpython\"\n"
|
||||
"shared object file. You can remove the \"public\" schema version\n"
|
||||
"of this function by running the following command:\n"
|
||||
"\n"
|
||||
" DROP FUNCTION public.plpython_call_handler()\n"
|
||||
"\n"
|
||||
"in each affected database:\n"
|
||||
"\n");
|
||||
}
|
||||
pg_log(PG_WARNING, " %s\n", active_db->db_name);
|
||||
found_public_plpython_handler = true;
|
||||
@ -217,9 +217,9 @@ get_loadable_libraries(void)
|
||||
|
||||
if (found_public_plpython_handler)
|
||||
pg_log(PG_FATAL,
|
||||
"Remove the problem functions from the old cluster to continue.\n");
|
||||
|
||||
totaltups++; /* reserve for pg_upgrade_support */
|
||||
"Remove the problem functions from the old cluster to continue.\n");
|
||||
|
||||
totaltups++; /* reserve for pg_upgrade_support */
|
||||
|
||||
/* Allocate what's certainly enough space */
|
||||
os_info.libraries = (char **) pg_malloc(totaltups * sizeof(char *));
|
||||
@ -293,17 +293,17 @@ check_loadable_libraries(void)
|
||||
PGresult *res;
|
||||
|
||||
/*
|
||||
* In Postgres 9.0, Python 3 support was added, and to do that, a
|
||||
* plpython2u language was created with library name plpython2.so
|
||||
* as a symbolic link to plpython.so. In Postgres 9.1, only the
|
||||
* plpython2.so library was created, and both plpythonu and
|
||||
* plpython2u pointing to it. For this reason, any reference to
|
||||
* library name "plpython" in an old PG <= 9.1 cluster must look
|
||||
* for "plpython2" in the new cluster.
|
||||
* In Postgres 9.0, Python 3 support was added, and to do that, a
|
||||
* plpython2u language was created with library name plpython2.so as a
|
||||
* symbolic link to plpython.so. In Postgres 9.1, only the
|
||||
* plpython2.so library was created, and both plpythonu and plpython2u
|
||||
* pointing to it. For this reason, any reference to library name
|
||||
* "plpython" in an old PG <= 9.1 cluster must look for "plpython2" in
|
||||
* the new cluster.
|
||||
*
|
||||
* For this case, we could check pg_pltemplate, but that only works
|
||||
* for languages, and does not help with function shared objects,
|
||||
* so we just do a general fix.
|
||||
* For this case, we could check pg_pltemplate, but that only works
|
||||
* for languages, and does not help with function shared objects, so
|
||||
* we just do a general fix.
|
||||
*/
|
||||
if (GET_MAJOR_VERSION(old_cluster.major_version) < 901 &&
|
||||
strcmp(lib, "$libdir/plpython") == 0)
|
||||
@ -325,7 +325,7 @@ check_loadable_libraries(void)
|
||||
/* exit and report missing support library with special message */
|
||||
if (strcmp(lib, PG_UPGRADE_SUPPORT) == 0)
|
||||
pg_log(PG_FATAL,
|
||||
"The pg_upgrade_support module must be created and installed in the new cluster.\n");
|
||||
"The pg_upgrade_support module must be created and installed in the new cluster.\n");
|
||||
|
||||
if (script == NULL && (script = fopen_priv(output_path, "w")) == NULL)
|
||||
pg_log(PG_FATAL, "Could not open file \"%s\": %s\n",
|
||||
|
@ -57,12 +57,12 @@ gen_db_file_maps(DbInfo *old_db, DbInfo *new_db,
|
||||
old_db->db_name, old_rel->reloid, new_rel->reloid);
|
||||
|
||||
/*
|
||||
* TOAST table names initially match the heap pg_class oid.
|
||||
* In pre-8.4, TOAST table names change during CLUSTER; in pre-9.0,
|
||||
* TOAST table names change during ALTER TABLE ALTER COLUMN SET TYPE.
|
||||
* In >= 9.0, TOAST relation names always use heap table oids, hence
|
||||
* we cannot check relation names when upgrading from pre-9.0.
|
||||
* Clusters upgraded to 9.0 will get matching TOAST names.
|
||||
* TOAST table names initially match the heap pg_class oid. In
|
||||
* pre-8.4, TOAST table names change during CLUSTER; in pre-9.0, TOAST
|
||||
* table names change during ALTER TABLE ALTER COLUMN SET TYPE. In >=
|
||||
* 9.0, TOAST relation names always use heap table oids, hence we
|
||||
* cannot check relation names when upgrading from pre-9.0. Clusters
|
||||
* upgraded to 9.0 will get matching TOAST names.
|
||||
*/
|
||||
if (strcmp(old_rel->nspname, new_rel->nspname) != 0 ||
|
||||
((GET_MAJOR_VERSION(old_cluster.major_version) >= 900 ||
|
||||
@ -194,16 +194,16 @@ get_db_infos(ClusterInfo *cluster)
|
||||
char query[QUERY_ALLOC];
|
||||
|
||||
snprintf(query, sizeof(query),
|
||||
"SELECT d.oid, d.datname, %s "
|
||||
"FROM pg_catalog.pg_database d "
|
||||
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
|
||||
" ON d.dattablespace = t.oid "
|
||||
"WHERE d.datallowconn = true "
|
||||
"SELECT d.oid, d.datname, %s "
|
||||
"FROM pg_catalog.pg_database d "
|
||||
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
|
||||
" ON d.dattablespace = t.oid "
|
||||
"WHERE d.datallowconn = true "
|
||||
/* we don't preserve pg_database.oid so we sort by name */
|
||||
"ORDER BY 2",
|
||||
"ORDER BY 2",
|
||||
/* 9.2 removed the spclocation column */
|
||||
(GET_MAJOR_VERSION(cluster->major_version) <= 901) ?
|
||||
"t.spclocation" : "pg_catalog.pg_tablespace_location(t.oid) AS spclocation");
|
||||
(GET_MAJOR_VERSION(cluster->major_version) <= 901) ?
|
||||
"t.spclocation" : "pg_catalog.pg_tablespace_location(t.oid) AS spclocation");
|
||||
|
||||
res = executeQueryOrDie(conn, "%s", query);
|
||||
|
||||
@ -276,7 +276,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
|
||||
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
|
||||
" ON c.reltablespace = t.oid "
|
||||
"WHERE relkind IN ('r','t', 'i'%s) AND "
|
||||
/* exclude possible orphaned temp tables */
|
||||
/* exclude possible orphaned temp tables */
|
||||
" ((n.nspname !~ '^pg_temp_' AND "
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema', 'binary_upgrade') AND "
|
||||
|
@ -56,10 +56,10 @@ parseCommandLine(int argc, char *argv[])
|
||||
int option; /* Command line option */
|
||||
int optindex = 0; /* used by getopt_long */
|
||||
int os_user_effective_id;
|
||||
FILE *fp;
|
||||
char **filename;
|
||||
FILE *fp;
|
||||
char **filename;
|
||||
time_t run_time = time(NULL);
|
||||
|
||||
|
||||
user_opts.transfer_mode = TRANSFER_MODE_COPY;
|
||||
|
||||
os_info.progname = get_progname(argv[0]);
|
||||
@ -138,11 +138,11 @@ parseCommandLine(int argc, char *argv[])
|
||||
new_cluster.pgopts = pg_strdup(optarg);
|
||||
break;
|
||||
|
||||
/*
|
||||
* Someday, the port number option could be removed and
|
||||
* passed using -o/-O, but that requires postmaster -C
|
||||
* to be supported on all old/new versions.
|
||||
*/
|
||||
/*
|
||||
* Someday, the port number option could be removed and passed
|
||||
* using -o/-O, but that requires postmaster -C to be
|
||||
* supported on all old/new versions.
|
||||
*/
|
||||
case 'p':
|
||||
if ((old_cluster.port = atoi(optarg)) <= 0)
|
||||
{
|
||||
@ -196,21 +196,21 @@ parseCommandLine(int argc, char *argv[])
|
||||
/* Start with newline because we might be appending to a file. */
|
||||
fprintf(fp, "\n"
|
||||
"-----------------------------------------------------------------\n"
|
||||
" pg_upgrade run on %s"
|
||||
"-----------------------------------------------------------------\n\n",
|
||||
ctime(&run_time));
|
||||
" pg_upgrade run on %s"
|
||||
"-----------------------------------------------------------------\n\n",
|
||||
ctime(&run_time));
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
/* Get values from env if not already set */
|
||||
check_required_directory(&old_cluster.bindir, "PGBINOLD", "-b",
|
||||
"old cluster binaries reside");
|
||||
"old cluster binaries reside");
|
||||
check_required_directory(&new_cluster.bindir, "PGBINNEW", "-B",
|
||||
"new cluster binaries reside");
|
||||
"new cluster binaries reside");
|
||||
check_required_directory(&old_cluster.pgdata, "PGDATAOLD", "-d",
|
||||
"old cluster data resides");
|
||||
"old cluster data resides");
|
||||
check_required_directory(&new_cluster.pgdata, "PGDATANEW", "-D",
|
||||
"new cluster data resides");
|
||||
"new cluster data resides");
|
||||
}
|
||||
|
||||
|
||||
@ -285,7 +285,7 @@ or\n"), old_cluster.port, new_cluster.port, os_info.user);
|
||||
*/
|
||||
static void
|
||||
check_required_directory(char **dirpath, char *envVarName,
|
||||
char *cmdLineOption, char *description)
|
||||
char *cmdLineOption, char *description)
|
||||
{
|
||||
if (*dirpath == NULL || strlen(*dirpath) == 0)
|
||||
{
|
||||
@ -322,8 +322,10 @@ void
|
||||
adjust_data_dir(ClusterInfo *cluster)
|
||||
{
|
||||
char filename[MAXPGPATH];
|
||||
char cmd[MAXPGPATH], cmd_output[MAX_STRING];
|
||||
FILE *fp, *output;
|
||||
char cmd[MAXPGPATH],
|
||||
cmd_output[MAX_STRING];
|
||||
FILE *fp,
|
||||
*output;
|
||||
|
||||
/* If there is no postgresql.conf, it can't be a config-only dir */
|
||||
snprintf(filename, sizeof(filename), "%s/postgresql.conf", cluster->pgconfig);
|
||||
@ -345,10 +347,9 @@ adjust_data_dir(ClusterInfo *cluster)
|
||||
CLUSTER_NAME(cluster));
|
||||
|
||||
/*
|
||||
* We don't have a data directory yet, so we can't check the PG
|
||||
* version, so this might fail --- only works for PG 9.2+. If this
|
||||
* fails, pg_upgrade will fail anyway because the data files will not
|
||||
* be found.
|
||||
* We don't have a data directory yet, so we can't check the PG version,
|
||||
* so this might fail --- only works for PG 9.2+. If this fails,
|
||||
* pg_upgrade will fail anyway because the data files will not be found.
|
||||
*/
|
||||
snprintf(cmd, sizeof(cmd), "\"%s/postmaster\" -D \"%s\" -C data_directory",
|
||||
cluster->bindir, cluster->pgconfig);
|
||||
@ -356,7 +357,7 @@ adjust_data_dir(ClusterInfo *cluster)
|
||||
if ((output = popen(cmd, "r")) == NULL ||
|
||||
fgets(cmd_output, sizeof(cmd_output), output) == NULL)
|
||||
pg_log(PG_FATAL, "Could not get data directory using %s: %s\n",
|
||||
cmd, getErrorText(errno));
|
||||
cmd, getErrorText(errno));
|
||||
|
||||
pclose(output);
|
||||
|
||||
|
@ -55,7 +55,7 @@ ClusterInfo old_cluster,
|
||||
new_cluster;
|
||||
OSInfo os_info;
|
||||
|
||||
char *output_files[] = {
|
||||
char *output_files[] = {
|
||||
SERVER_LOG_FILE,
|
||||
#ifdef WIN32
|
||||
/* unique file for pg_ctl start */
|
||||
@ -122,11 +122,10 @@ main(int argc, char **argv)
|
||||
stop_postmaster(false);
|
||||
|
||||
/*
|
||||
* Most failures happen in create_new_objects(), which has
|
||||
* completed at this point. We do this here because it is just
|
||||
* before linking, which will link the old and new cluster data
|
||||
* files, preventing the old cluster from being safely started
|
||||
* once the new cluster is started.
|
||||
* Most failures happen in create_new_objects(), which has completed at
|
||||
* this point. We do this here because it is just before linking, which
|
||||
* will link the old and new cluster data files, preventing the old
|
||||
* cluster from being safely started once the new cluster is started.
|
||||
*/
|
||||
if (user_opts.transfer_mode == TRANSFER_MODE_LINK)
|
||||
disable_old_cluster();
|
||||
@ -215,8 +214,8 @@ prepare_new_cluster(void)
|
||||
exec_prog(true, true, UTILITY_LOG_FILE,
|
||||
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
|
||||
"--all --analyze %s >> \"%s\" 2>&1" SYSTEMQUOTE,
|
||||
new_cluster.bindir, new_cluster.port, os_info.user,
|
||||
log_opts.verbose ? "--verbose" : "", UTILITY_LOG_FILE);
|
||||
new_cluster.bindir, new_cluster.port, os_info.user,
|
||||
log_opts.verbose ? "--verbose" : "", UTILITY_LOG_FILE);
|
||||
check_ok();
|
||||
|
||||
/*
|
||||
@ -229,8 +228,8 @@ prepare_new_cluster(void)
|
||||
exec_prog(true, true, UTILITY_LOG_FILE,
|
||||
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
|
||||
"--all --freeze %s >> \"%s\" 2>&1" SYSTEMQUOTE,
|
||||
new_cluster.bindir, new_cluster.port, os_info.user,
|
||||
log_opts.verbose ? "--verbose" : "", UTILITY_LOG_FILE);
|
||||
new_cluster.bindir, new_cluster.port, os_info.user,
|
||||
log_opts.verbose ? "--verbose" : "", UTILITY_LOG_FILE);
|
||||
check_ok();
|
||||
|
||||
get_pg_database_relfilenode(&new_cluster);
|
||||
@ -252,8 +251,8 @@ prepare_new_databases(void)
|
||||
|
||||
/*
|
||||
* Install support functions in the global-object restore database to
|
||||
* preserve pg_authid.oid. pg_dumpall uses 'template0' as its template
|
||||
* database so objects we add into 'template1' are not propogated. They
|
||||
* preserve pg_authid.oid. pg_dumpall uses 'template0' as its template
|
||||
* database so objects we add into 'template1' are not propogated. They
|
||||
* are removed on pg_upgrade exit.
|
||||
*/
|
||||
install_support_functions_in_new_db("template1");
|
||||
@ -267,7 +266,7 @@ prepare_new_databases(void)
|
||||
exec_prog(true, true, RESTORE_LOG_FILE,
|
||||
SYSTEMQUOTE "\"%s/psql\" --echo-queries "
|
||||
"--set ON_ERROR_STOP=on "
|
||||
/* --no-psqlrc prevents AUTOCOMMIT=off */
|
||||
/* --no-psqlrc prevents AUTOCOMMIT=off */
|
||||
"--no-psqlrc --port %d --username \"%s\" "
|
||||
"-f \"%s\" --dbname template1 >> \"%s\" 2>&1" SYSTEMQUOTE,
|
||||
new_cluster.bindir, new_cluster.port, os_info.user,
|
||||
@ -453,13 +452,13 @@ set_frozenxids(void)
|
||||
static void
|
||||
cleanup(void)
|
||||
{
|
||||
|
||||
|
||||
fclose(log_opts.internal);
|
||||
|
||||
/* Remove dump and log files? */
|
||||
if (!log_opts.retain)
|
||||
{
|
||||
char **filename;
|
||||
char **filename;
|
||||
|
||||
for (filename = output_files; *filename != NULL; filename++)
|
||||
unlink(*filename);
|
||||
|
@ -75,7 +75,7 @@ extern char *output_files[];
|
||||
#define RM_CMD "rm -f"
|
||||
#define RMDIR_CMD "rm -rf"
|
||||
#define SCRIPT_EXT "sh"
|
||||
#define ECHO_QUOTE "'"
|
||||
#define ECHO_QUOTE "'"
|
||||
#else
|
||||
#define pg_copy_file CopyFile
|
||||
#define pg_mv_file pgrename
|
||||
@ -85,7 +85,7 @@ extern char *output_files[];
|
||||
#define RMDIR_CMD "RMDIR /s/q"
|
||||
#define SCRIPT_EXT "bat"
|
||||
#define EXE_EXT ".exe"
|
||||
#define ECHO_QUOTE ""
|
||||
#define ECHO_QUOTE ""
|
||||
#endif
|
||||
|
||||
#define CLUSTER_NAME(cluster) ((cluster) == &old_cluster ? "old" : \
|
||||
@ -98,7 +98,7 @@ extern char *output_files[];
|
||||
/* postmaster/postgres -b (binary_upgrade) flag added during PG 9.1 development */
|
||||
#define BINARY_UPGRADE_SERVER_FLAG_CAT_VER 201104251
|
||||
/*
|
||||
* Visibility map changed with this 9.2 commit,
|
||||
* Visibility map changed with this 9.2 commit,
|
||||
* 8f9fe6edce358f7904e0db119416b4d1080a83aa; pick later catalog version.
|
||||
*/
|
||||
#define VISIBILITY_MAP_CRASHSAFE_CAT_VER 201107031
|
||||
@ -114,7 +114,7 @@ typedef struct
|
||||
Oid reloid; /* relation oid */
|
||||
Oid relfilenode; /* relation relfile node */
|
||||
/* relation tablespace path, or "" for the cluster default */
|
||||
char tablespace[MAXPGPATH];
|
||||
char tablespace[MAXPGPATH];
|
||||
} RelInfo;
|
||||
|
||||
typedef struct
|
||||
@ -222,9 +222,11 @@ typedef struct
|
||||
ControlData controldata; /* pg_control information */
|
||||
DbInfoArr dbarr; /* dbinfos array */
|
||||
char *pgdata; /* pathname for cluster's $PGDATA directory */
|
||||
char *pgconfig; /* pathname for cluster's config file directory */
|
||||
char *pgconfig; /* pathname for cluster's config file
|
||||
* directory */
|
||||
char *bindir; /* pathname for cluster's executable directory */
|
||||
char *pgopts; /* options to pass to the server, like pg_ctl -o */
|
||||
char *pgopts; /* options to pass to the server, like pg_ctl
|
||||
* -o */
|
||||
unsigned short port; /* port number where postmaster is waiting */
|
||||
uint32 major_version; /* PG_VERSION of cluster */
|
||||
char major_version_str[64]; /* string PG_VERSION of cluster */
|
||||
@ -291,8 +293,8 @@ void check_old_cluster(bool live_check,
|
||||
void check_new_cluster(void);
|
||||
void report_clusters_compatible(void);
|
||||
void issue_warnings(char *sequence_script_file_name);
|
||||
void output_completion_banner(char *analyze_script_file_name,
|
||||
char *deletion_script_file_name);
|
||||
void output_completion_banner(char *analyze_script_file_name,
|
||||
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);
|
||||
@ -314,9 +316,10 @@ void split_old_dump(void);
|
||||
|
||||
/* exec.c */
|
||||
|
||||
int exec_prog(bool throw_error, bool is_priv,
|
||||
const char *log_file, const char *cmd, ...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 4, 5)));
|
||||
int
|
||||
exec_prog(bool throw_error, bool is_priv,
|
||||
const char *log_file, const char *cmd,...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 4, 5)));
|
||||
void verify_directories(void);
|
||||
bool is_server_running(const char *datadir);
|
||||
|
||||
@ -353,14 +356,14 @@ const char *setupPageConverter(pageCnvCtx **result);
|
||||
typedef void *pageCnvCtx;
|
||||
#endif
|
||||
|
||||
int load_directory(const char *dirname, struct dirent ***namelist);
|
||||
int load_directory(const char *dirname, struct dirent *** namelist);
|
||||
const char *copyAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
|
||||
const char *dst, bool force);
|
||||
const char *linkAndUpdateFile(pageCnvCtx *pageConverter, const char *src,
|
||||
const char *dst);
|
||||
|
||||
void check_hard_link(void);
|
||||
FILE *fopen_priv(const char *path, const char *mode);
|
||||
FILE *fopen_priv(const char *path, const char *mode);
|
||||
|
||||
/* function.c */
|
||||
|
||||
@ -399,8 +402,9 @@ void init_tablespaces(void);
|
||||
/* server.c */
|
||||
|
||||
PGconn *connectToServer(ClusterInfo *cluster, const char *db_name);
|
||||
PGresult *executeQueryOrDie(PGconn *conn, const char *fmt, ...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
PGresult *
|
||||
executeQueryOrDie(PGconn *conn, const char *fmt,...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
|
||||
void start_postmaster(ClusterInfo *cluster);
|
||||
void stop_postmaster(bool fast);
|
||||
@ -413,12 +417,15 @@ void check_pghost_envvar(void);
|
||||
char *quote_identifier(const char *s);
|
||||
int get_user_info(char **user_name);
|
||||
void check_ok(void);
|
||||
void report_status(eLogType type, const char *fmt, ...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
void pg_log(eLogType type, char *fmt, ...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
void prep_status(const char *fmt, ...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
void
|
||||
report_status(eLogType type, const char *fmt,...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
void
|
||||
pg_log(eLogType type, char *fmt,...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
||||
void
|
||||
prep_status(const char *fmt,...)
|
||||
__attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
|
||||
void check_ok(void);
|
||||
char *pg_strdup(const char *s);
|
||||
void *pg_malloc(int size);
|
||||
|
@ -34,26 +34,28 @@ const char *
|
||||
transfer_all_new_dbs(DbInfoArr *old_db_arr,
|
||||
DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata)
|
||||
{
|
||||
int old_dbnum, new_dbnum;
|
||||
int old_dbnum,
|
||||
new_dbnum;
|
||||
const char *msg = NULL;
|
||||
|
||||
prep_status("%s user relation files\n",
|
||||
user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
|
||||
user_opts.transfer_mode == TRANSFER_MODE_LINK ? "Linking" : "Copying");
|
||||
|
||||
/* Scan the old cluster databases and transfer their files */
|
||||
for (old_dbnum = new_dbnum = 0;
|
||||
old_dbnum < old_db_arr->ndbs;
|
||||
old_dbnum++, new_dbnum++)
|
||||
{
|
||||
DbInfo *old_db = &old_db_arr->dbs[old_dbnum], *new_db = NULL;
|
||||
DbInfo *old_db = &old_db_arr->dbs[old_dbnum],
|
||||
*new_db = NULL;
|
||||
FileNameMap *mappings;
|
||||
int n_maps;
|
||||
pageCnvCtx *pageConverter = NULL;
|
||||
|
||||
/*
|
||||
* Advance past any databases that exist in the new cluster
|
||||
* but not in the old, e.g. "postgres". (The user might
|
||||
* have removed the 'postgres' database from the old cluster.)
|
||||
* Advance past any databases that exist in the new cluster but not in
|
||||
* the old, e.g. "postgres". (The user might have removed the
|
||||
* 'postgres' database from the old cluster.)
|
||||
*/
|
||||
for (; new_dbnum < new_db_arr->ndbs; new_dbnum++)
|
||||
{
|
||||
@ -83,8 +85,8 @@ transfer_all_new_dbs(DbInfoArr *old_db_arr,
|
||||
}
|
||||
}
|
||||
|
||||
prep_status(" "); /* in case nothing printed; pass a space so gcc
|
||||
* doesn't complain about empty format
|
||||
prep_status(" "); /* in case nothing printed; pass a space so
|
||||
* gcc doesn't complain about empty format
|
||||
* string */
|
||||
check_ok();
|
||||
|
||||
@ -137,14 +139,14 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
|
||||
int mapnum;
|
||||
int fileno;
|
||||
bool vm_crashsafe_change = false;
|
||||
|
||||
|
||||
old_dir[0] = '\0';
|
||||
|
||||
/* Do not copy non-crashsafe vm files for binaries that assume crashsafety */
|
||||
if (old_cluster.controldata.cat_ver < VISIBILITY_MAP_CRASHSAFE_CAT_VER &&
|
||||
new_cluster.controldata.cat_ver >= VISIBILITY_MAP_CRASHSAFE_CAT_VER)
|
||||
vm_crashsafe_change = true;
|
||||
|
||||
|
||||
for (mapnum = 0; mapnum < size; mapnum++)
|
||||
{
|
||||
char old_file[MAXPGPATH];
|
||||
@ -190,8 +192,8 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
|
||||
|
||||
for (fileno = 0; fileno < numFiles; fileno++)
|
||||
{
|
||||
char *vm_offset = strstr(namelist[fileno]->d_name, "_vm");
|
||||
bool is_vm_file = false;
|
||||
char *vm_offset = strstr(namelist[fileno]->d_name, "_vm");
|
||||
bool is_vm_file = false;
|
||||
|
||||
/* Is a visibility map file? (name ends with _vm) */
|
||||
if (vm_offset && strlen(vm_offset) == strlen("_vm"))
|
||||
|
@ -161,7 +161,7 @@ start_postmaster(ClusterInfo *cluster)
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
SYSTEMQUOTE "\"%s/pg_ctl\" -w -l \"%s\" -D \"%s\" "
|
||||
"-o \"-p %d %s %s\" start >> \"%s\" 2>&1" SYSTEMQUOTE,
|
||||
cluster->bindir, SERVER_LOG_FILE, cluster->pgconfig, cluster->port,
|
||||
cluster->bindir, SERVER_LOG_FILE, cluster->pgconfig, cluster->port,
|
||||
(cluster->controldata.cat_ver >=
|
||||
BINARY_UPGRADE_SERVER_FLAG_CAT_VER) ? "-b" :
|
||||
"-c autovacuum=off -c autovacuum_freeze_max_age=2000000000",
|
||||
@ -172,11 +172,11 @@ start_postmaster(ClusterInfo *cluster)
|
||||
* it might supply a reason for the failure.
|
||||
*/
|
||||
pg_ctl_return = exec_prog(false, true,
|
||||
/* pass both file names if the differ */
|
||||
(strcmp(SERVER_LOG_FILE, SERVER_START_LOG_FILE) == 0) ?
|
||||
SERVER_LOG_FILE :
|
||||
SERVER_LOG_FILE " or " SERVER_START_LOG_FILE,
|
||||
"%s", cmd);
|
||||
/* pass both file names if the differ */
|
||||
(strcmp(SERVER_LOG_FILE, SERVER_START_LOG_FILE) == 0) ?
|
||||
SERVER_LOG_FILE :
|
||||
SERVER_LOG_FILE " or " SERVER_START_LOG_FILE,
|
||||
"%s", cmd);
|
||||
|
||||
/* Check to see if we can connect to the server; if not, report it. */
|
||||
if ((conn = get_db_conn(cluster, "template1")) == NULL ||
|
||||
@ -211,14 +211,14 @@ stop_postmaster(bool fast)
|
||||
else if (os_info.running_cluster == &new_cluster)
|
||||
cluster = &new_cluster;
|
||||
else
|
||||
return; /* no cluster running */
|
||||
return; /* no cluster running */
|
||||
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
SYSTEMQUOTE "\"%s/pg_ctl\" -w -D \"%s\" -o \"%s\" "
|
||||
"%s stop >> \"%s\" 2>&1" SYSTEMQUOTE,
|
||||
cluster->bindir, cluster->pgconfig,
|
||||
cluster->pgopts ? cluster->pgopts : "",
|
||||
fast ? "-m fast" : "", SERVER_STOP_LOG_FILE);
|
||||
fast ? "-m fast" : "", SERVER_STOP_LOG_FILE);
|
||||
|
||||
exec_prog(fast ? false : true, true, SERVER_STOP_LOG_FILE, "%s", cmd);
|
||||
|
||||
|
@ -52,8 +52,8 @@ get_tablespace_paths(void)
|
||||
"WHERE spcname != 'pg_default' AND "
|
||||
" spcname != 'pg_global'",
|
||||
/* 9.2 removed the spclocation column */
|
||||
(GET_MAJOR_VERSION(old_cluster.major_version) <= 901) ?
|
||||
"spclocation" : "pg_catalog.pg_tablespace_location(oid) AS spclocation");
|
||||
(GET_MAJOR_VERSION(old_cluster.major_version) <= 901) ?
|
||||
"spclocation" : "pg_catalog.pg_tablespace_location(oid) AS spclocation");
|
||||
|
||||
res = executeQueryOrDie(conn, "%s", query);
|
||||
|
||||
|
@ -60,10 +60,10 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
|
||||
" NOT a.attisdropped AND "
|
||||
" a.atttypid = 'pg_catalog.name'::pg_catalog.regtype AND "
|
||||
" c.relnamespace = n.oid AND "
|
||||
/* exclude possible orphaned temp tables */
|
||||
/* exclude possible orphaned temp tables */
|
||||
" n.nspname !~ '^pg_temp_' AND "
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
|
||||
|
||||
ntups = PQntuples(res);
|
||||
i_nspname = PQfnumber(res, "nspname");
|
||||
@ -98,9 +98,9 @@ old_8_3_check_for_name_data_type_usage(ClusterInfo *cluster)
|
||||
pg_log(PG_REPORT, "fatal\n");
|
||||
pg_log(PG_FATAL,
|
||||
"Your installation contains the \"name\" data type in user tables. This\n"
|
||||
"data type changed its internal alignment between your old and new\n"
|
||||
"data type changed its internal alignment between your old and new\n"
|
||||
"clusters so this cluster cannot currently be upgraded. You can remove\n"
|
||||
"the problem tables and restart the upgrade. A list of the problem\n"
|
||||
"the problem tables and restart the upgrade. A list of the problem\n"
|
||||
"columns is in the file:\n"
|
||||
" %s\n\n", output_path);
|
||||
}
|
||||
@ -150,10 +150,10 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
|
||||
" NOT a.attisdropped AND "
|
||||
" a.atttypid = 'pg_catalog.tsquery'::pg_catalog.regtype AND "
|
||||
" c.relnamespace = n.oid AND "
|
||||
/* exclude possible orphaned temp tables */
|
||||
/* exclude possible orphaned temp tables */
|
||||
" n.nspname !~ '^pg_temp_' AND "
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
|
||||
|
||||
ntups = PQntuples(res);
|
||||
i_nspname = PQfnumber(res, "nspname");
|
||||
@ -189,7 +189,7 @@ old_8_3_check_for_tsquery_usage(ClusterInfo *cluster)
|
||||
pg_log(PG_FATAL,
|
||||
"Your installation contains the \"tsquery\" data type. This data type\n"
|
||||
"added a new internal field between your old and new clusters so this\n"
|
||||
"cluster cannot currently be upgraded. You can remove the problem\n"
|
||||
"cluster cannot currently be upgraded. You can remove the problem\n"
|
||||
"columns and restart the upgrade. A list of the problem columns is in the\n"
|
||||
"file:\n"
|
||||
" %s\n\n", output_path);
|
||||
@ -328,10 +328,10 @@ old_8_3_rebuild_tsvector_tables(ClusterInfo *cluster, bool check_mode)
|
||||
" NOT a.attisdropped AND "
|
||||
" a.atttypid = 'pg_catalog.tsvector'::pg_catalog.regtype AND "
|
||||
" c.relnamespace = n.oid AND "
|
||||
/* exclude possible orphaned temp tables */
|
||||
/* exclude possible orphaned temp tables */
|
||||
" n.nspname !~ '^pg_temp_' AND "
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
|
||||
|
||||
/*
|
||||
* This macro is used below to avoid reindexing indexes already rebuilt
|
||||
@ -527,7 +527,7 @@ old_8_3_invalidate_hash_gin_indexes(ClusterInfo *cluster, bool check_mode)
|
||||
"must be reindexed with the REINDEX command. The file:\n"
|
||||
" %s\n"
|
||||
"when executed by psql by the database superuser will recreate all invalid\n"
|
||||
"indexes; until then, none of these indexes will be used.\n\n",
|
||||
"indexes; until then, none of these indexes will be used.\n\n",
|
||||
output_path);
|
||||
}
|
||||
else
|
||||
@ -648,10 +648,10 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(ClusterInfo *cluster,
|
||||
pg_log(PG_WARNING, "\n"
|
||||
"Your installation contains indexes using \"bpchar_pattern_ops\". These\n"
|
||||
"indexes have different internal formats between your old and new clusters\n"
|
||||
"so they must be reindexed with the REINDEX command. The file:\n"
|
||||
"so they must be reindexed with the REINDEX command. The file:\n"
|
||||
" %s\n"
|
||||
"when executed by psql by the database superuser will recreate all invalid\n"
|
||||
"indexes; until then, none of these indexes will be used.\n\n",
|
||||
"indexes; until then, none of these indexes will be used.\n\n",
|
||||
output_path);
|
||||
}
|
||||
else
|
||||
@ -699,10 +699,10 @@ old_8_3_create_sequence_script(ClusterInfo *cluster)
|
||||
" pg_catalog.pg_namespace n "
|
||||
"WHERE c.relkind = 'S' AND "
|
||||
" c.relnamespace = n.oid AND "
|
||||
/* exclude possible orphaned temp tables */
|
||||
/* exclude possible orphaned temp tables */
|
||||
" n.nspname !~ '^pg_temp_' AND "
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
|
||||
" n.nspname !~ '^pg_toast_temp_' AND "
|
||||
" n.nspname NOT IN ('pg_catalog', 'information_schema')");
|
||||
|
||||
ntups = PQntuples(res);
|
||||
i_nspname = PQfnumber(res, "nspname");
|
||||
|
Reference in New Issue
Block a user