Add NULL regression tests.

Manfred Koizar
This commit is contained in:
Bruce Momjian 2003-10-10 03:46:51 +00:00
parent d7c971ab7d
commit 962987a1c2
2 changed files with 90 additions and 17 deletions

View File

@ -2,7 +2,7 @@ CREATE TABLE x (
a serial,
b int,
c text not null default 'stuff',
d text not null,
d text,
e text
);
NOTICE: CREATE TABLE will create implicit sequence "x_a_seq" for "serial" column "x.a"
@ -48,23 +48,38 @@ ERROR: extra data after last expected column
CONTEXT: COPY x, line 1: "2002 232 40 50 60 70 80"
-- various COPY options: delimiters, oids, NULL string
COPY x (b, c, d, e) from stdin with oids delimiter ',' null 'x';
COPY x from stdin WITH DELIMITER AS ';' NULL AS '';
COPY x from stdin WITH DELIMITER AS ':' NULL AS '\\X';
-- check results of copy in
SELECT * FROM x;
a | b | c | d | e
-------+----+-------+--------+----------------------
10000 | 21 | 31 | 41 | before trigger fired
10001 | 22 | 32 | 42 | before trigger fired
10002 | 23 | 33 | 43 | before trigger fired
10003 | 24 | 34 | 44 | before trigger fired
10004 | 25 | 35 | 45 | before trigger fired
10005 | 26 | 36 | 46 | before trigger fired
6 | | 45 | 80 | before trigger fired
1 | 1 | stuff | test_1 | after trigger fired
2 | 2 | stuff | test_2 | after trigger fired
3 | 3 | stuff | test_3 | after trigger fired
4 | 4 | stuff | test_4 | after trigger fired
5 | 5 | stuff | test_5 | after trigger fired
(12 rows)
a | b | c | d | e
-------+----+------------+--------+----------------------
9999 | | \N | NN | before trigger fired
10000 | 21 | 31 | 41 | before trigger fired
10001 | 22 | 32 | 42 | before trigger fired
10002 | 23 | 33 | 43 | before trigger fired
10003 | 24 | 34 | 44 | before trigger fired
10004 | 25 | 35 | 45 | before trigger fired
10005 | 26 | 36 | 46 | before trigger fired
6 | | 45 | 80 | before trigger fired
7 | | x | \x | before trigger fired
8 | | , | \, | before trigger fired
3000 | | c | | before trigger fired
4000 | | C | | before trigger fired
4001 | 1 | empty | | before trigger fired
4002 | 2 | null | | before trigger fired
4003 | 3 | Backslash | \ | before trigger fired
4004 | 4 | BackslashX | \X | before trigger fired
4005 | 5 | N | N | before trigger fired
4006 | 6 | BackslashN | \N | before trigger fired
4007 | 7 | XX | XX | before trigger fired
4008 | 8 | Delimiter | : | before trigger fired
1 | 1 | stuff | test_1 | after trigger fired
2 | 2 | stuff | test_2 | after trigger fired
3 | 3 | stuff | test_3 | after trigger fired
4 | 4 | stuff | test_4 | after trigger fired
5 | 5 | stuff | test_5 | after trigger fired
(25 rows)
-- COPY w/ oids on a table w/o oids should fail
CREATE TABLE no_oids (
@ -80,6 +95,7 @@ COPY no_oids TO stdout WITH OIDS;
ERROR: table "no_oids" does not have OIDs
-- check copy out
COPY x TO stdout;
9999 \N \\N NN before trigger fired
10000 21 31 41 before trigger fired
10001 22 32 42 before trigger fired
10002 23 33 43 before trigger fired
@ -87,12 +103,25 @@ COPY x TO stdout;
10004 25 35 45 before trigger fired
10005 26 36 46 before trigger fired
6 \N 45 80 before trigger fired
7 \N x \\x before trigger fired
8 \N , \\, before trigger fired
3000 \N c \N before trigger fired
4000 \N C \N before trigger fired
4001 1 empty before trigger fired
4002 2 null \N before trigger fired
4003 3 Backslash \\ before trigger fired
4004 4 BackslashX \\X before trigger fired
4005 5 N N before trigger fired
4006 6 BackslashN \\N before trigger fired
4007 7 XX XX before trigger fired
4008 8 Delimiter : before trigger fired
1 1 stuff test_1 after trigger fired
2 2 stuff test_2 after trigger fired
3 3 stuff test_3 after trigger fired
4 4 stuff test_4 after trigger fired
5 5 stuff test_5 after trigger fired
COPY x (c, e) TO stdout;
\\N before trigger fired
31 before trigger fired
32 before trigger fired
33 before trigger fired
@ -100,12 +129,25 @@ COPY x (c, e) TO stdout;
35 before trigger fired
36 before trigger fired
45 before trigger fired
x before trigger fired
, before trigger fired
c before trigger fired
C before trigger fired
empty before trigger fired
null before trigger fired
Backslash before trigger fired
BackslashX before trigger fired
N before trigger fired
BackslashN before trigger fired
XX before trigger fired
Delimiter before trigger fired
stuff after trigger fired
stuff after trigger fired
stuff after trigger fired
stuff after trigger fired
stuff after trigger fired
COPY x (b, e) TO stdout WITH NULL 'I''m null';
I'm null before trigger fired
21 before trigger fired
22 before trigger fired
23 before trigger fired
@ -113,6 +155,18 @@ COPY x (b, e) TO stdout WITH NULL 'I''m null';
25 before trigger fired
26 before trigger fired
I'm null before trigger fired
I'm null before trigger fired
I'm null before trigger fired
I'm null before trigger fired
I'm null before trigger fired
1 before trigger fired
2 before trigger fired
3 before trigger fired
4 before trigger fired
5 before trigger fired
6 before trigger fired
7 before trigger fired
8 before trigger fired
1 after trigger fired
2 after trigger fired
3 after trigger fired

View File

@ -2,7 +2,7 @@ CREATE TABLE x (
a serial,
b int,
c text not null default 'stuff',
d text not null,
d text,
e text
);
@ -27,6 +27,7 @@ CREATE TRIGGER trg_x_before BEFORE INSERT ON x
FOR EACH ROW EXECUTE PROCEDURE fn_x_before();
COPY x (a, b, c, d, e) from stdin;
9999 \N \\N \NN \N
10000 21 31 41 51
\.
@ -74,6 +75,24 @@ COPY x from stdin;
-- various COPY options: delimiters, oids, NULL string
COPY x (b, c, d, e) from stdin with oids delimiter ',' null 'x';
500000,x,45,80,90
500001,x,\x,\\x,\\\x
500002,x,\,,\\\,,\\
\.
COPY x from stdin WITH DELIMITER AS ';' NULL AS '';
3000;;c;;
\.
COPY x from stdin WITH DELIMITER AS ':' NULL AS '\\X';
4000:\X:C:\X:\X
4001:1:empty::
4002:2:null:\X:\X
4003:3:Backslash:\\:\\
4004:4:BackslashX:\\X:\\X
4005:5:N:\N:\N
4006:6:BackslashN:\\N:\\N
4007:7:XX:\XX:\XX
4008:8:Delimiter:\::\:
\.
-- check results of copy in