Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
de432ce3
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,发现更多精彩内容 >>
提交
de432ce3
编写于
1月 13, 2003
作者:
H
Hiroshi Inoue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change Adjust_lo_type() so that it doesn't cause an error
even when cast functions are allowed to be volatile.
上级
9e66243c
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
71 addition
and
54 deletion
+71
-54
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_backup_archiver.c
+71
-54
未找到文件。
src/bin/pg_dump/pg_backup_archiver.c
浏览文件 @
de432ce3
...
...
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.6
4 2003/01/03 18:05:02
inoue Exp $
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.6
5 2003/01/13 04:28:55
inoue Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -123,82 +123,99 @@ CloseArchive(Archive *AHX)
}
/*
* Adjust lo type in contrib for 7.3 or later.
* There must be a cast between lo and oid.
* This function repairs a slip when upgrading PG cast
* mechanism from 7.2 or earlier to 7.3 or later.
* The casts between lo and oid are needed when retrieving
* lo type data in FixupBlobRefs and so adjust lo type in
* contrib before processing FixupBlobRefs.
*/
static
void
Adjust_lo_type
(
ArchiveHandle
*
AH
)
{
PGresult
*
res
;
int
nTuples
;
/*
* The cast function lo(oid) should be immutable.
* If it's volatile it should be changed to
* be immutable and the cast (oid as lo)
* should be created.
* First check the existence of the cast oid as lo.
*/
res
=
PQexec
(
AH
->
blobConnection
,
"begin;"
"update pg_proc set provolatile = 'i'"
res
=
PQexec
(
AH
->
blobConnection
,
"select 1 from pg_cast where"
" castsource in (select oid from pg_type where typname = 'oid')"
" and casttarget in (select oid from pg_type where typname = 'lo')"
);
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_TUPLES_OK
)
die_horribly
(
AH
,
modulename
,
"error while checking the cast oid as lo
\n
"
);
nTuples
=
PQntuples
(
res
);
PQclear
(
res
);
if
(
nTuples
==
0
)
{
/*
* Check the existence of the cast function lo(oid)
* and change it to be IMMUTABLE.
*/
res
=
PQexec
(
AH
->
blobConnection
,
"update pg_proc set provolatile = 'i'"
" where proname = 'lo'"
" and pronargs = 1"
" and provolatile = 'v'"
" and prorettype in (select oid from pg_type where typname = 'lo')"
" and proargtypes[0] in (select oid from pg_type where typname = 'oid')"
);
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_COMMAND_OK
)
die_horribly
(
AH
,
modulename
,
"could not adjust lo(oid) function"
);
if
(
strcmp
(
PQcmdTuples
(
res
),
"1"
)
==
0
)
{
PQclear
(
res
);
/* create cast */
res
=
PQexec
(
AH
->
blobConnection
,
"create cast"
" (oid as lo) with function lo(oid) as implicit;commit"
);
if
(
!
res
)
die_horribly
(
AH
,
modulename
,
"couldn't create cast (oid as lo)"
);
}
else
{
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_COMMAND_OK
)
die_horribly
(
AH
,
modulename
,
"could not adjust lo(oid) function
\n
"
);
nTuples
=
atoi
(
PQcmdTuples
(
res
));
PQclear
(
res
);
/* The change is needless */
res
=
PQexec
(
AH
->
blobConnection
,
"rollback"
);
if
(
!
res
)
die_horribly
(
AH
,
modulename
,
"rollback error"
);
if
(
nTuples
==
1
)
{
/*
* The cast function lo(oid) exists and
* then create the correspoding cast.
*/
res
=
PQexec
(
AH
->
blobConnection
,
"create cast"
" (oid as lo) with function lo(oid) as implicit"
);
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_COMMAND_OK
)
die_horribly
(
AH
,
modulename
,
"couldn't create cast (oid as lo)
\n
"
);
PQclear
(
res
);
}
}
PQclear
(
res
);
/*
* The cast function oid(lo) should be immutable.
* If it's volatile it should be changed to
* be immutable and the cast (lo as oid)
* should be created.
/*
* Also check the existence of the cast lo as oid.
*/
res
=
PQexec
(
AH
->
blobConnection
,
"begin;"
"update pg_proc set provolatile = 'i'"
res
=
PQexec
(
AH
->
blobConnection
,
"select 1 from pg_cast where"
" castsource in (select oid from pg_type where typname = 'lo')"
" and casttarget in (select oid from pg_type where typname = 'oid')"
);
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_TUPLES_OK
)
die_horribly
(
AH
,
modulename
,
"error while checking the cast lo as oid
\n
"
);
nTuples
=
PQntuples
(
res
);
PQclear
(
res
);
if
(
nTuples
==
0
)
{
/*
* Check the existence of the cast function oid(lo)
* and change it to be IMMUTABLE.
*/
res
=
PQexec
(
AH
->
blobConnection
,
"update pg_proc set provolatile = 'i'"
" where proname = 'oid'"
" and provolatile = 'v'"
" and pronargs = 1"
" and prorettype in (select oid from pg_type where typname = 'oid')"
" and proargtypes[0] in (select oid from pg_type where typname = 'lo')"
);
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_COMMAND_OK
)
die_horribly
(
AH
,
modulename
,
"could not adjust oid(lo) function"
);
if
(
strcmp
(
PQcmdTuples
(
res
),
"1"
)
==
0
)
{
PQclear
(
res
);
/* create cast */
res
=
PQexec
(
AH
->
blobConnection
,
"create cast"
" (lo as oid) with function oid(lo) as implicit;commit"
);
if
(
!
res
)
die_horribly
(
AH
,
modulename
,
"couldn't create cast (lo as oid)"
);
}
else
{
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_COMMAND_OK
)
die_horribly
(
AH
,
modulename
,
"could not adjust oid(lo) function
\n
"
);
nTuples
=
atoi
(
PQcmdTuples
(
res
));
PQclear
(
res
);
/* the change is needless */
res
=
PQexec
(
AH
->
blobConnection
,
"rollback"
);
if
(
!
res
)
die_horribly
(
AH
,
modulename
,
"rollback error"
);
if
(
nTuples
==
1
)
{
/*
* The cast function oid(lo) exists and
* then create the correspoding cast.
*/
res
=
PQexec
(
AH
->
blobConnection
,
"create cast"
" (lo as oid) with function oid(lo) as implicit"
);
if
(
!
res
||
PQresultStatus
(
res
)
!=
PGRES_COMMAND_OK
)
die_horribly
(
AH
,
modulename
,
"couldn't create cast (lo as oid)
\n
"
);
PQclear
(
res
);
}
}
PQclear
(
res
);
}
/* Public */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录