Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit174bc0c

Browse files
committed
Tests for CHECK/DEFAULT
1 parent3751b49 commit174bc0c

File tree

9 files changed

+226
-8
lines changed

9 files changed

+226
-8
lines changed

‎src/test/regress/data/constrf.data

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\N\N\N

‎src/test/regress/data/constro.data

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\N\N\N
2+
\N\N\N
3+
\N\N\N

‎src/test/regress/expected/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/test/regress/expected/Attic/Makefile,v 1.1 1997/04/26 05:44:17scrappy Exp $
10+
# $Header: /cvsroot/pgsql/src/test/regress/expected/Attic/Makefile,v 1.2 1997/08/28 04:49:17vadim Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

14-
CLFILES=create_function_1.out create_function_2.out copy.out
14+
CLFILES=create_function_1.out create_function_2.out copy.out constraints.out
1515

1616
clean:
1717
rm -f$(CLFILES)

‎src/test/regress/input/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/test/regress/input/Attic/Makefile,v 1.5 1997/05/05 06:53:31 vadim Exp $
10+
# $Header: /cvsroot/pgsql/src/test/regress/input/Attic/Makefile,v 1.6 1997/08/28 04:49:18 vadim Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -21,7 +21,8 @@ include ../../../Makefile.global
2121
INFILES= copy.sql\
2222
create_function_1.sql\
2323
create_function_2.sql\
24-
misc.sql
24+
misc.sql\
25+
constraints.sql
2526

2627
all:$(INFILES)
2728

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
--
2+
-- Check constraints
3+
--
4+
5+
-- Check constraints on INSERT
6+
drop sequence seq;
7+
drop table test;
8+
create sequence seq;
9+
create table test (x int default nextval ( 'seq') ,
10+
y text default '-NULL-', z int default -1 * currval('seq') )
11+
constraint test1 check (x > 3 and y <> 'check failed' and x < 8 ),
12+
check x + z = 0;
13+
insert into test values (null, null, null);
14+
insert into test values (null, null, -2);
15+
select * from test;
16+
select nextval('seq');
17+
insert into test values (null, null, null);
18+
insert into test values (1, null, -2);
19+
insert into test values (7, null, -7);
20+
insert into test values (5, 'check failed', -5);
21+
insert into test values (7, '!check failed', -7);
22+
insert into test values (null, null, null);
23+
select * from test;
24+
insert into test values (null, 'check failed', 5);
25+
insert into test values (5, 'check failed', null);
26+
insert into test values (5, '!check failed', null);
27+
insert into test values (null, null, null);
28+
select * from test;
29+
insert into test values (null, null, null);
30+
select currval('seq');
31+
32+
-- Check constraints on INSERT INTO
33+
34+
drop table test;
35+
drop sequence seq;
36+
create sequence seq start 4;
37+
create table dummy (xd int, yd text, zd int);
38+
39+
create table test (x int default nextval ( 'seq') ,
40+
y text default '-NULL-', z int default -1 * currval('seq') )
41+
constraint test1 check (x > 3 and y <> 'check failed' and x < 7 ), check
42+
x + z = 0;
43+
44+
select nextval('seq');
45+
insert into dummy values (null, null, null);
46+
insert into dummy values (5, '!check failed', null);
47+
insert into dummy values (null, 'try again', null);
48+
insert into test select * from dummy;
49+
select * from test;
50+
insert into test select * from dummy where yd = 'try again';
51+
52+
-- Check constraints on UPDATE
53+
update test set x = null where x = 6;
54+
select currval('seq');
55+
56+
-- Check constraints on COPY FROM
57+
drop table test;
58+
drop sequence seq;
59+
create sequence seq start 4;
60+
create table test (x int default nextval ( 'seq') ,
61+
y text default '-NULL-', z int default -1 * currval('seq') )
62+
constraint test1 check (x > 3 and y <> 'check failed' and x < 7 ), check
63+
x + z = 0;
64+
copy test from '_OBJWD_/data/constro.data';
65+
select * from test;
66+
copy test from '_OBJWD_/data/constrf.data';
67+
select * from test;
68+
select nextval('seq') - 1 as currval;
69+
70+
-- Clean up
71+
drop sequence seq;
72+
drop table test;

‎src/test/regress/output/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/test/regress/output/Attic/Makefile,v 1.7 1997/05/05 06:52:58 vadim Exp $
10+
# $Header: /cvsroot/pgsql/src/test/regress/output/Attic/Makefile,v 1.8 1997/08/28 04:49:23 vadim Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

@@ -21,7 +21,8 @@ include ../../../Makefile.global
2121
INFILES= copy.out\
2222
create_function_1.out\
2323
create_function_2.out\
24-
misc.out
24+
misc.out\
25+
constraints.out
2526

2627
all:$(INFILES)
2728

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
QUERY: drop sequence seq;
2+
WARN:Relation seq Does Not Exist!
3+
QUERY: drop table test;
4+
WARN:Relation test Does Not Exist!
5+
QUERY: create sequence seq;
6+
QUERY: create table test (x int default nextval ( 'seq') ,
7+
y text default '-NULL-', z int default -1 * currval('seq') )
8+
constraint test1 check (x > 3 and y <> 'check failed' and x < 8 ),
9+
check x + z = 0;
10+
QUERY: insert into test values (null, null, null);
11+
WARN:ExecAppend: rejected due to CHECK constraint test1
12+
QUERY: insert into test values (null, null, -2);
13+
WARN:ExecAppend: rejected due to CHECK constraint test1
14+
QUERY: select * from test;
15+
x|y|z
16+
-+-+-
17+
(0 rows)
18+
19+
QUERY: select nextval('seq');
20+
nextval
21+
-------
22+
3
23+
(1 row)
24+
25+
QUERY: insert into test values (null, null, null);
26+
QUERY: insert into test values (1, null, -2);
27+
WARN:ExecAppend: rejected due to CHECK constraint $2
28+
QUERY: insert into test values (7, null, -7);
29+
QUERY: insert into test values (5, 'check failed', -5);
30+
WARN:ExecAppend: rejected due to CHECK constraint test1
31+
QUERY: insert into test values (7, '!check failed', -7);
32+
QUERY: insert into test values (null, null, null);
33+
QUERY: select * from test;
34+
x|y | z
35+
-+-------------+--
36+
4|-NULL- |-4
37+
7|-NULL- |-7
38+
7|!check failed|-7
39+
5|-NULL- |-5
40+
(4 rows)
41+
42+
QUERY: insert into test values (null, 'check failed', 5);
43+
WARN:ExecAppend: rejected due to CHECK constraint $2
44+
QUERY: insert into test values (5, 'check failed', null);
45+
WARN:ExecAppend: rejected due to CHECK constraint $2
46+
QUERY: insert into test values (5, '!check failed', null);
47+
WARN:ExecAppend: rejected due to CHECK constraint $2
48+
QUERY: insert into test values (null, null, null);
49+
QUERY: select * from test;
50+
x|y | z
51+
-+-------------+--
52+
4|-NULL- |-4
53+
7|-NULL- |-7
54+
7|!check failed|-7
55+
5|-NULL- |-5
56+
7|-NULL- |-7
57+
(5 rows)
58+
59+
QUERY: insert into test values (null, null, null);
60+
WARN:ExecAppend: rejected due to CHECK constraint test1
61+
QUERY: select currval('seq');
62+
currval
63+
-------
64+
8
65+
(1 row)
66+
67+
QUERY: drop table test;
68+
QUERY: drop sequence seq;
69+
QUERY: create sequence seq start 4;
70+
QUERY: create table dummy (xd int, yd text, zd int);
71+
QUERY: create table test (x int default nextval ( 'seq') ,
72+
y text default '-NULL-', z int default -1 * currval('seq') )
73+
constraint test1 check (x > 3 and y <> 'check failed' and x < 7 ), check
74+
x + z = 0;
75+
QUERY: select nextval('seq');
76+
NOTICE:seq.nextval: sequence was re-created
77+
78+
nextval
79+
-------
80+
4
81+
(1 row)
82+
83+
QUERY: insert into dummy values (null, null, null);
84+
QUERY: insert into dummy values (5, '!check failed', null);
85+
QUERY: insert into dummy values (null, 'try again', null);
86+
QUERY: insert into test select * from dummy;
87+
QUERY: select * from test;
88+
x|y | z
89+
-+-------------+--
90+
5|-NULL- |-5
91+
5|!check failed|-5
92+
6|try again |-6
93+
(3 rows)
94+
95+
QUERY: insert into test select * from dummy where yd = 'try again';
96+
WARN:ExecAppend: rejected due to CHECK constraint test1
97+
QUERY: update test set x = null where x = 6;
98+
WARN:ExecReplace: rejected due to CHECK constraint $2
99+
QUERY: select currval('seq');
100+
currval
101+
-------
102+
8
103+
(1 row)
104+
105+
QUERY: drop table test;
106+
QUERY: drop sequence seq;
107+
QUERY: create sequence seq start 4;
108+
QUERY: create table test (x int default nextval ( 'seq') ,
109+
y text default '-NULL-', z int default -1 * currval('seq') )
110+
constraint test1 check (x > 3 and y <> 'check failed' and x < 7 ), check
111+
x + z = 0;
112+
QUERY: copy test from '_OBJWD_/data/constro.data';
113+
NOTICE:seq.nextval: sequence was re-created
114+
QUERY: select * from test;
115+
x|y | z
116+
-+------+--
117+
4|-NULL-|-4
118+
5|-NULL-|-5
119+
6|-NULL-|-6
120+
(3 rows)
121+
122+
QUERY: copy test from '_OBJWD_/data/constrf.data';
123+
WARN:CopyFrom: rejected due to CHECK constraint test1
124+
QUERY: select * from test;
125+
x|y | z
126+
-+------+--
127+
4|-NULL-|-4
128+
5|-NULL-|-5
129+
6|-NULL-|-6
130+
(3 rows)
131+
132+
QUERY: select nextval('seq') - 1 as currval;
133+
currval
134+
-------
135+
7
136+
(1 row)
137+
138+
QUERY: drop sequence seq;
139+
QUERY: drop table test;

‎src/test/regress/sql/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#
88
#
99
# IDENTIFICATION
10-
# $Header: /cvsroot/pgsql/src/test/regress/sql/Attic/Makefile,v 1.2 1997/04/27 02:58:26 scrappy Exp $
10+
# $Header: /cvsroot/pgsql/src/test/regress/sql/Attic/Makefile,v 1.3 1997/08/28 04:49:31 vadim Exp $
1111
#
1212
#-------------------------------------------------------------------------
1313

14-
CLFILES=create_function_1.sql create_function_2.sql copy.sql misc.sql
14+
CLFILES=create_function_1.sql create_function_2.sql copy.sql misc.sql constraints.sql
1515

1616
clean:
1717
rm -f$(CLFILES)

‎src/test/regress/sql/tests

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ create_function_1
3131
create_type
3232
create_table
3333
create_function_2
34+
constraints
3435
copy
3536
create_misc
3637
create_aggregate

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp