Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
d600c1db
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,发现更多精彩内容 >>
提交
d600c1db
编写于
1月 19, 2005
作者:
N
Neil Conway
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add some basic regression tests for refcursors in PL/PgSQL.
上级
3fc86c0f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
126 addition
and
0 deletion
+126
-0
src/test/regress/expected/plpgsql.out
src/test/regress/expected/plpgsql.out
+70
-0
src/test/regress/sql/plpgsql.sql
src/test/regress/sql/plpgsql.sql
+56
-0
未找到文件。
src/test/regress/expected/plpgsql.out
浏览文件 @
d600c1db
...
...
@@ -2103,3 +2103,73 @@ select sp_add_user('user3');
drop function sp_add_user(text);
drop function sp_id_user(text);
--
-- tests for refcursors
--
create table rc_test (a int, b int);
copy rc_test from stdin;
create function return_refcursor(rc refcursor) returns refcursor as $$
begin
open rc for select a from rc_test;
return rc;
end
$$ language 'plpgsql';
create function refcursor_test1(refcursor) returns refcursor as $$
begin
perform return_refcursor($1);
return $1;
end
$$ language 'plpgsql';
begin;
select refcursor_test1('test1');
refcursor_test1
-----------------
test1
(1 row)
fetch next from test1;
a
---
5
(1 row)
select refcursor_test1('test2');
refcursor_test1
-----------------
test2
(1 row)
fetch all from test2;
a
-----
5
50
500
(3 rows)
commit;
-- should fail
fetch next from test1;
ERROR: cursor "test1" does not exist
create function refcursor_test2(int) returns boolean as $$
declare
c1 cursor (param integer) for select * from rc_test where a > param;
nonsense record;
begin
open c1($1);
fetch c1 into nonsense;
close c1;
if found then
return true;
else
return false;
end if;
end
$$ language 'plpgsql';
select refcursor_test2(20000) as "Should be false",
refcursor_test2(20) as "Should be true";
Should be false | Should be true
-----------------+----------------
f | t
(1 row)
src/test/regress/sql/plpgsql.sql
浏览文件 @
d600c1db
...
...
@@ -1807,3 +1807,59 @@ select sp_add_user('user3');
drop
function
sp_add_user
(
text
);
drop
function
sp_id_user
(
text
);
--
-- tests for refcursors
--
create
table
rc_test
(
a
int
,
b
int
);
copy
rc_test
from
stdin
;
5
10
50
100
500
1000
\
.
create
function
return_refcursor
(
rc
refcursor
)
returns
refcursor
as
$$
begin
open
rc
for
select
a
from
rc_test
;
return
rc
;
end
$$
language
'plpgsql'
;
create
function
refcursor_test1
(
refcursor
)
returns
refcursor
as
$$
begin
perform
return_refcursor
(
$
1
);
return
$
1
;
end
$$
language
'plpgsql'
;
begin
;
select
refcursor_test1
(
'test1'
);
fetch
next
from
test1
;
select
refcursor_test1
(
'test2'
);
fetch
all
from
test2
;
commit
;
-- should fail
fetch
next
from
test1
;
create
function
refcursor_test2
(
int
)
returns
boolean
as
$$
declare
c1
cursor
(
param
integer
)
for
select
*
from
rc_test
where
a
>
param
;
nonsense
record
;
begin
open
c1
(
$
1
);
fetch
c1
into
nonsense
;
close
c1
;
if
found
then
return
true
;
else
return
false
;
end
if
;
end
$$
language
'plpgsql'
;
select
refcursor_test2
(
20000
)
as
"Should be false"
,
refcursor_test2
(
20
)
as
"Should be true"
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录