Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
b8312c5f
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,发现更多精彩内容 >>
提交
b8312c5f
编写于
6月 06, 2004
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add some regression tests for composite-type operations.
上级
bb3da43e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
191 addition
and
2 deletion
+191
-2
src/test/regress/expected/rowtypes.out
src/test/regress/expected/rowtypes.out
+115
-0
src/test/regress/parallel_schedule
src/test/regress/parallel_schedule
+1
-1
src/test/regress/serial_schedule
src/test/regress/serial_schedule
+2
-1
src/test/regress/sql/rowtypes.sql
src/test/regress/sql/rowtypes.sql
+73
-0
未找到文件。
src/test/regress/expected/rowtypes.out
0 → 100644
浏览文件 @
b8312c5f
--
-- ROWTYPES
--
-- Make both a standalone composite type and a table rowtype
create type complex as (r float8, i float8);
create temp table fullname (first text, last text);
-- Nested composite
create type quad as (c1 complex, c2 complex);
-- Some simple tests of I/O conversions and row construction
select (1.1,2.2)::complex, row((3.3,4.4),(5.5,null))::quad;
row | row
-----------+------------------------
(1.1,2.2) | ("(3.3,4.4)","(5.5,)")
(1 row)
select row('Joe', 'Blow')::fullname, '(Joe,Blow)'::fullname;
row | fullname
------------+------------
(Joe,Blow) | (Joe,Blow)
(1 row)
select '(Joe,von Blow)'::fullname, '(Joe,d''Blow)'::fullname;
fullname | fullname
------------------+--------------
(Joe,"von Blow") | (Joe,d'Blow)
(1 row)
select '(Joe,"von""Blow")'::fullname, '(Joe,d\\\\Blow)'::fullname;
fullname | fullname
-------------------+-----------------
(Joe,"von""Blow") | (Joe,"d\\Blow")
(1 row)
select '(Joe,"Blow,Jr")'::fullname;
fullname
-----------------
(Joe,"Blow,Jr")
(1 row)
select '(Joe,)'::fullname; -- ok, null 2nd column
fullname
----------
(Joe,)
(1 row)
select '(Joe)'::fullname; -- bad
ERROR: malformed record literal: "(Joe)"
DETAIL: Too few columns.
select '(Joe,,)'::fullname; -- bad
ERROR: malformed record literal: "(Joe,,)"
DETAIL: Too many columns.
create temp table quadtable(f1 int, q quad);
insert into quadtable values (1, ((3.3,4.4),(5.5,6.6)));
insert into quadtable values (2, ((null,4.4),(5.5,6.6)));
select * from quadtable;
f1 | q
----+---------------------------
1 | ("(3.3,4.4)","(5.5,6.6)")
2 | ("(,4.4)","(5.5,6.6)")
(2 rows)
select f1, q.c1 from quadtable; -- fails, q is a table reference
ERROR: relation "q" does not exist
select f1, (q).c1, (qq.q).c1.i from quadtable qq;
f1 | c1 | i
----+-----------+-----
1 | (3.3,4.4) | 4.4
2 | (,4.4) | 4.4
(2 rows)
create temp table people (fn fullname, bd date);
insert into people values ('(Joe,Blow)', '1984-01-10');
select * from people;
fn | bd
------------+------------
(Joe,Blow) | 01-10-1984
(1 row)
-- at the moment this will not work due to ALTER TABLE inadequacy:
alter table fullname add column suffix text default '';
ERROR: cannot alter table "fullname" because column "people"."fn" uses its rowtype
-- but this should work:
alter table fullname add column suffix text default null;
select * from people;
fn | bd
-------------+------------
(Joe,Blow,) | 01-10-1984
(1 row)
-- This fails at the moment, would like it to work though:
update people set fn.suffix = 'Jr';
ERROR: syntax error at or near "." at character 21
LINE 1: update people set fn.suffix = 'Jr';
^
-- ugly workaround:
update people set fn = ((fn).first, (fn).last, 'III');
select * from people;
fn | bd
----------------+------------
(Joe,Blow,III) | 01-10-1984
(1 row)
-- The object here is to ensure that toasted references inside
-- composite values don't cause problems. The large f1 value will
-- be toasted inside pp, it must still work after being copied to people.
create temp table pp (f1 text);
insert into pp values (repeat('abcdefghijkl', 100000));
insert into people select ('Jim', f1, null)::fullname, current_date from pp;
select (fn).first, substr((fn).last, 1, 20), length((fn).last) from people;
first | substr | length
-------+----------------------+---------
Joe | Blow | 4
Jim | abcdefghijklabcdefgh | 1200000
(2 rows)
src/test/regress/parallel_schedule
浏览文件 @
b8312c5f
...
...
@@ -74,7 +74,7 @@ test: select_views portals_p2 rules foreign_key cluster
# The sixth group of parallel test
# ----------
# "plpgsql" cannot run concurrently with "rules"
test: limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion truncate alter_table sequence polymorphism
test: limit plpgsql copy2 temp domain rangefuncs prepare without_oid conversion truncate alter_table sequence polymorphism
rowtypes
# run stats by itself because its delay may be insufficient under heavy load
test: stats
src/test/regress/serial_schedule
浏览文件 @
b8312c5f
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.2
4 2004/01/11 04:58:17 neilc
Exp $
# $PostgreSQL: pgsql/src/test/regress/serial_schedule,v 1.2
5 2004/06/06 21:20:46 tgl
Exp $
# This should probably be in an order similar to parallel_schedule.
test: boolean
test: char
...
...
@@ -94,4 +94,5 @@ test: truncate
test: alter_table
test: sequence
test: polymorphism
test: rowtypes
test: stats
src/test/regress/sql/rowtypes.sql
0 → 100644
浏览文件 @
b8312c5f
--
-- ROWTYPES
--
-- Make both a standalone composite type and a table rowtype
create
type
complex
as
(
r
float8
,
i
float8
);
create
temp
table
fullname
(
first
text
,
last
text
);
-- Nested composite
create
type
quad
as
(
c1
complex
,
c2
complex
);
-- Some simple tests of I/O conversions and row construction
select
(
1
.
1
,
2
.
2
)::
complex
,
row
((
3
.
3
,
4
.
4
),(
5
.
5
,
null
))::
quad
;
select
row
(
'Joe'
,
'Blow'
)::
fullname
,
'(Joe,Blow)'
::
fullname
;
select
'(Joe,von Blow)'
::
fullname
,
'(Joe,d
''
Blow)'
::
fullname
;
select
'(Joe,"von""Blow")'
::
fullname
,
'(Joe,d
\\\\
Blow)'
::
fullname
;
select
'(Joe,"Blow,Jr")'
::
fullname
;
select
'(Joe,)'
::
fullname
;
-- ok, null 2nd column
select
'(Joe)'
::
fullname
;
-- bad
select
'(Joe,,)'
::
fullname
;
-- bad
create
temp
table
quadtable
(
f1
int
,
q
quad
);
insert
into
quadtable
values
(
1
,
((
3
.
3
,
4
.
4
),(
5
.
5
,
6
.
6
)));
insert
into
quadtable
values
(
2
,
((
null
,
4
.
4
),(
5
.
5
,
6
.
6
)));
select
*
from
quadtable
;
select
f1
,
q
.
c1
from
quadtable
;
-- fails, q is a table reference
select
f1
,
(
q
).
c1
,
(
qq
.
q
).
c1
.
i
from
quadtable
qq
;
create
temp
table
people
(
fn
fullname
,
bd
date
);
insert
into
people
values
(
'(Joe,Blow)'
,
'1984-01-10'
);
select
*
from
people
;
-- at the moment this will not work due to ALTER TABLE inadequacy:
alter
table
fullname
add
column
suffix
text
default
''
;
-- but this should work:
alter
table
fullname
add
column
suffix
text
default
null
;
select
*
from
people
;
-- This fails at the moment, would like it to work though:
update
people
set
fn
.
suffix
=
'Jr'
;
-- ugly workaround:
update
people
set
fn
=
((
fn
).
first
,
(
fn
).
last
,
'III'
);
select
*
from
people
;
-- The object here is to ensure that toasted references inside
-- composite values don't cause problems. The large f1 value will
-- be toasted inside pp, it must still work after being copied to people.
create
temp
table
pp
(
f1
text
);
insert
into
pp
values
(
repeat
(
'abcdefghijkl'
,
100000
));
insert
into
people
select
(
'Jim'
,
f1
,
null
)::
fullname
,
current_date
from
pp
;
select
(
fn
).
first
,
substr
((
fn
).
last
,
1
,
20
),
length
((
fn
).
last
)
from
people
;
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录