mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
pgindent run for 9.0, second run
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
* server checks and output routines
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/check.c,v 1.10 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/check.c,v 1.11 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -152,8 +152,8 @@ issue_warnings(migratorContext *ctx, char *sequence_script_file_name)
|
||||
{
|
||||
prep_status(ctx, "Adjusting sequences");
|
||||
exec_prog(ctx, true,
|
||||
SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on --port %d "
|
||||
"--username \"%s\" -f \"%s\" --dbname template1 >> \"%s\""
|
||||
SYSTEMQUOTE "\"%s/psql\" --set ON_ERROR_STOP=on --port %d "
|
||||
"--username \"%s\" -f \"%s\" --dbname template1 >> \"%s\""
|
||||
SYSTEMQUOTE,
|
||||
ctx->new.bindir, ctx->new.port, ctx->user,
|
||||
sequence_script_file_name, ctx->logfile);
|
||||
@ -217,7 +217,7 @@ check_cluster_versions(migratorContext *ctx)
|
||||
/* Only current PG version is supported as a target */
|
||||
if (GET_MAJOR_VERSION(ctx->new.major_version) != GET_MAJOR_VERSION(PG_VERSION_NUM))
|
||||
pg_log(ctx, PG_FATAL, "This utility can only upgrade to PostgreSQL version %s.\n",
|
||||
PG_MAJORVERSION);
|
||||
PG_MAJORVERSION);
|
||||
|
||||
/*
|
||||
* We can't allow downgrading because we use the target pg_dumpall, and
|
||||
@ -375,7 +375,7 @@ check_new_db_is_empty(migratorContext *ctx)
|
||||
*/
|
||||
void
|
||||
create_script_for_old_cluster_deletion(migratorContext *ctx,
|
||||
char **deletion_script_file_name)
|
||||
char **deletion_script_file_name)
|
||||
{
|
||||
FILE *script = NULL;
|
||||
int tblnum;
|
||||
@ -389,7 +389,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
|
||||
|
||||
if ((script = fopen(*deletion_script_file_name, "w")) == NULL)
|
||||
pg_log(ctx, PG_FATAL, "Could not create necessary file: %s\n",
|
||||
*deletion_script_file_name);
|
||||
*deletion_script_file_name);
|
||||
|
||||
#ifndef WIN32
|
||||
/* add shebang header */
|
||||
@ -420,6 +420,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
/*
|
||||
* Simply delete the tablespace directory, which might be ".old"
|
||||
* or a version-specific subdirectory.
|
||||
@ -433,7 +434,7 @@ create_script_for_old_cluster_deletion(migratorContext *ctx,
|
||||
#ifndef WIN32
|
||||
if (chmod(*deletion_script_file_name, S_IRWXU) != 0)
|
||||
pg_log(ctx, PG_FATAL, "Could not add execute permission to file: %s\n",
|
||||
*deletion_script_file_name);
|
||||
*deletion_script_file_name);
|
||||
#endif
|
||||
|
||||
check_ok(ctx);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* controldata functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/controldata.c,v 1.8 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/controldata.c,v 1.9 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -93,6 +93,7 @@ get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check)
|
||||
fputs(bufin, ctx->debug_fd);
|
||||
|
||||
#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
|
||||
|
@ -4,7 +4,7 @@
|
||||
* dump functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/dump.c,v 1.6 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/dump.c,v 1.7 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -24,7 +24,7 @@ generate_old_dump(migratorContext *ctx)
|
||||
exec_prog(ctx, true,
|
||||
SYSTEMQUOTE "\"%s/pg_dumpall\" --port %d --username \"%s\" "
|
||||
"--schema-only --binary-upgrade > \"%s/" ALL_DUMP_FILE "\""
|
||||
SYSTEMQUOTE, ctx->new.bindir, ctx->old.port, ctx->user, ctx->cwd);
|
||||
SYSTEMQUOTE, ctx->new.bindir, ctx->old.port, ctx->user, ctx->cwd);
|
||||
check_ok(ctx);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* execution functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/exec.c,v 1.7 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/exec.c,v 1.8 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
static void checkBinDir(migratorContext *ctx, ClusterInfo *cluster);
|
||||
static int check_exec(migratorContext *ctx, const char *dir, const char *cmdName);
|
||||
static int check_exec(migratorContext *ctx, const char *dir, const char *cmdName);
|
||||
static const char *validate_exec(const char *path);
|
||||
static int check_data_dir(migratorContext *ctx, const char *pg_data);
|
||||
|
||||
@ -311,5 +311,3 @@ check_data_dir(migratorContext *ctx, const char *pg_data)
|
||||
|
||||
return (fail) ? -1 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* file system operations
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/file.c,v 1.12 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/file.c,v 1.13 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -226,7 +226,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
|
||||
*/
|
||||
int
|
||||
pg_scandir(migratorContext *ctx, const char *dirname,
|
||||
struct dirent ***namelist,
|
||||
struct dirent *** namelist,
|
||||
int (*selector) (const struct dirent *))
|
||||
{
|
||||
#ifndef HAVE_SCANDIR
|
||||
@ -235,13 +235,14 @@ pg_scandir(migratorContext *ctx, const char *dirname,
|
||||
/*
|
||||
* scandir() is originally from BSD 4.3, which had the third argument as
|
||||
* non-const. Linux and other C libraries have updated it to use a const.
|
||||
* http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg00214.html
|
||||
* http://unix.derkeiler.com/Mailing-Lists/FreeBSD/questions/2005-12/msg002
|
||||
* 14.html
|
||||
*
|
||||
* Here we try to guess which libc's need const, and which don't. The net
|
||||
* goal here is to try to suppress a compiler warning due to a prototype
|
||||
* mismatch of const usage. Ideally we would do this via autoconf, but
|
||||
* autoconf doesn't have a suitable builtin test and it seems overkill
|
||||
* to add one just to avoid a warning.
|
||||
* autoconf doesn't have a suitable builtin test and it seems overkill to
|
||||
* add one just to avoid a warning.
|
||||
*/
|
||||
#elif defined(__FreeBSD__) || defined(__bsdi__) || defined(__darwin__) || defined(__OpenBSD__)
|
||||
/* no const */
|
||||
|
@ -4,7 +4,7 @@
|
||||
* information support functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/info.c,v 1.10 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/info.c,v 1.11 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -18,12 +18,12 @@ static void dbarr_print(migratorContext *ctx, DbInfoArr *arr,
|
||||
Cluster whichCluster);
|
||||
static void relarr_print(migratorContext *ctx, RelInfoArr *arr);
|
||||
static void get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
|
||||
RelInfoArr *relarr, Cluster whichCluster);
|
||||
RelInfoArr *relarr, Cluster whichCluster);
|
||||
static void relarr_free(RelInfoArr *rel_arr);
|
||||
static void map_rel(migratorContext *ctx, const RelInfo *oldrel,
|
||||
const RelInfo *newrel, const DbInfo *old_db,
|
||||
const DbInfo *new_db, const char *olddata,
|
||||
const char *newdata, FileNameMap *map);
|
||||
const RelInfo *newrel, const DbInfo *old_db,
|
||||
const DbInfo *new_db, const char *olddata,
|
||||
const char *newdata, FileNameMap *map);
|
||||
static void map_rel_by_id(migratorContext *ctx, Oid oldid, Oid newid,
|
||||
const char *old_nspname, const char *old_relname,
|
||||
const char *new_nspname, const char *new_relname,
|
||||
@ -31,10 +31,10 @@ static void map_rel_by_id(migratorContext *ctx, Oid oldid, Oid newid,
|
||||
const DbInfo *new_db, const char *olddata,
|
||||
const char *newdata, FileNameMap *map);
|
||||
static RelInfo *relarr_lookup_reloid(migratorContext *ctx,
|
||||
RelInfoArr *rel_arr, Oid oid, Cluster whichCluster);
|
||||
RelInfoArr *rel_arr, Oid oid, Cluster whichCluster);
|
||||
static RelInfo *relarr_lookup_rel(migratorContext *ctx, RelInfoArr *rel_arr,
|
||||
const char *nspname, const char *relname,
|
||||
Cluster whichCluster);
|
||||
const char *nspname, const char *relname,
|
||||
Cluster whichCluster);
|
||||
|
||||
|
||||
/*
|
||||
@ -226,13 +226,13 @@ get_db_infos(migratorContext *ctx, DbInfoArr *dbinfs_arr, Cluster whichCluster)
|
||||
int i_oid;
|
||||
int i_spclocation;
|
||||
|
||||
res = executeQueryOrDie(ctx, conn,
|
||||
"SELECT d.oid, d.datname, t.spclocation "
|
||||
"FROM pg_catalog.pg_database d "
|
||||
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
|
||||
" ON d.dattablespace = t.oid "
|
||||
"WHERE d.datallowconn = true");
|
||||
|
||||
res = executeQueryOrDie(ctx, conn,
|
||||
"SELECT d.oid, d.datname, t.spclocation "
|
||||
"FROM pg_catalog.pg_database d "
|
||||
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
|
||||
" ON d.dattablespace = t.oid "
|
||||
"WHERE d.datallowconn = true");
|
||||
|
||||
i_datname = PQfnumber(res, "datname");
|
||||
i_oid = PQfnumber(res, "oid");
|
||||
i_spclocation = PQfnumber(res, "spclocation");
|
||||
@ -358,7 +358,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
|
||||
for (relnum = 0; relnum < ntups; relnum++)
|
||||
{
|
||||
RelInfo *curr = &relinfos[num_rels++];
|
||||
const char *tblspace;
|
||||
const char *tblspace;
|
||||
|
||||
curr->reloid = atol(PQgetvalue(res, relnum, i_oid));
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* options functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/option.c,v 1.11 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/option.c,v 1.12 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -52,7 +52,7 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
|
||||
int option; /* Command line option */
|
||||
int optindex = 0; /* used by getopt_long */
|
||||
int user_id;
|
||||
|
||||
|
||||
if (getenv("PGUSER"))
|
||||
{
|
||||
pg_free(ctx->user);
|
||||
@ -68,7 +68,7 @@ parseCommandLine(migratorContext *ctx, int argc, char *argv[])
|
||||
|
||||
/* user lookup and 'root' test must be split because of usage() */
|
||||
user_id = get_user_info(ctx, &ctx->user);
|
||||
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 ||
|
||||
@ -303,7 +303,7 @@ validateDirectoryOption(migratorContext *ctx, char **dirpath,
|
||||
if ((*dirpath)[strlen(*dirpath) - 1] == '/')
|
||||
#else
|
||||
if ((*dirpath)[strlen(*dirpath) - 1] == '/' ||
|
||||
(*dirpath)[strlen(*dirpath) - 1] == '\\')
|
||||
(*dirpath)[strlen(*dirpath) - 1] == '\\')
|
||||
#endif
|
||||
(*dirpath)[strlen(*dirpath) - 1] = 0;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
* main source file
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/pg_upgrade.c,v 1.9 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/pg_upgrade.c,v 1.10 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -82,7 +82,7 @@ main(int argc, char **argv)
|
||||
*/
|
||||
prep_status(&ctx, "Setting next oid for new cluster");
|
||||
exec_prog(&ctx, true, SYSTEMQUOTE "\"%s/pg_resetxlog\" -o %u \"%s\" > "
|
||||
DEVNULL SYSTEMQUOTE,
|
||||
DEVNULL SYSTEMQUOTE,
|
||||
ctx.new.bindir, ctx.old.controldata.chkpnt_nxtoid, ctx.new.pgdata);
|
||||
check_ok(&ctx);
|
||||
|
||||
@ -166,10 +166,10 @@ prepare_new_cluster(migratorContext *ctx)
|
||||
check_ok(ctx);
|
||||
|
||||
/*
|
||||
* We do freeze after analyze so pg_statistic is also frozen.
|
||||
* template0 is not frozen here, but data rows were frozen by initdb,
|
||||
* and we set its datfrozenxid and relfrozenxids later to match the
|
||||
* new xid counter later.
|
||||
* We do freeze after analyze so pg_statistic is also frozen. template0 is
|
||||
* not frozen here, but data rows were frozen by initdb, and we set its
|
||||
* datfrozenxid and relfrozenxids later to match the new xid counter
|
||||
* later.
|
||||
*/
|
||||
prep_status(ctx, "Freezing all rows on the new cluster");
|
||||
exec_prog(ctx, true,
|
||||
@ -203,7 +203,7 @@ prepare_new_databases(migratorContext *ctx)
|
||||
prep_status(ctx, "Creating databases in the new cluster");
|
||||
exec_prog(ctx, true,
|
||||
SYSTEMQUOTE "\"%s/psql\" --port %d --username \"%s\" "
|
||||
"--set ON_ERROR_STOP=on -f \"%s/%s\" --dbname template1 >> \"%s\""
|
||||
"--set ON_ERROR_STOP=on -f \"%s/%s\" --dbname template1 >> \"%s\""
|
||||
SYSTEMQUOTE,
|
||||
ctx->new.bindir, ctx->new.port, ctx->user, ctx->cwd,
|
||||
GLOBALS_DUMP_FILE, ctx->logfile);
|
||||
@ -226,9 +226,9 @@ create_new_objects(migratorContext *ctx)
|
||||
prep_status(ctx, "Restoring database schema to new cluster");
|
||||
exec_prog(ctx, true,
|
||||
SYSTEMQUOTE "\"%s/psql\" --port %d --username \"%s\" "
|
||||
"--set ON_ERROR_STOP=on -f \"%s/%s\" --dbname template1 >> \"%s\""
|
||||
"--set ON_ERROR_STOP=on -f \"%s/%s\" --dbname template1 >> \"%s\""
|
||||
SYSTEMQUOTE,
|
||||
ctx->new.bindir, ctx->new.port, ctx->user, ctx->cwd,
|
||||
ctx->new.bindir, ctx->new.port, ctx->user, ctx->cwd,
|
||||
DB_DUMP_FILE, ctx->logfile);
|
||||
check_ok(ctx);
|
||||
|
||||
@ -300,7 +300,8 @@ void
|
||||
set_frozenxids(migratorContext *ctx)
|
||||
{
|
||||
int dbnum;
|
||||
PGconn *conn, *conn_template1;
|
||||
PGconn *conn,
|
||||
*conn_template1;
|
||||
PGresult *dbres;
|
||||
int ntups;
|
||||
int i_datname;
|
||||
@ -327,21 +328,21 @@ set_frozenxids(migratorContext *ctx)
|
||||
ntups = PQntuples(dbres);
|
||||
for (dbnum = 0; dbnum < ntups; dbnum++)
|
||||
{
|
||||
char *datname = PQgetvalue(dbres, dbnum, i_datname);
|
||||
char *datallowconn= PQgetvalue(dbres, dbnum, i_datallowconn);
|
||||
char *datname = PQgetvalue(dbres, dbnum, i_datname);
|
||||
char *datallowconn = PQgetvalue(dbres, dbnum, i_datallowconn);
|
||||
|
||||
/*
|
||||
* We must update databases where datallowconn = false, e.g.
|
||||
* template0, because autovacuum increments their datfrozenxids and
|
||||
* relfrozenxids even if autovacuum is turned off, and even though
|
||||
* all the data rows are already frozen To enable this, we
|
||||
* temporarily change datallowconn.
|
||||
* We must update databases where datallowconn = false, e.g.
|
||||
* template0, because autovacuum increments their datfrozenxids and
|
||||
* relfrozenxids even if autovacuum is turned off, and even though all
|
||||
* the data rows are already frozen To enable this, we temporarily
|
||||
* change datallowconn.
|
||||
*/
|
||||
if (strcmp(datallowconn, "f") == 0)
|
||||
PQclear(executeQueryOrDie(ctx, conn_template1,
|
||||
"UPDATE pg_catalog.pg_database "
|
||||
"SET datallowconn = true "
|
||||
"WHERE datname = '%s'", datname));
|
||||
"UPDATE pg_catalog.pg_database "
|
||||
"SET datallowconn = true "
|
||||
"WHERE datname = '%s'", datname));
|
||||
|
||||
conn = connectToServer(ctx, datname, CLUSTER_NEW);
|
||||
|
||||
@ -357,9 +358,9 @@ set_frozenxids(migratorContext *ctx)
|
||||
/* Reset datallowconn flag */
|
||||
if (strcmp(datallowconn, "f") == 0)
|
||||
PQclear(executeQueryOrDie(ctx, conn_template1,
|
||||
"UPDATE pg_catalog.pg_database "
|
||||
"SET datallowconn = false "
|
||||
"WHERE datname = '%s'", datname));
|
||||
"UPDATE pg_catalog.pg_database "
|
||||
"SET datallowconn = false "
|
||||
"WHERE datname = '%s'", datname));
|
||||
}
|
||||
|
||||
PQclear(dbres);
|
||||
|
@ -2,7 +2,7 @@
|
||||
* pg_upgrade.h
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/pg_upgrade.h,v 1.14 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/pg_upgrade.h,v 1.15 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
@ -21,7 +21,7 @@
|
||||
#define MAX_STRING 1024
|
||||
#define LINE_ALLOC 4096
|
||||
#define QUERY_ALLOC 8192
|
||||
|
||||
|
||||
#define MIGRATOR_API_VERSION 1
|
||||
|
||||
#define MESSAGE_WIDTH "60"
|
||||
@ -53,19 +53,19 @@
|
||||
#define CLUSTERNAME(cluster) ((cluster) == CLUSTER_OLD ? "old" : "new")
|
||||
|
||||
/* OID system catalog preservation added during PG 9.0 development */
|
||||
#define TABLE_SPACE_SUBDIRS 201001111
|
||||
#define TABLE_SPACE_SUBDIRS 201001111
|
||||
|
||||
/*
|
||||
* Each relation is represented by a relinfo structure.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char nspname[NAMEDATALEN]; /* namespace name */
|
||||
char relname[NAMEDATALEN]; /* relation name */
|
||||
char nspname[NAMEDATALEN]; /* namespace name */
|
||||
char relname[NAMEDATALEN]; /* relation name */
|
||||
Oid reloid; /* relation oid */
|
||||
Oid relfilenode; /* relation relfile node */
|
||||
Oid toastrelid; /* oid of the toast relation */
|
||||
char tablespace[MAXPGPATH]; /* relations tablespace path */
|
||||
char tablespace[MAXPGPATH]; /* relations tablespace path */
|
||||
} RelInfo;
|
||||
|
||||
typedef struct
|
||||
@ -83,10 +83,10 @@ typedef struct
|
||||
Oid new; /* Relfilenode of the new relation */
|
||||
char old_file[MAXPGPATH];
|
||||
char new_file[MAXPGPATH];
|
||||
char old_nspname[NAMEDATALEN]; /* old name of the namespace */
|
||||
char old_relname[NAMEDATALEN]; /* old name of the relation */
|
||||
char new_nspname[NAMEDATALEN]; /* new name of the namespace */
|
||||
char new_relname[NAMEDATALEN]; /* new name of the relation */
|
||||
char old_nspname[NAMEDATALEN]; /* old name of the namespace */
|
||||
char old_relname[NAMEDATALEN]; /* old name of the relation */
|
||||
char new_nspname[NAMEDATALEN]; /* new name of the namespace */
|
||||
char new_relname[NAMEDATALEN]; /* new name of the relation */
|
||||
} FileNameMap;
|
||||
|
||||
/*
|
||||
@ -161,7 +161,7 @@ typedef enum
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
NONE = 0, /* used for no running servers */
|
||||
NONE = 0, /* used for no running servers */
|
||||
CLUSTER_OLD,
|
||||
CLUSTER_NEW
|
||||
} Cluster;
|
||||
@ -177,15 +177,15 @@ typedef long pgpid_t;
|
||||
typedef struct
|
||||
{
|
||||
ControlData controldata; /* pg_control information */
|
||||
DbInfoArr dbarr; /* dbinfos array */
|
||||
char *pgdata; /* pathname for cluster's $PGDATA directory */
|
||||
char *bindir; /* pathname for cluster's executable directory */
|
||||
unsigned short port; /* port number where postmaster is waiting */
|
||||
uint32 major_version; /* PG_VERSION of cluster */
|
||||
char *major_version_str; /* string PG_VERSION of cluster */
|
||||
Oid pg_database_oid; /* OID of pg_database relation */
|
||||
char *libpath; /* pathname for cluster's pkglibdir */
|
||||
char *tablespace_suffix; /* directory specification */
|
||||
DbInfoArr dbarr; /* dbinfos array */
|
||||
char *pgdata; /* pathname for cluster's $PGDATA directory */
|
||||
char *bindir; /* pathname for cluster's executable directory */
|
||||
unsigned short port; /* port number where postmaster is waiting */
|
||||
uint32 major_version; /* PG_VERSION of cluster */
|
||||
char *major_version_str; /* string PG_VERSION of cluster */
|
||||
Oid pg_database_oid; /* OID of pg_database relation */
|
||||
char *libpath; /* pathname for cluster's pkglibdir */
|
||||
char *tablespace_suffix; /* directory specification */
|
||||
} ClusterInfo;
|
||||
|
||||
|
||||
@ -197,11 +197,12 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ClusterInfo old, new; /* old and new cluster information */
|
||||
ClusterInfo old,
|
||||
new; /* old and new cluster information */
|
||||
const char *progname; /* complete pathname for this program */
|
||||
char *exec_path; /* full path to my executable */
|
||||
char *user; /* username for clusters */
|
||||
char cwd[MAXPGPATH]; /* current working directory, used for output */
|
||||
char cwd[MAXPGPATH]; /* current working directory, used for output */
|
||||
char **tablespaces; /* tablespaces */
|
||||
int num_tablespaces;
|
||||
char **libraries; /* loadable libraries */
|
||||
@ -216,37 +217,37 @@ typedef struct
|
||||
* changes */
|
||||
bool verbose; /* TRUE -> be verbose in messages */
|
||||
bool debug; /* TRUE -> log more information */
|
||||
transferMode transfer_mode; /* copy files or link them? */
|
||||
transferMode transfer_mode; /* copy files or link them? */
|
||||
} migratorContext;
|
||||
|
||||
|
||||
/*
|
||||
* Global variables
|
||||
*/
|
||||
extern char scandir_file_pattern[];
|
||||
extern char scandir_file_pattern[];
|
||||
|
||||
|
||||
/* check.c */
|
||||
|
||||
void output_check_banner(migratorContext *ctx, bool *live_check);
|
||||
void check_old_cluster(migratorContext *ctx, bool live_check,
|
||||
char **sequence_script_file_name);
|
||||
void check_old_cluster(migratorContext *ctx, bool live_check,
|
||||
char **sequence_script_file_name);
|
||||
void check_new_cluster(migratorContext *ctx);
|
||||
void report_clusters_compatible(migratorContext *ctx);
|
||||
void issue_warnings(migratorContext *ctx,
|
||||
char *sequence_script_file_name);
|
||||
void output_completion_banner(migratorContext *ctx,
|
||||
char *deletion_script_file_name);
|
||||
void issue_warnings(migratorContext *ctx,
|
||||
char *sequence_script_file_name);
|
||||
void output_completion_banner(migratorContext *ctx,
|
||||
char *deletion_script_file_name);
|
||||
void check_cluster_versions(migratorContext *ctx);
|
||||
void check_cluster_compatibility(migratorContext *ctx, bool live_check);
|
||||
void create_script_for_old_cluster_deletion(migratorContext *ctx,
|
||||
char **deletion_script_file_name);
|
||||
void create_script_for_old_cluster_deletion(migratorContext *ctx,
|
||||
char **deletion_script_file_name);
|
||||
|
||||
|
||||
/* controldata.c */
|
||||
|
||||
void get_control_data(migratorContext *ctx, ClusterInfo *cluster, bool live_check);
|
||||
void check_control_data(migratorContext *ctx, ControlData *oldctrl,
|
||||
void check_control_data(migratorContext *ctx, ControlData *oldctrl,
|
||||
ControlData *newctrl);
|
||||
|
||||
|
||||
@ -258,8 +259,8 @@ void split_old_dump(migratorContext *ctx);
|
||||
|
||||
/* exec.c */
|
||||
|
||||
int exec_prog(migratorContext *ctx, bool throw_error,
|
||||
const char *cmd,...);
|
||||
int exec_prog(migratorContext *ctx, bool throw_error,
|
||||
const char *cmd,...);
|
||||
void verify_directories(migratorContext *ctx);
|
||||
bool is_server_running(migratorContext *ctx, const char *datadir);
|
||||
void rename_old_pg_control(migratorContext *ctx);
|
||||
@ -279,31 +280,28 @@ typedef const char *(*pluginShutdown) (void *pluginData);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 oldPageVersion; /* Page layout version of the old
|
||||
* cluster */
|
||||
uint16 newPageVersion; /* Page layout version of the new
|
||||
* cluster */
|
||||
uint16 oldPageVersion; /* Page layout version of the old cluster */
|
||||
uint16 newPageVersion; /* Page layout version of the new cluster */
|
||||
uint16 pluginVersion; /* API version of converter plugin */
|
||||
void *pluginData; /* Plugin data (set by plugin) */
|
||||
pluginStartup startup; /* Pointer to plugin's startup function */
|
||||
pluginConvertFile convertFile; /* Pointer to plugin's file converter
|
||||
void *pluginData; /* Plugin data (set by plugin) */
|
||||
pluginStartup startup; /* Pointer to plugin's startup function */
|
||||
pluginConvertFile convertFile; /* Pointer to plugin's file converter
|
||||
* function */
|
||||
pluginConvertPage convertPage; /* Pointer to plugin's page converter
|
||||
pluginConvertPage convertPage; /* Pointer to plugin's page converter
|
||||
* function */
|
||||
pluginShutdown shutdown; /* Pointer to plugin's shutdown function */
|
||||
} pageCnvCtx;
|
||||
|
||||
const char *setupPageConverter(migratorContext *ctx, pageCnvCtx **result);
|
||||
|
||||
#else
|
||||
/* dummy */
|
||||
typedef void *pageCnvCtx;
|
||||
#endif
|
||||
|
||||
int dir_matching_filenames(const struct dirent *scan_ent);
|
||||
int pg_scandir(migratorContext *ctx, const char *dirname,
|
||||
struct dirent ***namelist,
|
||||
int (*selector) (const struct dirent *));
|
||||
int dir_matching_filenames(const struct dirent * scan_ent);
|
||||
int pg_scandir(migratorContext *ctx, const char *dirname,
|
||||
struct dirent *** namelist,
|
||||
int (*selector) (const struct dirent *));
|
||||
const char *copyAndUpdateFile(migratorContext *ctx,
|
||||
pageCnvCtx *pageConverter, const char *src,
|
||||
const char *dst, bool force);
|
||||
@ -315,21 +313,21 @@ void check_hard_link(migratorContext *ctx);
|
||||
/* function.c */
|
||||
|
||||
void install_support_functions(migratorContext *ctx);
|
||||
void uninstall_support_functions(migratorContext *ctx);
|
||||
void uninstall_support_functions(migratorContext *ctx);
|
||||
void get_loadable_libraries(migratorContext *ctx);
|
||||
void check_loadable_libraries(migratorContext *ctx);
|
||||
|
||||
/* info.c */
|
||||
|
||||
FileNameMap *gen_db_file_maps(migratorContext *ctx, DbInfo *old_db,
|
||||
DbInfo *new_db, int *nmaps, const char *old_pgdata,
|
||||
const char *new_pgdata);
|
||||
void get_db_and_rel_infos(migratorContext *ctx, DbInfoArr *db_arr,
|
||||
Cluster whichCluster);
|
||||
DbInfo *new_db, int *nmaps, const char *old_pgdata,
|
||||
const char *new_pgdata);
|
||||
void get_db_and_rel_infos(migratorContext *ctx, DbInfoArr *db_arr,
|
||||
Cluster whichCluster);
|
||||
DbInfo *dbarr_lookup_db(DbInfoArr *db_arr, const char *db_name);
|
||||
void dbarr_free(DbInfoArr *db_arr);
|
||||
void print_maps(migratorContext *ctx, FileNameMap *maps, int n,
|
||||
const char *dbName);
|
||||
void print_maps(migratorContext *ctx, FileNameMap *maps, int n,
|
||||
const char *dbName);
|
||||
|
||||
/* option.c */
|
||||
|
||||
@ -349,15 +347,15 @@ void init_tablespaces(migratorContext *ctx);
|
||||
|
||||
/* server.c */
|
||||
|
||||
PGconn *connectToServer(migratorContext *ctx, const char *db_name,
|
||||
PGconn *connectToServer(migratorContext *ctx, const char *db_name,
|
||||
Cluster whichCluster);
|
||||
PGresult *executeQueryOrDie(migratorContext *ctx, PGconn *conn,
|
||||
PGresult *executeQueryOrDie(migratorContext *ctx, PGconn *conn,
|
||||
const char *fmt,...);
|
||||
|
||||
void start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet);
|
||||
void start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet);
|
||||
void stop_postmaster(migratorContext *ctx, bool fast, bool quiet);
|
||||
uint32 get_major_server_version(migratorContext *ctx, char **verstr,
|
||||
Cluster whichCluster);
|
||||
uint32 get_major_server_version(migratorContext *ctx, char **verstr,
|
||||
Cluster whichCluster);
|
||||
void check_for_libpq_envvars(migratorContext *ctx);
|
||||
|
||||
|
||||
@ -381,22 +379,22 @@ const char *getErrorText(int errNum);
|
||||
|
||||
/* version.c */
|
||||
|
||||
void new_9_0_populate_pg_largeobject_metadata(migratorContext *ctx,
|
||||
bool check_mode, Cluster whichCluster);
|
||||
void new_9_0_populate_pg_largeobject_metadata(migratorContext *ctx,
|
||||
bool check_mode, Cluster whichCluster);
|
||||
|
||||
/* version_old_8_3.c */
|
||||
|
||||
void old_8_3_check_for_name_data_type_usage(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
void old_8_3_check_for_tsquery_usage(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
void old_8_3_check_for_isn_and_int8_passing_mismatch(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
void old_8_3_rebuild_tsvector_tables(migratorContext *ctx,
|
||||
bool check_mode, Cluster whichCluster);
|
||||
void old_8_3_invalidate_hash_gin_indexes(migratorContext *ctx,
|
||||
bool check_mode, Cluster whichCluster);
|
||||
void old_8_3_invalidate_bpchar_pattern_ops_indexes(migratorContext *ctx,
|
||||
bool check_mode, Cluster whichCluster);
|
||||
char *old_8_3_create_sequence_script(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
void old_8_3_check_for_name_data_type_usage(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
void old_8_3_check_for_tsquery_usage(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
void old_8_3_check_for_isn_and_int8_passing_mismatch(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
void old_8_3_rebuild_tsvector_tables(migratorContext *ctx,
|
||||
bool check_mode, Cluster whichCluster);
|
||||
void old_8_3_invalidate_hash_gin_indexes(migratorContext *ctx,
|
||||
bool check_mode, Cluster whichCluster);
|
||||
void old_8_3_invalidate_bpchar_pattern_ops_indexes(migratorContext *ctx,
|
||||
bool check_mode, Cluster whichCluster);
|
||||
char *old_8_3_create_sequence_script(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* relfilenode functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/relfilenode.c,v 1.7 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/relfilenode.c,v 1.8 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -21,8 +21,8 @@ static void transfer_relfile(migratorContext *ctx, pageCnvCtx *pageConverter,
|
||||
const char *newnspname, const char *newrelname);
|
||||
|
||||
/* used by scandir(), must be global */
|
||||
char scandir_file_pattern[MAXPGPATH];
|
||||
|
||||
char scandir_file_pattern[MAXPGPATH];
|
||||
|
||||
/*
|
||||
* transfer_all_new_dbs()
|
||||
*
|
||||
|
@ -4,7 +4,7 @@
|
||||
* database server functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/server.c,v 1.7 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/server.c,v 1.8 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -181,11 +181,11 @@ start_postmaster(migratorContext *ctx, Cluster whichCluster, bool quiet)
|
||||
}
|
||||
|
||||
/*
|
||||
* On Win32, we can't send both server 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 pg_ctl output to 'nul'.
|
||||
*/
|
||||
* On Win32, we can't send both server 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 pg_ctl
|
||||
* output to 'nul'.
|
||||
*/
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" "
|
||||
"-o \"-p %d -c autovacuum=off "
|
||||
@ -233,13 +233,13 @@ stop_postmaster(migratorContext *ctx, bool fast, bool quiet)
|
||||
|
||||
/* See comment in start_postmaster() about why win32 output is ignored. */
|
||||
snprintf(cmd, sizeof(cmd),
|
||||
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" %s stop >> "
|
||||
"\"%s\" 2>&1" SYSTEMQUOTE,
|
||||
bindir, ctx->logfile, datadir, fast ? "-m fast" : "",
|
||||
SYSTEMQUOTE "\"%s/pg_ctl\" -l \"%s\" -D \"%s\" %s stop >> "
|
||||
"\"%s\" 2>&1" SYSTEMQUOTE,
|
||||
bindir, ctx->logfile, datadir, fast ? "-m fast" : "",
|
||||
#ifndef WIN32
|
||||
ctx->logfile);
|
||||
ctx->logfile);
|
||||
#else
|
||||
DEVNULL);
|
||||
DEVNULL);
|
||||
#endif
|
||||
exec_prog(ctx, fast ? false : true, "%s", cmd);
|
||||
|
||||
|
@ -4,14 +4,14 @@
|
||||
* tablespace functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/tablespace.c,v 1.5 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/tablespace.c,v 1.6 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
|
||||
static void get_tablespace_paths(migratorContext *ctx);
|
||||
static void set_tablespace_directory_suffix(migratorContext *ctx,
|
||||
Cluster whichCluster);
|
||||
Cluster whichCluster);
|
||||
|
||||
|
||||
void
|
||||
@ -52,7 +52,7 @@ get_tablespace_paths(migratorContext *ctx)
|
||||
|
||||
if ((ctx->num_tablespaces = PQntuples(res)) != 0)
|
||||
ctx->tablespaces = (char **) pg_malloc(ctx,
|
||||
ctx->num_tablespaces * sizeof(char *));
|
||||
ctx->num_tablespaces * sizeof(char *));
|
||||
else
|
||||
ctx->tablespaces = NULL;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* utility functions
|
||||
*
|
||||
* Copyright (c) 2010, PostgreSQL Global Development Group
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/util.c,v 1.4 2010/07/03 16:33:14 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pg_upgrade/util.c,v 1.5 2010/07/06 19:18:55 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "pg_upgrade.h"
|
||||
@ -156,8 +156,8 @@ quote_identifier(migratorContext *ctx, const char *s)
|
||||
int
|
||||
get_user_info(migratorContext *ctx, char **user_name)
|
||||
{
|
||||
int user_id;
|
||||
|
||||
int user_id;
|
||||
|
||||
#ifndef WIN32
|
||||
struct passwd *pw = getpwuid(geteuid());
|
||||
|
||||
|
Reference in New Issue
Block a user