static void check_locale_and_encoding(ControlData *oldctrl,
ControlData *newctrl);
static void check_for_isn_and_int8_passing_mismatch(
- Cluster whichCluster);
+ Cluster whichCluster);
static void check_for_reg_data_type_usage(Cluster whichCluster);
{
prep_status("Adjusting sequences");
exec_prog(true,
- SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on "
- "--no-psqlrc --port %d --username \"%s\" "
- "-f \"%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
+ SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on "
+ "--no-psqlrc --port %d --username \"%s\" "
+ "-f \"%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user,
sequence_script_file_name, log.filename);
unlink(sequence_script_file_name);
/* remove PG_VERSION? */
if (GET_MAJOR_VERSION(old_cluster.major_version) <= 804)
fprintf(script, RM_CMD " %s%s/PG_VERSION\n",
- os_info.tablespaces[tblnum], old_cluster.tablespace_suffix);
+ os_info.tablespaces[tblnum], old_cluster.tablespace_suffix);
for (dbnum = 0; dbnum < new_cluster.dbarr.ndbs; dbnum++)
{
fprintf(script, RMDIR_CMD " %s%s/%d\n",
- os_info.tablespaces[tblnum], old_cluster.tablespace_suffix,
+ os_info.tablespaces[tblnum], old_cluster.tablespace_suffix,
old_cluster.dbarr.dbs[dbnum].db_oid);
}
}
* or a version-specific subdirectory.
*/
fprintf(script, RMDIR_CMD " %s%s\n",
- os_info.tablespaces[tblnum], old_cluster.tablespace_suffix);
+ os_info.tablespaces[tblnum], old_cluster.tablespace_suffix);
}
fclose(script);
/*
- * check_for_isn_and_int8_passing_mismatch()
+ * check_for_isn_and_int8_passing_mismatch()
*
* /contrib/isn relies on data type int8, and in 8.4 int8 can now be passed
* by value. The schema dumps the CREATE TYPE PASSEDBYVALUE setting so
* pg_type.oid
* pg_enum.oid
*
- * Most of the reg* data types reference system catalog info that is
+ * Most of the reg* data types reference system catalog info that is
* not preserved, and hence these data types cannot be used in user
* tables upgraded by pg_upgrade.
*/
"WHERE c.oid = a.attrelid AND "
" NOT a.attisdropped AND "
" a.atttypid IN ( "
- " 'pg_catalog.regproc'::pg_catalog.regtype, "
+ " 'pg_catalog.regproc'::pg_catalog.regtype, "
" 'pg_catalog.regprocedure'::pg_catalog.regtype, "
- " 'pg_catalog.regoper'::pg_catalog.regtype, "
+ " 'pg_catalog.regoper'::pg_catalog.regtype, "
" 'pg_catalog.regoperator'::pg_catalog.regtype, "
- " 'pg_catalog.regclass'::pg_catalog.regtype, "
- /* regtype.oid is preserved, so 'regtype' is OK */
- " 'pg_catalog.regconfig'::pg_catalog.regtype, "
+ " 'pg_catalog.regclass'::pg_catalog.regtype, "
+ /* 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 "
#ifndef WIN32
NULL);
#else
- /* On Windows the default locale cannot be English, so force it */
+ /* On Windows the default locale cannot be English, so force it */
"en");
#endif
putenv2("LANGUAGE", NULL);
pclose(output);
/*
- * Restore environment variables
+ * Restore environment variables
*/
putenv2("LC_COLLATE", lc_collate);
putenv2("LC_CTYPE", lc_ctype);
pg_free(language);
pg_free(lc_all);
pg_free(lc_messages);
-
+
/* verify that we got all the mandatory pg_control data */
if (!got_xid || !got_oid ||
(!live_check && !got_log_id) ||
sprintf(envstr, "%s=%s", var, val);
putenv(envstr);
+
/*
- * Do not free envstr because it becomes part of the environment
- * on some operating systems. See port/unsetenv.c::unsetenv.
+ * Do not free envstr because it becomes part of the environment on
+ * some operating systems. See port/unsetenv.c::unsetenv.
*/
#else
SetEnvironmentVariableA(var, val);
exec_prog(true,
SYSTEMQUOTE "\"%s/pg_dumpall\" --port %d --username \"%s\" "
"--schema-only --binary-upgrade > \"%s/" ALL_DUMP_FILE "\""
- SYSTEMQUOTE, new_cluster.bindir, old_cluster.port, os_info.user, os_info.cwd);
+ SYSTEMQUOTE, new_cluster.bindir, old_cluster.port, os_info.user, os_info.cwd);
check_ok();
}
#include <grp.h>
-static void check_data_dir(const char *pg_data);
+static void check_data_dir(const char *pg_data);
static void check_bin_dir(ClusterInfo *cluster);
static int check_exec(const char *dir, const char *cmdName);
static const char *validate_exec(const char *path);
int subdirnum;
const char *requiredSubdirs[] = {"base", "global", "pg_clog",
"pg_multixact", "pg_subtrans", "pg_tblspc", "pg_twophase",
- "pg_xlog"};
+ "pg_xlog"};
for (subdirnum = 0;
subdirnum < sizeof(requiredSubdirs) / sizeof(requiredSubdirs[0]);
report_status(PG_FATAL, "check for %s failed: %s",
requiredSubdirs[subdirnum], getErrorText(errno));
else if (!S_ISDIR(statBuf.st_mode))
- report_status(PG_FATAL, "%s is not a directory",
- requiredSubdirs[subdirnum]);
+ report_status(PG_FATAL, "%s is not a directory",
+ requiredSubdirs[subdirnum]);
}
}
if (nbytes < 0)
{
- int save_errno = errno;
-
+ int save_errno = errno;
+
if (buffer != NULL)
free(buffer);
if (write(dest_fd, buffer, nbytes) != nbytes)
{
/* if write didn't set errno, assume problem is no disk space */
- int save_errno = errno ? errno : ENOSPC;
+ int save_errno = errno ? errno : ENOSPC;
if (buffer != NULL)
free(buffer);
fclose(script);
pg_log(PG_REPORT, "fatal\n");
pg_log(PG_FATAL,
- "| Your installation references loadable libraries that are missing\n"
+ "| Your installation references loadable libraries that are missing\n"
"| from the new installation. You can add these libraries to\n"
"| the new installation, or remove the functions using them\n"
"| from the old installation. A list of the problem libraries\n"
for (mapnum = 0; mapnum < n; mapnum++)
pg_log(PG_DEBUG, "%s.%s:%u ==> %s.%s:%u\n",
maps[mapnum].old_nspname, maps[mapnum].old_relname,
- maps[mapnum].old_relfilenode,
+ maps[mapnum].old_relfilenode,
maps[mapnum].new_nspname, maps[mapnum].new_relname,
- maps[mapnum].new_relfilenode);
+ maps[mapnum].new_relfilenode);
pg_log(PG_DEBUG, "\n\n");
}
static char *get_pkglibdir(const char *bindir);
-UserOpts user_opts;
+UserOpts user_opts;
/*
static void setup(char *argv0, bool live_check);
static void cleanup(void);
-ClusterInfo old_cluster, new_cluster;
+ClusterInfo old_cluster,
+ new_cluster;
OSInfo os_info;
int
prep_status("Setting next oid for new cluster");
exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -o %u \"%s\" > "
DEVNULL SYSTEMQUOTE,
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtoid, new_cluster.pgdata);
+ new_cluster.bindir, old_cluster.controldata.chkpnt_nxtoid, new_cluster.pgdata);
check_ok();
create_script_for_old_cluster_deletion(&deletion_script_file_name);
exec_prog(true,
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
"--all --analyze >> %s 2>&1" SYSTEMQUOTE,
- new_cluster.bindir, new_cluster.port, os_info.user, log.filename);
+ new_cluster.bindir, new_cluster.port, os_info.user, log.filename);
check_ok();
/*
exec_prog(true,
SYSTEMQUOTE "\"%s/vacuumdb\" --port %d --username \"%s\" "
"--all --freeze >> %s 2>&1" SYSTEMQUOTE,
- new_cluster.bindir, new_cluster.port, os_info.user, log.filename);
+ new_cluster.bindir, new_cluster.port, os_info.user, log.filename);
check_ok();
get_pg_database_relfilenode(CLUSTER_NEW);
prep_status("Creating databases in the new cluster");
exec_prog(true,
SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on "
- /* --no-psqlrc prevents AUTOCOMMIT=off */
+ /* --no-psqlrc prevents AUTOCOMMIT=off */
"--no-psqlrc --port %d --username \"%s\" "
"-f \"%s/%s\" --dbname template1 >> \"%s\"" SYSTEMQUOTE,
new_cluster.bindir, new_cluster.port, os_info.user, os_info.cwd,
/* set the next transaction id of the new cluster */
prep_status("Setting next transaction id for new cluster");
exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -f -x %u \"%s\" > " DEVNULL SYSTEMQUOTE,
- new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid, new_cluster.pgdata);
+ new_cluster.bindir, old_cluster.controldata.chkpnt_nxtxid, new_cluster.pgdata);
check_ok();
/* now reset the wal archives in the new cluster */
prep_status("Resetting WAL archives");
exec_prog(true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -l %u,%u,%u \"%s\" >> \"%s\" 2>&1" SYSTEMQUOTE,
new_cluster.bindir, old_cluster.controldata.chkpnt_tli,
- old_cluster.controldata.logid, old_cluster.controldata.nxtlogseg,
+ old_cluster.controldata.logid, old_cluster.controldata.nxtlogseg,
new_cluster.pgdata, log.filename);
check_ok();
}
#endif
#define CLUSTERNAME(cluster) ((cluster) == CLUSTER_OLD ? "old" : "new")
-#define ACTIVE_CLUSTER(cluster) (((cluster) == CLUSTER_OLD) ? \
+#define ACTIVE_CLUSTER(cluster) (((cluster) == CLUSTER_OLD) ? \
&old_cluster : &new_cluster)
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
*/
typedef struct
{
- Oid old_relfilenode; /* Relfilenode of the old relation */
- Oid new_relfilenode; /* Relfilenode of the new relation */
+ Oid old_relfilenode; /* Relfilenode of the old relation */
+ Oid new_relfilenode; /* Relfilenode of the new relation */
char old_file[MAXPGPATH];
char new_file[MAXPGPATH];
char old_nspname[NAMEDATALEN]; /* old name of the namespace */
/*
* Global variables
*/
-extern Log log;
-extern UserOpts user_opts;
-extern ClusterInfo old_cluster, new_cluster;
-extern OSInfo os_info;
+extern Log log;
+extern UserOpts user_opts;
+extern ClusterInfo old_cluster,
+ new_cluster;
+extern OSInfo os_info;
extern char scandir_file_pattern[];
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_old_cluster_deletion(char **deletion_script_file_name);
/* controldata.c */
/* version_old_8_3.c */
-void old_8_3_check_for_name_data_type_usage(Cluster whichCluster);
-void old_8_3_check_for_tsquery_usage(Cluster whichCluster);
+void old_8_3_check_for_name_data_type_usage(Cluster whichCluster);
+void old_8_3_check_for_tsquery_usage(Cluster whichCluster);
void old_8_3_rebuild_tsvector_tables(bool check_mode,
- Cluster whichCluster);
+ Cluster whichCluster);
void old_8_3_invalidate_hash_gin_indexes(bool check_mode,
- Cluster whichCluster);
+ Cluster whichCluster);
void old_8_3_invalidate_bpchar_pattern_ops_indexes(bool check_mode,
- Cluster whichCluster);
-char *old_8_3_create_sequence_script(Cluster whichCluster);
+ Cluster whichCluster);
+char *old_8_3_create_sequence_script(Cluster whichCluster);
}
}
- prep_status(""); /* in case nothing printed */
+ prep_status(""); /* in case nothing printed */
check_ok();
return msg;
/* Copying files might take some time, so give feedback. */
snprintf(old_file, sizeof(old_file), "%s/%u", maps[mapnum].old_file,
- maps[mapnum].old_relfilenode);
+ maps[mapnum].old_relfilenode);
snprintf(new_file, sizeof(new_file), "%s/%u", maps[mapnum].new_file,
- maps[mapnum].new_relfilenode);
+ maps[mapnum].new_relfilenode);
pg_log(PG_REPORT, OVERWRITE_MESSAGE, old_file);
/*
* Now copy/link any fsm and vm files, if they exist
*/
snprintf(scandir_file_pattern, sizeof(scandir_file_pattern), "%u_",
- maps[mapnum].old_relfilenode);
+ maps[mapnum].old_relfilenode);
numFiles = pg_scandir(maps[mapnum].old_file, &namelist, dir_matching_filenames);
while (numFiles--)
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_file,
namelist[numFiles]->d_name);
snprintf(new_file, sizeof(new_file), "%s/%u%s", maps[mapnum].new_file,
- maps[mapnum].new_relfilenode, strchr(namelist[numFiles]->d_name, '_'));
+ maps[mapnum].new_relfilenode, strchr(namelist[numFiles]->d_name, '_'));
unlink(new_file);
transfer_relfile(pageConverter, old_file, new_file,
* copied.
*/
snprintf(scandir_file_pattern, sizeof(scandir_file_pattern), "%u.",
- maps[mapnum].old_relfilenode);
+ maps[mapnum].old_relfilenode);
numFiles = pg_scandir(maps[mapnum].old_file, &namelist, dir_matching_filenames);
while (numFiles--)
snprintf(old_file, sizeof(old_file), "%s/%s", maps[mapnum].old_file,
namelist[numFiles]->d_name);
snprintf(new_file, sizeof(new_file), "%s/%u%s", maps[mapnum].new_file,
- maps[mapnum].new_relfilenode, strchr(namelist[numFiles]->d_name, '.'));
+ maps[mapnum].new_relfilenode, strchr(namelist[numFiles]->d_name, '.'));
unlink(new_file);
transfer_relfile(pageConverter, old_file, new_file,
PGconn *conn;
snprintf(connectString, sizeof(connectString),
- "dbname = '%s' user = '%s' port = %d", db_name, os_info.user, port);
+ "dbname = '%s' user = '%s' port = %d", db_name, os_info.user, port);
conn = PQconnectdb(connectString);
/*
* On Win32, we can't send both pg_upgrade output and pg_ctl output to the
* same file because we get the error: "The process cannot access the file
- * because it is being used by another process." so we have to send all other
- * output to 'nul'.
+ * because it is being used by another process." so we have to send all
+ * other output to 'nul'.
*/
snprintf(cmd, sizeof(cmd),
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
bool ret = false;
snprintf(con_opts, sizeof(con_opts),
- "dbname = 'template1' user = '%s' port = %d ", os_info.user, port);
+ "dbname = 'template1' user = '%s' port = %d ", os_info.user, port);
for (tries = 0; tries < timeout; tries++)
{
set_tablespace_directory_suffix(CLUSTER_NEW);
if (os_info.num_tablespaces > 0 &&
- strcmp(old_cluster.tablespace_suffix, new_cluster.tablespace_suffix) == 0)
+ strcmp(old_cluster.tablespace_suffix, new_cluster.tablespace_suffix) == 0)
pg_log(PG_FATAL,
"Cannot migrate to/from the same system catalog version when\n"
"using tablespaces.\n");
if ((os_info.num_tablespaces = PQntuples(res)) != 0)
os_info.tablespaces = (char **) pg_malloc(
- os_info.num_tablespaces * sizeof(char *));
+ os_info.num_tablespaces * sizeof(char *));
else
os_info.tablespaces = NULL;
{
/* This cluster has a version-specific subdirectory */
active_cluster->tablespace_suffix = pg_malloc(4 +
- strlen(active_cluster->major_version_str) +
- 10 /* OIDCHARS */ + 1);
+ strlen(active_cluster->major_version_str) +
+ 10 /* OIDCHARS */ + 1);
/* The leading slash is needed to start a new directory. */
sprintf(active_cluster->tablespace_suffix, "/PG_%s_%d", active_cluster->major_version_str,
if (strlen(old_nspname) != 0 || strlen(old_relname) != 0)
fprintf(script, ";\n\n");
fprintf(script, "ALTER TABLE %s.%s\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
+ quote_identifier(PQgetvalue(res, rowno, i_nspname)),
+ quote_identifier(PQgetvalue(res, rowno, i_relname)));
}
else
fprintf(script, ",\n");
fprintf(script, "ALTER COLUMN %s "
/* This could have been a custom conversion function call. */
"TYPE pg_catalog.tsvector USING %s::pg_catalog.text::pg_catalog.tsvector",
- quote_identifier(PQgetvalue(res, rowno, i_attname)),
- quote_identifier(PQgetvalue(res, rowno, i_attname)));
+ quote_identifier(PQgetvalue(res, rowno, i_attname)),
+ quote_identifier(PQgetvalue(res, rowno, i_attname)));
}
}
if (strlen(old_nspname) != 0 || strlen(old_relname) != 0)
db_used = true;
}
fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
+ quote_identifier(PQgetvalue(res, rowno, i_nspname)),
+ quote_identifier(PQgetvalue(res, rowno, i_relname)));
}
}
db_used = true;
}
fprintf(script, "REINDEX INDEX %s.%s;\n",
- quote_identifier(PQgetvalue(res, rowno, i_nspname)),
- quote_identifier(PQgetvalue(res, rowno, i_relname)));
+ quote_identifier(PQgetvalue(res, rowno, i_nspname)),
+ quote_identifier(PQgetvalue(res, rowno, i_relname)));
}
}
i_is_called = PQfnumber(seq_res, "is_called");
fprintf(script, "SELECT setval('%s.%s', %s, '%s');\n",
- quote_identifier(nspname), quote_identifier(relname),
+ quote_identifier(nspname), quote_identifier(relname),
PQgetvalue(seq_res, 0, i_last_value), PQgetvalue(seq_res, 0, i_is_called));
PQclear(seq_res);
}