Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
cd7a3b6c
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,发现更多精彩内容 >>
提交
cd7a3b6c
编写于
9月 14, 2002
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify handling of second database for dblink tests.
上级
b66ba36b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
79 deletion
+43
-79
contrib/dblink/expected/dblink.out
contrib/dblink/expected/dblink.out
+23
-41
contrib/dblink/sql/dblink.sql
contrib/dblink/sql/dblink.sql
+20
-38
未找到文件。
contrib/dblink/expected/dblink.out
浏览文件 @
cd7a3b6c
--
--
-- First, create a slave database and define the functions.
-- First, create a slave database and define the functions and test data
-- Turn off echoing so that expected file does not depend on
-- therein.
-- contents of dblink.sql.
--
-- This initial hackery is to allow successive runs without failures.
--
--
CREATE OR REPLACE FUNCTION conditional_drop() RETURNS text AS '
DECLARE
dbname text;
BEGIN
SELECT INTO dbname datname FROM pg_database WHERE datname = ''regression_slave'';
IF FOUND THEN
DROP DATABASE regression_slave;
END IF;
RETURN ''OK'';
END;
' LANGUAGE 'plpgsql';
SELECT conditional_drop();
conditional_drop
------------------
OK
(1 row)
CREATE DATABASE regression_slave;
CREATE DATABASE regression_slave;
\connect regression_slave
\connect regression_slave
-- Turn off echoing so that expected file does not depend on
-- contents of dblink.sql.
\set ECHO none
\set ECHO none
create table foo(f1 int, f2 text, f3 text[], primary key (f1,f2));
create table foo(f1 int, f2 text, f3 text[], primary key (f1,f2));
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo'
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'foo_pkey' for table 'foo'
...
@@ -219,41 +239,3 @@ select dblink_disconnect();
...
@@ -219,41 +239,3 @@ select dblink_disconnect();
OK
OK
(1 row)
(1 row)
-- now wait for the connection to the slave to be cleared before
-- we try to drop the database
CREATE FUNCTION wait() RETURNS TEXT AS '
DECLARE
rec record;
cntr int;
BEGIN
cntr = 0;
select into rec d.datname
from pg_database d,
(select pg_stat_get_backend_dbid(pg_stat_get_backend_idset()) AS dbid) b
where d.oid = b.dbid and d.datname = ''regression_slave'';
WHILE FOUND LOOP
cntr = cntr + 1;
select into rec d.datname
from pg_database d,
(select pg_stat_get_backend_dbid(pg_stat_get_backend_idset()) AS dbid) b
where d.oid = b.dbid and d.datname = ''regression_slave'';
-- safety valve
if cntr > 1000 THEN
EXIT;
end if;
END LOOP;
RETURN ''OK'';
END;
' LANGUAGE 'plpgsql';
SELECT wait();
wait
------
OK
(1 row)
-- OK, safe to drop the slave
DROP DATABASE regression_slave;
contrib/dblink/sql/dblink.sql
浏览文件 @
cd7a3b6c
--
--
-- First, create a slave database and define the functions.
-- First, create a slave database and define the functions and test data
-- Turn off echoing so that expected file does not depend on
-- therein.
-- contents of dblink.sql.
--
-- This initial hackery is to allow successive runs without failures.
--
--
CREATE
OR
REPLACE
FUNCTION
conditional_drop
()
RETURNS
text
AS
'
DECLARE
dbname text;
BEGIN
SELECT INTO dbname datname FROM pg_database WHERE datname =
''
regression_slave
''
;
IF FOUND THEN
DROP DATABASE regression_slave;
END IF;
RETURN
''
OK
''
;
END;
'
LANGUAGE
'plpgsql'
;
SELECT
conditional_drop
();
CREATE
DATABASE
regression_slave
;
CREATE
DATABASE
regression_slave
;
\
connect
regression_slave
\
connect
regression_slave
-- Turn off echoing so that expected file does not depend on
-- contents of dblink.sql.
\
set
ECHO
none
\
set
ECHO
none
\
i
dblink
.
sql
\
i
dblink
.
sql
\
set
ECHO
all
\
set
ECHO
all
...
@@ -112,38 +129,3 @@ select * from dblink('select * from foo') as t(a int, b text, c text[]) where a
...
@@ -112,38 +129,3 @@ select * from dblink('select * from foo') as t(a int, b text, c text[]) where a
-- close the persistent connection
-- close the persistent connection
select
dblink_disconnect
();
select
dblink_disconnect
();
-- now wait for the connection to the slave to be cleared before
-- we try to drop the database
CREATE
FUNCTION
wait
()
RETURNS
TEXT
AS
'
DECLARE
rec record;
cntr int;
BEGIN
cntr = 0;
select into rec d.datname
from pg_database d,
(select pg_stat_get_backend_dbid(pg_stat_get_backend_idset()) AS dbid) b
where d.oid = b.dbid and d.datname =
''
regression_slave
''
;
WHILE FOUND LOOP
cntr = cntr + 1;
select into rec d.datname
from pg_database d,
(select pg_stat_get_backend_dbid(pg_stat_get_backend_idset()) AS dbid) b
where d.oid = b.dbid and d.datname =
''
regression_slave
''
;
-- safety valve
if cntr > 1000 THEN
EXIT;
end if;
END LOOP;
RETURN
''
OK
''
;
END;
'
LANGUAGE
'plpgsql'
;
SELECT
wait
();
-- OK, safe to drop the slave
DROP
DATABASE
regression_slave
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录