Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
9bc933b2
Commit
9bc933b2
authored
Mar 19, 2007
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 8.2 breakage of domains over array types, and add a regression test case
to cover it. Per report from Anton Pikhteryev.
parent
79929fff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
19 deletions
+55
-19
src/backend/utils/cache/lsyscache.c
src/backend/utils/cache/lsyscache.c
+4
-4
src/test/regress/expected/domain.out
src/test/regress/expected/domain.out
+29
-9
src/test/regress/sql/domain.sql
src/test/regress/sql/domain.sql
+22
-6
No files found.
src/backend/utils/cache/lsyscache.c
View file @
9bc933b2
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.1
49 2007/03/17 00:11:05
tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/cache/lsyscache.c,v 1.1
50 2007/03/19 16:30:31
tgl Exp $
*
*
* NOTES
* NOTES
* Eventually, the index information should go through here, too.
* Eventually, the index information should go through here, too.
...
@@ -1767,10 +1767,10 @@ getTypeIOParam(HeapTuple typeTuple)
...
@@ -1767,10 +1767,10 @@ getTypeIOParam(HeapTuple typeTuple)
/*
/*
* Array types get their typelem as parameter; everybody else gets their
* Array types get their typelem as parameter; everybody else gets their
* own type OID as parameter. (
This is a change from 8.0, in which only
* own type OID as parameter. (
As of 8.2, domains must get their own OID
*
composite types got their own OID as parameter
.)
*
even if their base type is an array
.)
*/
*/
if
(
OidIsValid
(
typeStruct
->
typelem
))
if
(
typeStruct
->
typtype
==
'b'
&&
OidIsValid
(
typeStruct
->
typelem
))
return
typeStruct
->
typelem
;
return
typeStruct
->
typelem
;
else
else
return
HeapTupleGetOid
(
typeTuple
);
return
HeapTupleGetOid
(
typeTuple
);
...
...
src/test/regress/expected/domain.out
View file @
9bc933b2
...
@@ -15,7 +15,9 @@ NOTICE: drop cascades to type dependenttypetest
...
@@ -15,7 +15,9 @@ NOTICE: drop cascades to type dependenttypetest
-- this should fail because already gone
-- this should fail because already gone
drop domain domaindroptest cascade;
drop domain domaindroptest cascade;
ERROR: type "domaindroptest" does not exist
ERROR: type "domaindroptest" does not exist
-- TEST Domains.
-- Test domain input.
-- Note: the point of checking both INSERT and COPY FROM is that INSERT
-- exercises CoerceToDomain while COPY exercises domain_in.
create domain domainvarchar varchar(5);
create domain domainvarchar varchar(5);
create domain domainnumeric numeric(8,2);
create domain domainnumeric numeric(8,2);
create domain domainint4 int4;
create domain domainint4 int4;
...
@@ -72,20 +74,22 @@ drop domain domainvarchar restrict;
...
@@ -72,20 +74,22 @@ drop domain domainvarchar restrict;
drop domain domainnumeric restrict;
drop domain domainnumeric restrict;
drop domain domainint4 restrict;
drop domain domainint4 restrict;
drop domain domaintext;
drop domain domaintext;
--
Array Test
--
Test domains over array types
create domain domainint4arr int4[1];
create domain domainint4arr int4[1];
create domain domain
textarr text
[2][3];
create domain domain
char4arr varchar(4)
[2][3];
create table domarrtest
create table domarrtest
( testint4arr domainint4arr
( testint4arr domainint4arr
, test
textarr domaintext
arr
, test
char4arr domainchar4
arr
);
);
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"}}');
INSERT INTO domarrtest values ('{{2,2},{2,2}}', '{{"a","b"}}');
INSERT INTO domarrtest values ('{{2,2},{2,2}}', '{{"a","b"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"},{"e","f"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a","b"},{"c","d"},{"e","f"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a"},{"c"}}');
INSERT INTO domarrtest values ('{2,2}', '{{"a"},{"c"}}');
INSERT INTO domarrtest values (NULL, '{{"a","b","c"},{"d","e","f"}}');
INSERT INTO domarrtest values (NULL, '{{"a","b","c"},{"d","e","f"}}');
INSERT INTO domarrtest values (NULL, '{{"toolong","b","c"},{"d","e","f"}}');
ERROR: value too long for type character varying(4)
select * from domarrtest;
select * from domarrtest;
testint4arr |
testtext
arr
testint4arr |
testchar4
arr
---------------+---------------------
---------------+---------------------
{2,2} | {{a,b},{c,d}}
{2,2} | {{a,b},{c,d}}
{{2,2},{2,2}} | {{a,b}}
{{2,2},{2,2}} | {{a,b}}
...
@@ -94,9 +98,9 @@ select * from domarrtest;
...
@@ -94,9 +98,9 @@ select * from domarrtest;
| {{a,b,c},{d,e,f}}
| {{a,b,c},{d,e,f}}
(5 rows)
(5 rows)
select testint4arr[1], test
text
arr[2:2] from domarrtest;
select testint4arr[1], test
char4
arr[2:2] from domarrtest;
testint4arr | test
text
arr
testint4arr | test
char4
arr
-------------+-------------
-------------+-------------
-
2 | {{c,d}}
2 | {{c,d}}
| {}
| {}
2 | {{c,d}}
2 | {{c,d}}
...
@@ -104,9 +108,25 @@ select testint4arr[1], testtextarr[2:2] from domarrtest;
...
@@ -104,9 +108,25 @@ select testint4arr[1], testtextarr[2:2] from domarrtest;
| {{d,e,f}}
| {{d,e,f}}
(5 rows)
(5 rows)
COPY domarrtest FROM stdin;
COPY domarrtest FROM stdin; -- fail
ERROR: value too long for type character varying(4)
CONTEXT: COPY domarrtest, line 1, column testchar4arr: "{qwerty,w,e}"
select * from domarrtest;
testint4arr | testchar4arr
---------------+---------------------
{2,2} | {{a,b},{c,d}}
{{2,2},{2,2}} | {{a,b}}
{2,2} | {{a,b},{c,d},{e,f}}
{2,2} | {{a},{c}}
| {{a,b,c},{d,e,f}}
{3,4} | {q,w,e}
|
(7 rows)
drop table domarrtest;
drop table domarrtest;
drop domain domainint4arr restrict;
drop domain domainint4arr restrict;
drop domain domain
text
arr restrict;
drop domain domain
char4
arr restrict;
create domain dnotnull varchar(15) NOT NULL;
create domain dnotnull varchar(15) NOT NULL;
create domain dnull varchar(15);
create domain dnull varchar(15);
create domain dcheck varchar(15) NOT NULL CHECK (VALUE = 'a' OR VALUE = 'c' OR VALUE = 'd');
create domain dcheck varchar(15) NOT NULL CHECK (VALUE = 'a' OR VALUE = 'c' OR VALUE = 'd');
...
...
src/test/regress/sql/domain.sql
View file @
9bc933b2
...
@@ -17,7 +17,10 @@ drop domain domaindroptest cascade;
...
@@ -17,7 +17,10 @@ drop domain domaindroptest cascade;
drop
domain
domaindroptest
cascade
;
drop
domain
domaindroptest
cascade
;
-- TEST Domains.
-- Test domain input.
-- Note: the point of checking both INSERT and COPY FROM is that INSERT
-- exercises CoerceToDomain while COPY exercises domain_in.
create
domain
domainvarchar
varchar
(
5
);
create
domain
domainvarchar
varchar
(
5
);
create
domain
domainnumeric
numeric
(
8
,
2
);
create
domain
domainnumeric
numeric
(
8
,
2
);
...
@@ -62,25 +65,38 @@ drop domain domainint4 restrict;
...
@@ -62,25 +65,38 @@ drop domain domainint4 restrict;
drop
domain
domaintext
;
drop
domain
domaintext
;
-- Array Test
-- Test domains over array types
create
domain
domainint4arr
int4
[
1
];
create
domain
domainint4arr
int4
[
1
];
create
domain
domain
textarr
text
[
2
][
3
];
create
domain
domain
char4arr
varchar
(
4
)
[
2
][
3
];
create
table
domarrtest
create
table
domarrtest
(
testint4arr
domainint4arr
(
testint4arr
domainint4arr
,
test
textarr
domaintext
arr
,
test
char4arr
domainchar4
arr
);
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a","b"},{"c","d"}}'
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a","b"},{"c","d"}}'
);
INSERT
INTO
domarrtest
values
(
'{{2,2},{2,2}}'
,
'{{"a","b"}}'
);
INSERT
INTO
domarrtest
values
(
'{{2,2},{2,2}}'
,
'{{"a","b"}}'
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a","b"},{"c","d"},{"e","f"}}'
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a","b"},{"c","d"},{"e","f"}}'
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a"},{"c"}}'
);
INSERT
INTO
domarrtest
values
(
'{2,2}'
,
'{{"a"},{"c"}}'
);
INSERT
INTO
domarrtest
values
(
NULL
,
'{{"a","b","c"},{"d","e","f"}}'
);
INSERT
INTO
domarrtest
values
(
NULL
,
'{{"a","b","c"},{"d","e","f"}}'
);
INSERT
INTO
domarrtest
values
(
NULL
,
'{{"toolong","b","c"},{"d","e","f"}}'
);
select
*
from
domarrtest
;
select
testint4arr
[
1
],
testchar4arr
[
2
:
2
]
from
domarrtest
;
COPY
domarrtest
FROM
stdin
;
{
3
,
4
}
{
q
,
w
,
e
}
\
N
\
N
\
.
COPY
domarrtest
FROM
stdin
;
-- fail
{
3
,
4
}
{
qwerty
,
w
,
e
}
\
.
select
*
from
domarrtest
;
select
*
from
domarrtest
;
select
testint4arr
[
1
],
testtextarr
[
2
:
2
]
from
domarrtest
;
drop
table
domarrtest
;
drop
table
domarrtest
;
drop
domain
domainint4arr
restrict
;
drop
domain
domainint4arr
restrict
;
drop
domain
domain
text
arr
restrict
;
drop
domain
domain
char4
arr
restrict
;
create
domain
dnotnull
varchar
(
15
)
NOT
NULL
;
create
domain
dnotnull
varchar
(
15
)
NOT
NULL
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment