summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorBruce Momjian2002-09-20 03:52:50 +0000
committerBruce Momjian2002-09-20 03:52:50 +0000
commit07a6fa9df1dbb7a1d6466fdc833983bcd0d616eb (patch)
treea114729be88aefe3aa54f995f3daac68722688a8 /src/test
parent24bebf0b725e965ed2b725dcb31a46f787e98dbf (diff)
Fixed this problem and added regression tests in domain.sql.
Also: - Changed header file order (alphabetical) - Changed to m = attnum - 1 in binary copy code for consistency Rod Taylor
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/domain.out24
-rw-r--r--src/test/regress/sql/domain.sql26
2 files changed, 46 insertions, 4 deletions
diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out
index 8bbed8c431..79953d472c 100644
--- a/src/test/regress/expected/domain.out
+++ b/src/test/regress/expected/domain.out
@@ -37,12 +37,18 @@ INSERT INTO basictest values ('88', 'haha', 'short', '123.12'); -- Good
INSERT INTO basictest values ('88', 'haha', 'short text', '123.12'); -- Bad varchar
ERROR: value too long for type character varying(5)
INSERT INTO basictest values ('88', 'haha', 'short', '123.1212'); -- Truncate numeric
+-- Test copy
+COPY basictest (testvarchar) FROM stdin; -- fail
+ERROR: copy: line 1, value too long for type character varying(5)
+lost synchronization with server, resetting connection
+COPY basictest (testvarchar) FROM stdin;
select * from basictest;
testint4 | testtext | testvarchar | testnumeric
----------+----------+-------------+-------------
88 | haha | short | 123.12
88 | haha | short | 123.12
-(2 rows)
+ | | short |
+(3 rows)
-- check that domains inherit operations from base types
select testtext || testvarchar as concat, testnumeric + 42 as sum
@@ -51,7 +57,8 @@ from basictest;
-----------+--------
hahashort | 165.12
hahashort | 165.12
-(2 rows)
+ |
+(3 rows)
drop table basictest;
drop domain domainvarchar restrict;
@@ -111,12 +118,18 @@ ERROR: Domain dnotnull does not allow NULL values
INSERT INTO nulltest values ('a', 'b', NULL, 'd');
ERROR: ExecInsert: Fail to add null value in not null attribute col3
INSERT INTO nulltest values ('a', 'b', 'c', NULL); -- Good
+-- Test copy
+COPY nulltest FROM stdin; --fail
+ERROR: copy: line 1, CopyFrom: Fail to add null value in not null attribute col3
+lost synchronization with server, resetting connection
+COPY nulltest FROM stdin;
select * from nulltest;
col1 | col2 | col3 | col4
------+------+------+------
a | b | c | d
a | b | c |
-(2 rows)
+ a | b | c |
+(3 rows)
-- Test out coerced (casted) constraints
SELECT cast('1' as dnotnull);
@@ -156,13 +169,16 @@ NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 'defaulttest_pkey
insert into defaulttest default values;
insert into defaulttest default values;
insert into defaulttest default values;
+-- Test defaults with copy
+COPY defaulttest(col5) FROM stdin;
select * from defaulttest;
col1 | col2 | col3 | col4 | col5 | col6 | col7 | col8
------+------+------+------+------+------+------+-------
3 | 12 | 5 | 1 | 3 | 88 | 8000 | 12.12
3 | 12 | 5 | 2 | 3 | 88 | 8000 | 12.12
3 | 12 | 5 | 3 | 3 | 88 | 8000 | 12.12
-(3 rows)
+ 3 | 12 | 5 | 4 | 42 | 88 | 8000 | 12.12
+(4 rows)
drop sequence ddef4_seq;
drop table defaulttest;
diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql
index a5690694ca..98ed4248cc 100644
--- a/src/test/regress/sql/domain.sql
+++ b/src/test/regress/sql/domain.sql
@@ -35,6 +35,16 @@ create table basictest
INSERT INTO basictest values ('88', 'haha', 'short', '123.12'); -- Good
INSERT INTO basictest values ('88', 'haha', 'short text', '123.12'); -- Bad varchar
INSERT INTO basictest values ('88', 'haha', 'short', '123.1212'); -- Truncate numeric
+
+-- Test copy
+COPY basictest (testvarchar) FROM stdin; -- fail
+notsoshorttext
+\.
+
+COPY basictest (testvarchar) FROM stdin;
+short
+\.
+
select * from basictest;
-- check that domains inherit operations from base types
@@ -84,6 +94,16 @@ INSERT INTO nulltest values (NULL, 'b', 'c', 'd');
INSERT INTO nulltest values ('a', NULL, 'c', 'd');
INSERT INTO nulltest values ('a', 'b', NULL, 'd');
INSERT INTO nulltest values ('a', 'b', 'c', NULL); -- Good
+
+-- Test copy
+COPY nulltest FROM stdin; --fail
+a b \N d
+\.
+
+COPY nulltest FROM stdin;
+a b c \N
+\.
+
select * from nulltest;
-- Test out coerced (casted) constraints
@@ -119,6 +139,12 @@ create table defaulttest
insert into defaulttest default values;
insert into defaulttest default values;
insert into defaulttest default values;
+
+-- Test defaults with copy
+COPY defaulttest(col5) FROM stdin;
+42
+\.
+
select * from defaulttest;
drop sequence ddef4_seq;