@@ -15,7 +15,9 @@ NOTICE: drop cascades to type dependenttypetest
1515-- this should fail because already gone
1616drop domain domaindroptest cascade;
1717ERROR: type "domaindroptest" does not exist
18- -- TEST Domains.
18+ -- Test domain input.
19+ -- Note: the point of checking both INSERT and COPY FROM is that INSERT
20+ -- exercises CoerceToDomain while COPY exercises domain_in.
1921create domain domainvarchar varchar(5);
2022create domain domainnumeric numeric(8,2);
2123create domain domainint4 int4;
@@ -72,20 +74,22 @@ drop domain domainvarchar restrict;
7274drop domain domainnumeric restrict;
7375drop domain domainint4 restrict;
7476drop domain domaintext;
75- -- Array Test
77+ -- Test domains over array types
7678create domain domainint4arr int4[1];
77- create domain domaintextarr text [2][3];
79+ create domain domainchar4arr varchar(4) [2][3];
7880create table domarrtest
7981 ( testint4arr domainint4arr
80- , testtextarr domaintextarr
82+ , testchar4arr domainchar4arr
8183 );
8284INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"}}');
8385INSERT INTO domarrtest values ('{{2,2},{2,2}}', '{{"a","b"}}');
8486INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"},{"e","f"}}');
8587INSERT INTO domarrtest values ('{2,2}', '{{"a"},{"c"}}');
8688INSERT INTO domarrtest values (NULL, '{{"a","b","c"},{"d","e","f"}}');
89+ INSERT INTO domarrtest values (NULL, '{{"toolong","b","c"},{"d","e","f"}}');
90+ ERROR: value too long for type character varying(4)
8791select * from domarrtest;
88- testint4arr | testtextarr
92+ testint4arr | testchar4arr
8993---------------+---------------------
9094 {2,2} | {{a,b},{c,d}}
9195 {{2,2},{2,2}} | {{a,b}}
@@ -94,19 +98,35 @@ select * from domarrtest;
9498 | {{a,b,c},{d,e,f}}
9599(5 rows)
96100
97- select testint4arr[1], testtextarr [2:2] from domarrtest;
98- testint4arr | testtextarr
99- -------------+-------------
101+ select testint4arr[1], testchar4arr [2:2] from domarrtest;
102+ testint4arr | testchar4arr
103+ -------------+--------------
100104 2 | {{c,d}}
101105 | {}
102106 2 | {{c,d}}
103107 2 | {{c}}
104108 | {{d,e,f}}
105109(5 rows)
106110
111+ COPY domarrtest FROM stdin;
112+ COPY domarrtest FROM stdin; -- fail
113+ ERROR: value too long for type character varying(4)
114+ CONTEXT: COPY domarrtest, line 1, column testchar4arr: "{qwerty,w,e}"
115+ select * from domarrtest;
116+ testint4arr | testchar4arr
117+ ---------------+---------------------
118+ {2,2} | {{a,b},{c,d}}
119+ {{2,2},{2,2}} | {{a,b}}
120+ {2,2} | {{a,b},{c,d},{e,f}}
121+ {2,2} | {{a},{c}}
122+ | {{a,b,c},{d,e,f}}
123+ {3,4} | {q,w,e}
124+ |
125+ (7 rows)
126+
107127drop table domarrtest;
108128drop domain domainint4arr restrict;
109- drop domain domaintextarr restrict;
129+ drop domain domainchar4arr restrict;
110130create domain dnotnull varchar(15) NOT NULL;
111131create domain dnull varchar(15);
112132create domain dcheck varchar(15) NOT NULL CHECK (VALUE = 'a' OR VALUE = 'c' OR VALUE = 'd');
0 commit comments