Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
c419c224
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c419c224
编写于
4月 09, 2002
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update pg_upgrade for 7.3.
上级
7a48acbf
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
19 addition
and
85 deletion
+19
-85
contrib/pg_upgrade/pg_upgrade
contrib/pg_upgrade/pg_upgrade
+19
-85
未找到文件。
contrib/pg_upgrade/pg_upgrade
浏览文件 @
c419c224
...
...
@@ -3,7 +3,7 @@
# pg_upgrade: update a database without needing a full dump/reload cycle.
# CAUTION: Read the manual page before trying to use this!
# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.1
2 2002/02/11 15:19:33
momjian Exp $
# $Header: /cvsroot/pgsql/contrib/pg_upgrade/Attic/pg_upgrade,v 1.1
3 2002/04/09 18:07:24
momjian Exp $
#
# To migrate this to newer versions of PostgreSQL:
# 1) Update the version numbers at the top of the file
...
...
@@ -14,8 +14,8 @@
#set -x
# UPGRADE_VERSION is the expected old database version
UPGRADE_VERSION
=
"7.
1
"
CUR_VERSION
=
"7.
2
"
UPGRADE_VERSION
=
"7.
2
"
CUR_VERSION
=
"7.
3
"
# Set this to "Y" to enable this program
ENABLE
=
"Y"
...
...
@@ -75,6 +75,7 @@ fi
# Strip off the trailing directory name and store our data there
# in the hope we are in the same filesystem so 'mv 'works.
INFODIR
=
`
dirname
"
$PGDATA
"
`
/pg_upgrade_info
SAVEDATA
=
"
$INFODIR
"
/data
...
...
@@ -88,14 +89,8 @@ make_dbobjoidmap()
FROM pg_class
WHERE relkind = 'r' OR
relkind = 'i' OR
relkind = 't'"
# Don't move over 7.1 int4 sequences; use setval() file.
# Sequence XIDs changed from 7.2beta4 to beta5; don't copy them.
if
[
"
$SRC_VERSION
"
!=
"7.1"
-a
\
"
$SRC_VERSION
"
!=
"7.2"
]
then
QUERY
=
"
$QUERY
OR relkind = 'S';"
;
QUERY
=
"
$QUERY
;"
fi
relkind = 'S' OR
relkind = 't';"
psql
-d
"
$DB
"
-At
-F
' '
-c
"
$QUERY
"
|
while
read
RELNAME_OID
...
...
@@ -213,28 +208,7 @@ then
# Dump schema
pg_dumpall
-s
|
awk
-F
' *'
'
{
# Modify sequences with int8 maximums if we are upgrading from 7.1.
if ("'
"
$SRC_VERSION
"
'" == "7.1" &&
$1 == "CREATE" &&
$2 == "SEQUENCE" &&
# handle OS rounding
$9 >= 2147483646 &&
$9 <= 2147483648)
{
for(i=1; i <= NF; i++)
{
if (i != 9)
printf "%s ", $i;
else
printf "%s ", "9223372036854775807";
}
print "";
}
else print $0;
}'
>
"
$INFODIR
"
/schema
pg_dumpall
-s
>
"
$INFODIR
"
/schema
if
[
$?
-ne
0
]
then
echo
"Can not dump schema. Exiting."
1>&2
exit
1
...
...
@@ -244,32 +218,6 @@ then
make_dboidmap
>
"
$INFODIR
"
/dboidmap
||
exit
"
$?
"
make_dbobjoidmap
>
"
$INFODIR
"
/dbobjoidmap
||
exit
"
$?
"
# Generate setval() script for 7.1 because it has int4 sequences
# Sequence XIDs changed from 7.2beta4 to beta5 so we have to recreate them too.
# Not required for 7.2beta5 and later, but it can't hurt.
if
[
"
$SRC_VERSION
"
=
"7.1"
-o
\
"
$SRC_VERSION
"
=
"7.2"
]
then
psql
-d
template1
-At
-c
"SELECT datname FROM pg_database"
|
grep
-v
'^template0$'
|
while
read
DB
do
# We use awk as a portable way to output a backslash
awk
'BEGIN {print "\\connect '
"
$DB
"
'"}'
psql
-d
"
$DB
"
-At
-c
"
SELECT relname
FROM pg_class
WHERE relkind = 'S';"
|
while
read
SEQUENCE
do
VALUE
=
`
psql
-d
"
$DB
"
-At
-c
"SELECT last_value
FROM
\"
$SEQUENCE
\"
;"
`
echo
"SELECT setval ('
$SEQUENCE
',
$VALUE
, true);"
done
done
>
"
$INFODIR
"
/setval
else
rm
-f
"
$INFODIR
"
/setval
fi
# Vacuum all databases to remove exipired rows.
# We will lose our transaction log file during the upgrade so we
# have to do this.
...
...
@@ -375,14 +323,7 @@ then echo "Old version of pg_resetxlog found in path." 1>&2
exit
1
fi
# If the XID is > 2 billion, 7.1 database will have non-frozen XID's in
# low numbers, and 7.2 will think they are in the future --- bad.
SRC_XID
=
`
pg_resetxlog
-n
"
$SAVEDATA
"
|
grep
"NextXID"
|
awk
-F
' *'
'{print $4}'
`
if
[
"
$SRC_VERSION
"
=
"7.1"
-a
"
$SRC_XID
"
-gt
2000000000
]
then
echo
"XID too high for
$BASENAME
. Exiting."
1>&2
exit
1
fi
DST_XID
=
`
pg_resetxlog
-n
"
$PGDATA
"
|
grep
"NextXID"
|
awk
-F
' *'
'{print $4}'
`
# compare locales to make sure they match
...
...
@@ -418,16 +359,6 @@ fi
echo
"Input script completed, fixing row commit statuses..."
# XXX do we still need this?
# Now vacuum each result database because our movement of transaction log
# causes some committed transactions to appear as non-committed
vacuumdb
-a
if
[
$?
-ne
0
]
then
echo
"There were errors during VACUUM. Exiting."
1>&2
exit
1
fi
# Generate mappings for new database
make_dboidmap
>
/tmp/
$$
.dboidmap
||
exit
"
$?
"
make_dbobjoidmap
>
/tmp/
$$
.dbobjoidmap
||
exit
"
$?
"
...
...
@@ -508,6 +439,11 @@ fi
rm
-r
"
$PGDATA
"
/pg_xlog
mv
-f
"
$SAVEDATA
"
/pg_xlog
"
$PGDATA
"
# Move over old clog
rm
-r
"
$PGDATA
"
/pg_clog
mv
-f
"
$SAVEDATA
"
/pg_clog
"
$PGDATA
"
# Set last log file id and segment from old database
LOG_ID
=
`
pg_resetxlog
-n
"
$SAVEDATA
"
|
grep
"Current log file id:"
|
...
...
@@ -539,16 +475,14 @@ then echo "Unable to restart database server. Exiting." 1>&2
exit
1
fi
# Set sequence values for 7.1-version sequences, which were int4.
# Now that we have moved the WAL/transaction log files, vacuum again to
# mark install rows with fixed transaction ids to prevent problems on xid
# wraparound.
if
[
"
$SRC_VERSION
"
=
"7.1"
-o
\
"
$SRC_VERSION
"
=
"7.2"
]
then
echo
"Set sequence values..."
psql
-d
template1
-At
<
"
$INFODIR
"
/setval
if
[
$?
-ne
0
]
then
echo
"There were errors during int4 sequence restoration. Exiting."
1>&2
exit
1
fi
vacuumdb
-a
if
[
$?
-ne
0
]
then
echo
"There were errors during VACUUM. Exiting."
1>&2
exit
1
fi
echo
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录