Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
07456b45
Commit
07456b45
authored
Oct 19, 2010
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pgindent run on pg_upgrade source after restructuring.
parent
e13f7e9a
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
79 additions
and
76 deletions
+79
-76
contrib/pg_upgrade/check.c
contrib/pg_upgrade/check.c
+14
-14
contrib/pg_upgrade/controldata.c
contrib/pg_upgrade/controldata.c
+6
-5
contrib/pg_upgrade/dump.c
contrib/pg_upgrade/dump.c
+1
-1
contrib/pg_upgrade/exec.c
contrib/pg_upgrade/exec.c
+4
-4
contrib/pg_upgrade/file.c
contrib/pg_upgrade/file.c
+3
-3
contrib/pg_upgrade/function.c
contrib/pg_upgrade/function.c
+1
-1
contrib/pg_upgrade/info.c
contrib/pg_upgrade/info.c
+2
-2
contrib/pg_upgrade/option.c
contrib/pg_upgrade/option.c
+1
-1
contrib/pg_upgrade/pg_upgrade.c
contrib/pg_upgrade/pg_upgrade.c
+8
-7
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/pg_upgrade.h
+15
-14
contrib/pg_upgrade/relfilenode.c
contrib/pg_upgrade/relfilenode.c
+7
-7
contrib/pg_upgrade/server.c
contrib/pg_upgrade/server.c
+4
-4
contrib/pg_upgrade/tablespace.c
contrib/pg_upgrade/tablespace.c
+4
-4
contrib/pg_upgrade/version_old_8_3.c
contrib/pg_upgrade/version_old_8_3.c
+9
-9
No files found.
contrib/pg_upgrade/check.c
View file @
07456b45
...
@@ -15,7 +15,7 @@ static void check_new_db_is_empty(void);
...
@@ -15,7 +15,7 @@ static void check_new_db_is_empty(void);
static
void
check_locale_and_encoding
(
ControlData
*
oldctrl
,
static
void
check_locale_and_encoding
(
ControlData
*
oldctrl
,
ControlData
*
newctrl
);
ControlData
*
newctrl
);
static
void
check_for_isn_and_int8_passing_mismatch
(
static
void
check_for_isn_and_int8_passing_mismatch
(
Cluster
whichCluster
);
Cluster
whichCluster
);
static
void
check_for_reg_data_type_usage
(
Cluster
whichCluster
);
static
void
check_for_reg_data_type_usage
(
Cluster
whichCluster
);
...
@@ -156,9 +156,9 @@ issue_warnings(char *sequence_script_file_name)
...
@@ -156,9 +156,9 @@ issue_warnings(char *sequence_script_file_name)
{
{
prep_status
(
"Adjusting sequences"
);
prep_status
(
"Adjusting sequences"
);
exec_prog
(
true
,
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/psql
\"
--set ON_ERROR_STOP=on "
SYSTEMQUOTE
"
\"
%s/psql
\"
--set ON_ERROR_STOP=on "
"--no-psqlrc --port %d --username
\"
%s
\"
"
"--no-psqlrc --port %d --username
\"
%s
\"
"
"-f
\"
%s
\"
--dbname template1 >>
\"
%s
\"
"
SYSTEMQUOTE
,
"-f
\"
%s
\"
--dbname template1 >>
\"
%s
\"
"
SYSTEMQUOTE
,
new_cluster
.
bindir
,
new_cluster
.
port
,
os_info
.
user
,
new_cluster
.
bindir
,
new_cluster
.
port
,
os_info
.
user
,
sequence_script_file_name
,
log
.
filename
);
sequence_script_file_name
,
log
.
filename
);
unlink
(
sequence_script_file_name
);
unlink
(
sequence_script_file_name
);
...
@@ -418,12 +418,12 @@ create_script_for_old_cluster_deletion(
...
@@ -418,12 +418,12 @@ create_script_for_old_cluster_deletion(
/* remove PG_VERSION? */
/* remove PG_VERSION? */
if
(
GET_MAJOR_VERSION
(
old_cluster
.
major_version
)
<=
804
)
if
(
GET_MAJOR_VERSION
(
old_cluster
.
major_version
)
<=
804
)
fprintf
(
script
,
RM_CMD
" %s%s/PG_VERSION
\n
"
,
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
++
)
for
(
dbnum
=
0
;
dbnum
<
new_cluster
.
dbarr
.
ndbs
;
dbnum
++
)
{
{
fprintf
(
script
,
RMDIR_CMD
" %s%s/%d
\n
"
,
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
);
old_cluster
.
dbarr
.
dbs
[
dbnum
].
db_oid
);
}
}
}
}
...
@@ -434,7 +434,7 @@ create_script_for_old_cluster_deletion(
...
@@ -434,7 +434,7 @@ create_script_for_old_cluster_deletion(
* or a version-specific subdirectory.
* or a version-specific subdirectory.
*/
*/
fprintf
(
script
,
RMDIR_CMD
" %s%s
\n
"
,
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
);
fclose
(
script
);
...
@@ -450,7 +450,7 @@ create_script_for_old_cluster_deletion(
...
@@ -450,7 +450,7 @@ create_script_for_old_cluster_deletion(
/*
/*
*
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
* /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
* by value. The schema dumps the CREATE TYPE PASSEDBYVALUE setting so
...
@@ -547,7 +547,7 @@ check_for_isn_and_int8_passing_mismatch(Cluster whichCluster)
...
@@ -547,7 +547,7 @@ check_for_isn_and_int8_passing_mismatch(Cluster whichCluster)
* pg_type.oid
* pg_type.oid
* pg_enum.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
* not preserved, and hence these data types cannot be used in user
* tables upgraded by pg_upgrade.
* tables upgraded by pg_upgrade.
*/
*/
...
@@ -585,13 +585,13 @@ check_for_reg_data_type_usage(Cluster whichCluster)
...
@@ -585,13 +585,13 @@ check_for_reg_data_type_usage(Cluster whichCluster)
"WHERE c.oid = a.attrelid AND "
"WHERE c.oid = a.attrelid AND "
" NOT a.attisdropped AND "
" NOT a.attisdropped AND "
" a.atttypid IN ( "
" a.atttypid IN ( "
" 'pg_catalog.regproc'::pg_catalog.regtype, "
" '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.regoper'::pg_catalog.regtype, "
" 'pg_catalog.regoperator'::pg_catalog.regtype, "
" 'pg_catalog.regoperator'::pg_catalog.regtype, "
" 'pg_catalog.regclass'::pg_catalog.regtype, "
" 'pg_catalog.regclass'::pg_catalog.regtype, "
/* regtype.oid is preserved, so 'regtype' is OK */
/* regtype.oid is preserved, so 'regtype' is OK */
" 'pg_catalog.regconfig'::pg_catalog.regtype, "
" 'pg_catalog.regconfig'::pg_catalog.regtype, "
" 'pg_catalog.regdictionary'::pg_catalog.regtype) AND "
" 'pg_catalog.regdictionary'::pg_catalog.regtype) AND "
" c.relnamespace = n.oid AND "
" c.relnamespace = n.oid AND "
" n.nspname != 'pg_catalog' AND "
" n.nspname != 'pg_catalog' AND "
...
...
contrib/pg_upgrade/controldata.c
View file @
07456b45
...
@@ -94,7 +94,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
...
@@ -94,7 +94,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
#ifndef WIN32
#ifndef WIN32
NULL
);
NULL
);
#else
#else
/* On Windows the default locale cannot be English, so force it */
/* On Windows the default locale cannot be English, so force it */
"en"
);
"en"
);
#endif
#endif
putenv2
(
"LANGUAGE"
,
NULL
);
putenv2
(
"LANGUAGE"
,
NULL
);
...
@@ -372,7 +372,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
...
@@ -372,7 +372,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pclose
(
output
);
pclose
(
output
);
/*
/*
*
Restore environment variables
*
Restore environment variables
*/
*/
putenv2
(
"LC_COLLATE"
,
lc_collate
);
putenv2
(
"LC_COLLATE"
,
lc_collate
);
putenv2
(
"LC_CTYPE"
,
lc_ctype
);
putenv2
(
"LC_CTYPE"
,
lc_ctype
);
...
@@ -393,7 +393,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
...
@@ -393,7 +393,7 @@ get_control_data(ClusterInfo *cluster, bool live_check)
pg_free
(
language
);
pg_free
(
language
);
pg_free
(
lc_all
);
pg_free
(
lc_all
);
pg_free
(
lc_messages
);
pg_free
(
lc_messages
);
/* verify that we got all the mandatory pg_control data */
/* verify that we got all the mandatory pg_control data */
if
(
!
got_xid
||
!
got_oid
||
if
(
!
got_xid
||
!
got_oid
||
(
!
live_check
&&
!
got_log_id
)
||
(
!
live_check
&&
!
got_log_id
)
||
...
@@ -549,9 +549,10 @@ putenv2(const char *var, const char *val)
...
@@ -549,9 +549,10 @@ putenv2(const char *var, const char *val)
sprintf
(
envstr
,
"%s=%s"
,
var
,
val
);
sprintf
(
envstr
,
"%s=%s"
,
var
,
val
);
putenv
(
envstr
);
putenv
(
envstr
);
/*
/*
*
Do not free envstr because it becomes part of the environment
*
Do not free envstr because it becomes part of the environment on
*
on some operating systems.
See port/unsetenv.c::unsetenv.
*
some operating systems.
See port/unsetenv.c::unsetenv.
*/
*/
#else
#else
SetEnvironmentVariableA
(
var
,
val
);
SetEnvironmentVariableA
(
var
,
val
);
...
...
contrib/pg_upgrade/dump.c
View file @
07456b45
...
@@ -24,7 +24,7 @@ generate_old_dump(void)
...
@@ -24,7 +24,7 @@ generate_old_dump(void)
exec_prog
(
true
,
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/pg_dumpall
\"
--port %d --username
\"
%s
\"
"
SYSTEMQUOTE
"
\"
%s/pg_dumpall
\"
--port %d --username
\"
%s
\"
"
"--schema-only --binary-upgrade >
\"
%s/"
ALL_DUMP_FILE
"
\"
"
"--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
();
check_ok
();
}
}
...
...
contrib/pg_upgrade/exec.c
View file @
07456b45
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#include <grp.h>
#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
void
check_bin_dir
(
ClusterInfo
*
cluster
);
static
int
check_exec
(
const
char
*
dir
,
const
char
*
cmdName
);
static
int
check_exec
(
const
char
*
dir
,
const
char
*
cmdName
);
static
const
char
*
validate_exec
(
const
char
*
path
);
static
const
char
*
validate_exec
(
const
char
*
path
);
...
@@ -128,7 +128,7 @@ check_data_dir(const char *pg_data)
...
@@ -128,7 +128,7 @@ check_data_dir(const char *pg_data)
int
subdirnum
;
int
subdirnum
;
const
char
*
requiredSubdirs
[]
=
{
"base"
,
"global"
,
"pg_clog"
,
const
char
*
requiredSubdirs
[]
=
{
"base"
,
"global"
,
"pg_clog"
,
"pg_multixact"
,
"pg_subtrans"
,
"pg_tblspc"
,
"pg_twophase"
,
"pg_multixact"
,
"pg_subtrans"
,
"pg_tblspc"
,
"pg_twophase"
,
"pg_xlog"
};
"pg_xlog"
};
for
(
subdirnum
=
0
;
for
(
subdirnum
=
0
;
subdirnum
<
sizeof
(
requiredSubdirs
)
/
sizeof
(
requiredSubdirs
[
0
]);
subdirnum
<
sizeof
(
requiredSubdirs
)
/
sizeof
(
requiredSubdirs
[
0
]);
...
@@ -143,8 +143,8 @@ check_data_dir(const char *pg_data)
...
@@ -143,8 +143,8 @@ check_data_dir(const char *pg_data)
report_status
(
PG_FATAL
,
"check for %s failed: %s"
,
report_status
(
PG_FATAL
,
"check for %s failed: %s"
,
requiredSubdirs
[
subdirnum
],
getErrorText
(
errno
));
requiredSubdirs
[
subdirnum
],
getErrorText
(
errno
));
else
if
(
!
S_ISDIR
(
statBuf
.
st_mode
))
else
if
(
!
S_ISDIR
(
statBuf
.
st_mode
))
report_status
(
PG_FATAL
,
"%s is not a directory"
,
report_status
(
PG_FATAL
,
"%s is not a directory"
,
requiredSubdirs
[
subdirnum
]);
requiredSubdirs
[
subdirnum
]);
}
}
}
}
...
...
contrib/pg_upgrade/file.c
View file @
07456b45
...
@@ -173,8 +173,8 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
...
@@ -173,8 +173,8 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if
(
nbytes
<
0
)
if
(
nbytes
<
0
)
{
{
int
save_errno
=
errno
;
int
save_errno
=
errno
;
if
(
buffer
!=
NULL
)
if
(
buffer
!=
NULL
)
free
(
buffer
);
free
(
buffer
);
...
@@ -196,7 +196,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
...
@@ -196,7 +196,7 @@ copy_file(const char *srcfile, const char *dstfile, bool force)
if
(
write
(
dest_fd
,
buffer
,
nbytes
)
!=
nbytes
)
if
(
write
(
dest_fd
,
buffer
,
nbytes
)
!=
nbytes
)
{
{
/* if write didn't set errno, assume problem is no disk space */
/* 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
)
if
(
buffer
!=
NULL
)
free
(
buffer
);
free
(
buffer
);
...
...
contrib/pg_upgrade/function.c
View file @
07456b45
...
@@ -253,7 +253,7 @@ check_loadable_libraries(void)
...
@@ -253,7 +253,7 @@ check_loadable_libraries(void)
fclose
(
script
);
fclose
(
script
);
pg_log
(
PG_REPORT
,
"fatal
\n
"
);
pg_log
(
PG_REPORT
,
"fatal
\n
"
);
pg_log
(
PG_FATAL
,
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
"
"| from the new installation. You can add these libraries to
\n
"
"| the new installation, or remove the functions using them
\n
"
"| the new installation, or remove the functions using them
\n
"
"| from the old installation. A list of the problem libraries
\n
"
"| from the old installation. A list of the problem libraries
\n
"
...
...
contrib/pg_upgrade/info.c
View file @
07456b45
...
@@ -201,9 +201,9 @@ print_maps(FileNameMap *maps, int n, const char *dbName)
...
@@ -201,9 +201,9 @@ print_maps(FileNameMap *maps, int n, const char *dbName)
for
(
mapnum
=
0
;
mapnum
<
n
;
mapnum
++
)
for
(
mapnum
=
0
;
mapnum
<
n
;
mapnum
++
)
pg_log
(
PG_DEBUG
,
"%s.%s:%u ==> %s.%s:%u
\n
"
,
pg_log
(
PG_DEBUG
,
"%s.%s:%u ==> %s.%s:%u
\n
"
,
maps
[
mapnum
].
old_nspname
,
maps
[
mapnum
].
old_relname
,
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_nspname
,
maps
[
mapnum
].
new_relname
,
maps
[
mapnum
].
new_relfilenode
);
maps
[
mapnum
].
new_relfilenode
);
pg_log
(
PG_DEBUG
,
"
\n\n
"
);
pg_log
(
PG_DEBUG
,
"
\n\n
"
);
}
}
...
...
contrib/pg_upgrade/option.c
View file @
07456b45
...
@@ -23,7 +23,7 @@ static void get_pkglibdirs(void);
...
@@ -23,7 +23,7 @@ static void get_pkglibdirs(void);
static
char
*
get_pkglibdir
(
const
char
*
bindir
);
static
char
*
get_pkglibdir
(
const
char
*
bindir
);
UserOpts
user_opts
;
UserOpts
user_opts
;
/*
/*
...
...
contrib/pg_upgrade/pg_upgrade.c
View file @
07456b45
...
@@ -22,7 +22,8 @@ static void set_frozenxids(void);
...
@@ -22,7 +22,8 @@ static void set_frozenxids(void);
static
void
setup
(
char
*
argv0
,
bool
live_check
);
static
void
setup
(
char
*
argv0
,
bool
live_check
);
static
void
cleanup
(
void
);
static
void
cleanup
(
void
);
ClusterInfo
old_cluster
,
new_cluster
;
ClusterInfo
old_cluster
,
new_cluster
;
OSInfo
os_info
;
OSInfo
os_info
;
int
int
...
@@ -82,7 +83,7 @@ main(int argc, char **argv)
...
@@ -82,7 +83,7 @@ main(int argc, char **argv)
prep_status
(
"Setting next oid for new cluster"
);
prep_status
(
"Setting next oid for new cluster"
);
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/pg_resetxlog
\"
-o %u
\"
%s
\"
> "
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/pg_resetxlog
\"
-o %u
\"
%s
\"
> "
DEVNULL
SYSTEMQUOTE
,
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
();
check_ok
();
create_script_for_old_cluster_deletion
(
&
deletion_script_file_name
);
create_script_for_old_cluster_deletion
(
&
deletion_script_file_name
);
...
@@ -161,7 +162,7 @@ prepare_new_cluster(void)
...
@@ -161,7 +162,7 @@ prepare_new_cluster(void)
exec_prog
(
true
,
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/vacuumdb
\"
--port %d --username
\"
%s
\"
"
SYSTEMQUOTE
"
\"
%s/vacuumdb
\"
--port %d --username
\"
%s
\"
"
"--all --analyze >> %s 2>&1"
SYSTEMQUOTE
,
"--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
();
check_ok
();
/*
/*
...
@@ -174,7 +175,7 @@ prepare_new_cluster(void)
...
@@ -174,7 +175,7 @@ prepare_new_cluster(void)
exec_prog
(
true
,
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/vacuumdb
\"
--port %d --username
\"
%s
\"
"
SYSTEMQUOTE
"
\"
%s/vacuumdb
\"
--port %d --username
\"
%s
\"
"
"--all --freeze >> %s 2>&1"
SYSTEMQUOTE
,
"--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
();
check_ok
();
get_pg_database_relfilenode
(
CLUSTER_NEW
);
get_pg_database_relfilenode
(
CLUSTER_NEW
);
...
@@ -202,7 +203,7 @@ prepare_new_databases(void)
...
@@ -202,7 +203,7 @@ prepare_new_databases(void)
prep_status
(
"Creating databases in the new cluster"
);
prep_status
(
"Creating databases in the new cluster"
);
exec_prog
(
true
,
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/psql
\"
--set ON_ERROR_STOP=on "
SYSTEMQUOTE
"
\"
%s/psql
\"
--set ON_ERROR_STOP=on "
/* --no-psqlrc prevents AUTOCOMMIT=off */
/* --no-psqlrc prevents AUTOCOMMIT=off */
"--no-psqlrc --port %d --username
\"
%s
\"
"
"--no-psqlrc --port %d --username
\"
%s
\"
"
"-f
\"
%s/%s
\"
--dbname template1 >>
\"
%s
\"
"
SYSTEMQUOTE
,
"-f
\"
%s/%s
\"
--dbname template1 >>
\"
%s
\"
"
SYSTEMQUOTE
,
new_cluster
.
bindir
,
new_cluster
.
port
,
os_info
.
user
,
os_info
.
cwd
,
new_cluster
.
bindir
,
new_cluster
.
port
,
os_info
.
user
,
os_info
.
cwd
,
...
@@ -273,14 +274,14 @@ copy_clog_xlog_xid(void)
...
@@ -273,14 +274,14 @@ copy_clog_xlog_xid(void)
/* set the next transaction id of the new cluster */
/* set the next transaction id of the new cluster */
prep_status
(
"Setting next transaction id for new cluster"
);
prep_status
(
"Setting next transaction id for new cluster"
);
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/pg_resetxlog
\"
-f -x %u
\"
%s
\"
> "
DEVNULL
SYSTEMQUOTE
,
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
();
check_ok
();
/* now reset the wal archives in the new cluster */
/* now reset the wal archives in the new cluster */
prep_status
(
"Resetting WAL archives"
);
prep_status
(
"Resetting WAL archives"
);
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/pg_resetxlog
\"
-l %u,%u,%u
\"
%s
\"
>>
\"
%s
\"
2>&1"
SYSTEMQUOTE
,
exec_prog
(
true
,
SYSTEMQUOTE
"
\"
%s/pg_resetxlog
\"
-l %u,%u,%u
\"
%s
\"
>>
\"
%s
\"
2>&1"
SYSTEMQUOTE
,
new_cluster
.
bindir
,
old_cluster
.
controldata
.
chkpnt_tli
,
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
);
new_cluster
.
pgdata
,
log
.
filename
);
check_ok
();
check_ok
();
}
}
...
...
contrib/pg_upgrade/pg_upgrade.h
View file @
07456b45
...
@@ -53,7 +53,7 @@
...
@@ -53,7 +53,7 @@
#endif
#endif
#define CLUSTERNAME(cluster) ((cluster) == CLUSTER_OLD ? "old" : "new")
#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)
&old_cluster : &new_cluster)
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
...
@@ -85,8 +85,8 @@ typedef struct
...
@@ -85,8 +85,8 @@ typedef struct
*/
*/
typedef
struct
typedef
struct
{
{
Oid
old_relfilenode
;
/* Relfilenode of the old relation */
Oid
old_relfilenode
;
/* Relfilenode of the old relation */
Oid
new_relfilenode
;
/* Relfilenode of the new relation */
Oid
new_relfilenode
;
/* Relfilenode of the new relation */
char
old_file
[
MAXPGPATH
];
char
old_file
[
MAXPGPATH
];
char
new_file
[
MAXPGPATH
];
char
new_file
[
MAXPGPATH
];
char
old_nspname
[
NAMEDATALEN
];
/* old name of the namespace */
char
old_nspname
[
NAMEDATALEN
];
/* old name of the namespace */
...
@@ -240,10 +240,11 @@ typedef struct
...
@@ -240,10 +240,11 @@ typedef struct
/*
/*
* Global variables
* Global variables
*/
*/
extern
Log
log
;
extern
Log
log
;
extern
UserOpts
user_opts
;
extern
UserOpts
user_opts
;
extern
ClusterInfo
old_cluster
,
new_cluster
;
extern
ClusterInfo
old_cluster
,
extern
OSInfo
os_info
;
new_cluster
;
extern
OSInfo
os_info
;
extern
char
scandir_file_pattern
[];
extern
char
scandir_file_pattern
[];
...
@@ -260,7 +261,7 @@ void output_completion_banner(
...
@@ -260,7 +261,7 @@ void output_completion_banner(
char
*
deletion_script_file_name
);
char
*
deletion_script_file_name
);
void
check_cluster_versions
(
void
);
void
check_cluster_versions
(
void
);
void
check_cluster_compatibility
(
bool
live_check
);
void
check_cluster_compatibility
(
bool
live_check
);
void
create_script_for_old_cluster_deletion
(
char
**
deletion_script_file_name
);
void
create_script_for_old_cluster_deletion
(
char
**
deletion_script_file_name
);
/* controldata.c */
/* controldata.c */
...
@@ -402,12 +403,12 @@ void new_9_0_populate_pg_largeobject_metadata(
...
@@ -402,12 +403,12 @@ void new_9_0_populate_pg_largeobject_metadata(
/* version_old_8_3.c */
/* version_old_8_3.c */
void
old_8_3_check_for_name_data_type_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_check_for_tsquery_usage
(
Cluster
whichCluster
);
void
old_8_3_rebuild_tsvector_tables
(
bool
check_mode
,
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
,
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
,
void
old_8_3_invalidate_bpchar_pattern_ops_indexes
(
bool
check_mode
,
Cluster
whichCluster
);
Cluster
whichCluster
);
char
*
old_8_3_create_sequence_script
(
Cluster
whichCluster
);
char
*
old_8_3_create_sequence_script
(
Cluster
whichCluster
);
contrib/pg_upgrade/relfilenode.c
View file @
07456b45
...
@@ -63,7 +63,7 @@ transfer_all_new_dbs(DbInfoArr *olddb_arr,
...
@@ -63,7 +63,7 @@ transfer_all_new_dbs(DbInfoArr *olddb_arr,
}
}
}
}
prep_status
(
""
);
/* in case nothing printed */
prep_status
(
""
);
/* in case nothing printed */
check_ok
();
check_ok
();
return
msg
;
return
msg
;
...
@@ -122,9 +122,9 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
...
@@ -122,9 +122,9 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
/* Copying files might take some time, so give feedback. */
/* Copying files might take some time, so give feedback. */
snprintf
(
old_file
,
sizeof
(
old_file
),
"%s/%u"
,
maps
[
mapnum
].
old_file
,
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
,
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
);
pg_log
(
PG_REPORT
,
OVERWRITE_MESSAGE
,
old_file
);
/*
/*
...
@@ -142,7 +142,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
...
@@ -142,7 +142,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
* Now copy/link any fsm and vm files, if they exist
* Now copy/link any fsm and vm files, if they exist
*/
*/
snprintf
(
scandir_file_pattern
,
sizeof
(
scandir_file_pattern
),
"%u_"
,
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
);
numFiles
=
pg_scandir
(
maps
[
mapnum
].
old_file
,
&
namelist
,
dir_matching_filenames
);
while
(
numFiles
--
)
while
(
numFiles
--
)
...
@@ -150,7 +150,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
...
@@ -150,7 +150,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
snprintf
(
old_file
,
sizeof
(
old_file
),
"%s/%s"
,
maps
[
mapnum
].
old_file
,
snprintf
(
old_file
,
sizeof
(
old_file
),
"%s/%s"
,
maps
[
mapnum
].
old_file
,
namelist
[
numFiles
]
->
d_name
);
namelist
[
numFiles
]
->
d_name
);
snprintf
(
new_file
,
sizeof
(
new_file
),
"%s/%u%s"
,
maps
[
mapnum
].
new_file
,
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
);
unlink
(
new_file
);
transfer_relfile
(
pageConverter
,
old_file
,
new_file
,
transfer_relfile
(
pageConverter
,
old_file
,
new_file
,
...
@@ -171,7 +171,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
...
@@ -171,7 +171,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
* copied.
* copied.
*/
*/
snprintf
(
scandir_file_pattern
,
sizeof
(
scandir_file_pattern
),
"%u."
,
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
);
numFiles
=
pg_scandir
(
maps
[
mapnum
].
old_file
,
&
namelist
,
dir_matching_filenames
);
while
(
numFiles
--
)
while
(
numFiles
--
)
...
@@ -179,7 +179,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
...
@@ -179,7 +179,7 @@ transfer_single_new_db(pageCnvCtx *pageConverter,
snprintf
(
old_file
,
sizeof
(
old_file
),
"%s/%s"
,
maps
[
mapnum
].
old_file
,
snprintf
(
old_file
,
sizeof
(
old_file
),
"%s/%s"
,
maps
[
mapnum
].
old_file
,
namelist
[
numFiles
]
->
d_name
);
namelist
[
numFiles
]
->
d_name
);
snprintf
(
new_file
,
sizeof
(
new_file
),
"%s/%u%s"
,
maps
[
mapnum
].
new_file
,
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
);
unlink
(
new_file
);
transfer_relfile
(
pageConverter
,
old_file
,
new_file
,
transfer_relfile
(
pageConverter
,
old_file
,
new_file
,
...
...
contrib/pg_upgrade/server.c
View file @
07456b45
...
@@ -36,7 +36,7 @@ connectToServer(const char *db_name,
...
@@ -36,7 +36,7 @@ connectToServer(const char *db_name,
PGconn
*
conn
;
PGconn
*
conn
;
snprintf
(
connectString
,
sizeof
(
connectString
),
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
);
conn
=
PQconnectdb
(
connectString
);
...
@@ -175,8 +175,8 @@ start_postmaster(Cluster whichCluster, bool quiet)
...
@@ -175,8 +175,8 @@ start_postmaster(Cluster whichCluster, bool quiet)
/*
/*
* On Win32, we can't send both pg_upgrade output and pg_ctl output to the
* 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
* 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
* because it is being used by another process." so we have to send all
* output to 'nul'.
* o
ther o
utput to 'nul'.
*/
*/
snprintf
(
cmd
,
sizeof
(
cmd
),
snprintf
(
cmd
,
sizeof
(
cmd
),
SYSTEMQUOTE
"
\"
%s/pg_ctl
\"
-l
\"
%s
\"
-D
\"
%s
\"
"
SYSTEMQUOTE
"
\"
%s/pg_ctl
\"
-l
\"
%s
\"
-D
\"
%s
\"
"
...
@@ -260,7 +260,7 @@ test_server_conn(int timeout, Cluster whichCluster)
...
@@ -260,7 +260,7 @@ test_server_conn(int timeout, Cluster whichCluster)
bool
ret
=
false
;
bool
ret
=
false
;
snprintf
(
con_opts
,
sizeof
(
con_opts
),
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
++
)
for
(
tries
=
0
;
tries
<
timeout
;
tries
++
)
{
{
...
...
contrib/pg_upgrade/tablespace.c
View file @
07456b45
...
@@ -23,7 +23,7 @@ init_tablespaces(void)
...
@@ -23,7 +23,7 @@ init_tablespaces(void)
set_tablespace_directory_suffix
(
CLUSTER_NEW
);
set_tablespace_directory_suffix
(
CLUSTER_NEW
);
if
(
os_info
.
num_tablespaces
>
0
&&
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
,
pg_log
(
PG_FATAL
,
"Cannot migrate to/from the same system catalog version when
\n
"
"Cannot migrate to/from the same system catalog version when
\n
"
"using tablespaces.
\n
"
);
"using tablespaces.
\n
"
);
...
@@ -52,7 +52,7 @@ get_tablespace_paths(void)
...
@@ -52,7 +52,7 @@ get_tablespace_paths(void)
if
((
os_info
.
num_tablespaces
=
PQntuples
(
res
))
!=
0
)
if
((
os_info
.
num_tablespaces
=
PQntuples
(
res
))
!=
0
)
os_info
.
tablespaces
=
(
char
**
)
pg_malloc
(
os_info
.
tablespaces
=
(
char
**
)
pg_malloc
(
os_info
.
num_tablespaces
*
sizeof
(
char
*
));
os_info
.
num_tablespaces
*
sizeof
(
char
*
));
else
else
os_info
.
tablespaces
=
NULL
;
os_info
.
tablespaces
=
NULL
;
...
@@ -81,8 +81,8 @@ set_tablespace_directory_suffix(Cluster whichCluster)
...
@@ -81,8 +81,8 @@ set_tablespace_directory_suffix(Cluster whichCluster)
{
{
/* This cluster has a version-specific subdirectory */
/* This cluster has a version-specific subdirectory */
active_cluster
->
tablespace_suffix
=
pg_malloc
(
4
+
active_cluster
->
tablespace_suffix
=
pg_malloc
(
4
+
strlen
(
active_cluster
->
major_version_str
)
+
strlen
(
active_cluster
->
major_version_str
)
+
10
/* OIDCHARS */
+
1
);
10
/* OIDCHARS */
+
1
);
/* The leading slash is needed to start a new directory. */
/* The leading slash is needed to start a new directory. */
sprintf
(
active_cluster
->
tablespace_suffix
,
"/PG_%s_%d"
,
active_cluster
->
major_version_str
,
sprintf
(
active_cluster
->
tablespace_suffix
,
"/PG_%s_%d"
,
active_cluster
->
major_version_str
,
...
...
contrib/pg_upgrade/version_old_8_3.c
View file @
07456b45
...
@@ -293,8 +293,8 @@ old_8_3_rebuild_tsvector_tables(bool check_mode,
...
@@ -293,8 +293,8 @@ old_8_3_rebuild_tsvector_tables(bool check_mode,
if
(
strlen
(
old_nspname
)
!=
0
||
strlen
(
old_relname
)
!=
0
)
if
(
strlen
(
old_nspname
)
!=
0
||
strlen
(
old_relname
)
!=
0
)
fprintf
(
script
,
";
\n\n
"
);
fprintf
(
script
,
";
\n\n
"
);
fprintf
(
script
,
"ALTER TABLE %s.%s
\n
"
,
fprintf
(
script
,
"ALTER TABLE %s.%s
\n
"
,
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_nspname
)),
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_nspname
)),
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_relname
)));
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_relname
)));
}
}
else
else
fprintf
(
script
,
",
\n
"
);
fprintf
(
script
,
",
\n
"
);
...
@@ -304,8 +304,8 @@ old_8_3_rebuild_tsvector_tables(bool check_mode,
...
@@ -304,8 +304,8 @@ old_8_3_rebuild_tsvector_tables(bool check_mode,
fprintf
(
script
,
"ALTER COLUMN %s "
fprintf
(
script
,
"ALTER COLUMN %s "
/* This could have been a custom conversion function call. */
/* This could have been a custom conversion function call. */
"TYPE pg_catalog.tsvector USING %s::pg_catalog.text::pg_catalog.tsvector"
,
"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
)
if
(
strlen
(
old_nspname
)
!=
0
||
strlen
(
old_relname
)
!=
0
)
...
@@ -407,8 +407,8 @@ old_8_3_invalidate_hash_gin_indexes(bool check_mode,
...
@@ -407,8 +407,8 @@ old_8_3_invalidate_hash_gin_indexes(bool check_mode,
db_used
=
true
;
db_used
=
true
;
}
}
fprintf
(
script
,
"REINDEX INDEX %s.%s;
\n
"
,
fprintf
(
script
,
"REINDEX INDEX %s.%s;
\n
"
,
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_nspname
)),
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_nspname
)),
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_relname
)));
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_relname
)));
}
}
}
}
...
@@ -532,8 +532,8 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(bool check_mode,
...
@@ -532,8 +532,8 @@ old_8_3_invalidate_bpchar_pattern_ops_indexes(bool check_mode,
db_used
=
true
;
db_used
=
true
;
}
}
fprintf
(
script
,
"REINDEX INDEX %s.%s;
\n
"
,
fprintf
(
script
,
"REINDEX INDEX %s.%s;
\n
"
,
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_nspname
)),
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_nspname
)),
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_relname
)));
quote_identifier
(
PQgetvalue
(
res
,
rowno
,
i_relname
)));
}
}
}
}
...
@@ -669,7 +669,7 @@ old_8_3_create_sequence_script(Cluster whichCluster)
...
@@ -669,7 +669,7 @@ old_8_3_create_sequence_script(Cluster whichCluster)
i_is_called
=
PQfnumber
(
seq_res
,
"is_called"
);
i_is_called
=
PQfnumber
(
seq_res
,
"is_called"
);
fprintf
(
script
,
"SELECT setval('%s.%s', %s, '%s');
\n
"
,
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
));
PQgetvalue
(
seq_res
,
0
,
i_last_value
),
PQgetvalue
(
seq_res
,
0
,
i_is_called
));
PQclear
(
seq_res
);
PQclear
(
seq_res
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment