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

Commit9bc933b

Browse files
committed
Fix 8.2 breakage of domains over array types, and add a regression test case
to cover it. Per report from Anton Pikhteryev.
1 parent79929ff commit9bc933b

File tree

3 files changed

+55
-19
lines changed

3 files changed

+55
-19
lines changed

‎src/backend/utils/cache/lsyscache.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.149 2007/03/17 00:11:05 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.150 2007/03/19 16:30:31 tgl Exp $
1111
*
1212
* NOTES
1313
* Eventually, the index information should go through here, too.
@@ -1767,10 +1767,10 @@ getTypeIOParam(HeapTuple typeTuple)
17671767

17681768
/*
17691769
* Array types get their typelem as parameter; everybody else gets their
1770-
* own type OID as parameter. (This is a change from 8.0, in which only
1771-
*composite types gottheirown OID as parameter.)
1770+
* own type OID as parameter. (As of 8.2, domains must get their own OID
1771+
*even iftheirbase type is an array.)
17721772
*/
1773-
if (OidIsValid(typeStruct->typelem))
1773+
if (typeStruct->typtype=='b'&&OidIsValid(typeStruct->typelem))
17741774
returntypeStruct->typelem;
17751775
else
17761776
returnHeapTupleGetOid(typeTuple);

‎src/test/regress/expected/domain.out

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ NOTICE: drop cascades to type dependenttypetest
1515
-- this should fail because already gone
1616
drop domain domaindroptest cascade;
1717
ERROR: 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.
1921
create domain domainvarchar varchar(5);
2022
create domain domainnumeric numeric(8,2);
2123
create domain domainint4 int4;
@@ -72,20 +74,22 @@ drop domain domainvarchar restrict;
7274
drop domain domainnumeric restrict;
7375
drop domain domainint4 restrict;
7476
drop domain domaintext;
75-
--ArrayTest
77+
-- Test domains over array types
7678
create domain domainint4arr int4[1];
77-
create domaindomaintextarr text[2][3];
79+
create domaindomainchar4arr varchar(4)[2][3];
7880
create table domarrtest
7981
( testint4arr domainint4arr
80-
,testtextarr domaintextarr
82+
,testchar4arr domainchar4arr
8183
);
8284
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"}}');
8385
INSERT INTO domarrtest values ('{{2,2},{2,2}}', '{{"a","b"}}');
8486
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"},{"e","f"}}');
8587
INSERT INTO domarrtest values ('{2,2}', '{{"a"},{"c"}}');
8688
INSERT 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)
8791
select * 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+
107127
drop table domarrtest;
108128
drop domain domainint4arr restrict;
109-
drop domaindomaintextarr restrict;
129+
drop domaindomainchar4arr restrict;
110130
create domain dnotnull varchar(15) NOT NULL;
111131
create domain dnull varchar(15);
112132
create domain dcheck varchar(15) NOT NULL CHECK (VALUE = 'a' OR VALUE = 'c' OR VALUE = 'd');

‎src/test/regress/sql/domain.sql

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ drop domain domaindroptest cascade;
1717
dropdomain domaindroptest cascade;
1818

1919

20-
-- TEST Domains.
20+
-- Test domain input.
21+
22+
-- Note: the point of checking both INSERT and COPY FROM is that INSERT
23+
-- exercises CoerceToDomain while COPY exercises domain_in.
2124

2225
createdomaindomainvarcharvarchar(5);
2326
createdomaindomainnumericnumeric(8,2);
@@ -62,25 +65,38 @@ drop domain domainint4 restrict;
6265
dropdomain domaintext;
6366

6467

65-
-- Array Test
68+
-- Test domains over array types
69+
6670
createdomaindomainint4arr int4[1];
67-
createdomaindomaintextarrtext[2][3];
71+
createdomaindomainchar4arrvarchar(4)[2][3];
6872

6973
createtabledomarrtest
7074
( testint4arr domainint4arr
71-
,testtextarr domaintextarr
75+
,testchar4arr domainchar4arr
7276
);
7377
INSERT INTO domarrtestvalues ('{2,2}','{{"a","b"},{"c","d"}}');
7478
INSERT INTO domarrtestvalues ('{{2,2},{2,2}}','{{"a","b"}}');
7579
INSERT INTO domarrtestvalues ('{2,2}','{{"a","b"},{"c","d"},{"e","f"}}');
7680
INSERT INTO domarrtestvalues ('{2,2}','{{"a"},{"c"}}');
7781
INSERT INTO domarrtestvalues (NULL,'{{"a","b","c"},{"d","e","f"}}');
82+
INSERT INTO domarrtestvalues (NULL,'{{"toolong","b","c"},{"d","e","f"}}');
83+
select*from domarrtest;
84+
select testint4arr[1], testchar4arr[2:2]from domarrtest;
85+
86+
COPY domarrtestFROM stdin;
87+
{3,4}{q,w,e}
88+
\N\N
89+
\.
90+
91+
COPY domarrtestFROM stdin;-- fail
92+
{3,4}{qwerty,w,e}
93+
\.
94+
7895
select*from domarrtest;
79-
select testint4arr[1], testtextarr[2:2]from domarrtest;
8096

8197
droptable domarrtest;
8298
dropdomain domainint4arr restrict;
83-
dropdomaindomaintextarr restrict;
99+
dropdomaindomainchar4arr restrict;
84100

85101

86102
createdomaindnotnullvarchar(15)NOT NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp