diff options
| author | Vadim B. Mikheev <vadim4o@yahoo.com> | 1997-08-28 04:49:34 +0000 |
|---|---|---|
| committer | Vadim B. Mikheev <vadim4o@yahoo.com> | 1997-08-28 04:49:34 +0000 |
| commit | 174bc0c1e7003c5ae852547c184e349df0003053 (patch) | |
| tree | 557e57c1892d86b56188db560c896de14c101343 /src/test/regress/input | |
| parent | 3751b49545d71881b93035ef8cdd1c4034f08a59 (diff) | |
| download | postgresql-174bc0c1e7003c5ae852547c184e349df0003053.tar.gz | |
Tests for CHECK/DEFAULT
Diffstat (limited to 'src/test/regress/input')
| -rw-r--r-- | src/test/regress/input/Makefile | 5 | ||||
| -rw-r--r-- | src/test/regress/input/constraints.source | 72 |
2 files changed, 75 insertions, 2 deletions
diff --git a/src/test/regress/input/Makefile b/src/test/regress/input/Makefile index 6b9e3dc41e..2d00f3ac8a 100644 --- a/src/test/regress/input/Makefile +++ b/src/test/regress/input/Makefile @@ -7,7 +7,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/test/regress/input/Attic/Makefile,v 1.5 1997/05/05 06:53:31 vadim Exp $ +# $Header: /cvsroot/pgsql/src/test/regress/input/Attic/Makefile,v 1.6 1997/08/28 04:49:18 vadim Exp $ # #------------------------------------------------------------------------- @@ -21,7 +21,8 @@ include ../../../Makefile.global INFILES= copy.sql \ create_function_1.sql \ create_function_2.sql \ - misc.sql + misc.sql \ + constraints.sql all: $(INFILES) diff --git a/src/test/regress/input/constraints.source b/src/test/regress/input/constraints.source new file mode 100644 index 0000000000..a0043e3651 --- /dev/null +++ b/src/test/regress/input/constraints.source @@ -0,0 +1,72 @@ +-- +-- Check constraints +-- + +-- Check constraints on INSERT +drop sequence seq; +drop table test; +create sequence seq; +create table test (x int default nextval ( 'seq') , +y text default '-NULL-', z int default -1 * currval('seq') ) +constraint test1 check (x > 3 and y <> 'check failed' and x < 8 ), +check x + z = 0; +insert into test values (null, null, null); +insert into test values (null, null, -2); +select * from test; +select nextval('seq'); +insert into test values (null, null, null); +insert into test values (1, null, -2); +insert into test values (7, null, -7); +insert into test values (5, 'check failed', -5); +insert into test values (7, '!check failed', -7); +insert into test values (null, null, null); +select * from test; +insert into test values (null, 'check failed', 5); +insert into test values (5, 'check failed', null); +insert into test values (5, '!check failed', null); +insert into test values (null, null, null); +select * from test; +insert into test values (null, null, null); +select currval('seq'); + +-- Check constraints on INSERT INTO + +drop table test; +drop sequence seq; +create sequence seq start 4; +create table dummy (xd int, yd text, zd int); + +create table test (x int default nextval ( 'seq') , +y text default '-NULL-', z int default -1 * currval('seq') ) +constraint test1 check (x > 3 and y <> 'check failed' and x < 7 ), check +x + z = 0; + +select nextval('seq'); +insert into dummy values (null, null, null); +insert into dummy values (5, '!check failed', null); +insert into dummy values (null, 'try again', null); +insert into test select * from dummy; +select * from test; +insert into test select * from dummy where yd = 'try again'; + +-- Check constraints on UPDATE +update test set x = null where x = 6; +select currval('seq'); + +-- Check constraints on COPY FROM +drop table test; +drop sequence seq; +create sequence seq start 4; +create table test (x int default nextval ( 'seq') , +y text default '-NULL-', z int default -1 * currval('seq') ) +constraint test1 check (x > 3 and y <> 'check failed' and x < 7 ), check +x + z = 0; +copy test from '_OBJWD_/data/constro.data'; +select * from test; +copy test from '_OBJWD_/data/constrf.data'; +select * from test; +select nextval('seq') - 1 as currval; + +-- Clean up +drop sequence seq; +drop table test; |
