Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 35f059e

Browse files
committed
Add sanity check for pg_proc.provariadic
Check that the values from pg_proc.h match what ProcedureCreate would have done. Robert Haas and Amul Sul Discussion: http://postgr.es/m/CA+TgmoZ_UGXfq5ygeDDMdUSJ4J_VX7nFnjC6mfY6BgOJ3qZCmw@mail.gmail.com
1 parent 86182b1 commit 35f059e

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/test/regress/expected/type_sanity.out

+18
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,24 @@ WHERE p1.typinput = p2.oid AND NOT
129129
-----+---------+-----+---------
130130
(0 rows)
131131

132+
-- Check for type of the variadic array parameter's elements.
133+
-- provariadic should be ANYOID if the type of the last element is ANYOID,
134+
-- ANYELEMENTOID if the type of the last element is ANYARRAYOID, and otherwise
135+
-- the element type corresponding to the array type.
136+
SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[]
137+
FROM pg_proc
138+
WHERE provariadic != 0
139+
AND case proargtypes[array_length(proargtypes, 1)-1]
140+
WHEN 2276 THEN 2276 -- any -> any
141+
WHEN 2277 THEN 2283 -- anyarray -> anyelement
142+
ELSE (SELECT t.oid
143+
FROM pg_type t
144+
WHERE t.typarray = proargtypes[array_length(proargtypes, 1)-1])
145+
END != provariadic;
146+
oid | provariadic | proargtypes
147+
-----+-------------+-------------
148+
(0 rows)
149+
132150
-- As of 8.0, this check finds refcursor, which is borrowing
133151
-- other types' I/O routines
134152
SELECT p1.oid, p1.typname, p2.oid, p2.proname

src/test/regress/sql/type_sanity.sql

+16
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ WHERE p1.typinput = p2.oid AND NOT
104104
p2.proargtypes[1] = 'oid'::regtype AND
105105
p2.proargtypes[2] = 'int4'::regtype));
106106

107+
-- Check for type of the variadic array parameter's elements.
108+
-- provariadic should be ANYOID if the type of the last element is ANYOID,
109+
-- ANYELEMENTOID if the type of the last element is ANYARRAYOID, and otherwise
110+
-- the element type corresponding to the array type.
111+
112+
SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[]
113+
FROM pg_proc
114+
WHERE provariadic != 0
115+
AND case proargtypes[array_length(proargtypes, 1)-1]
116+
WHEN 2276 THEN 2276 -- any -> any
117+
WHEN 2277 THEN 2283 -- anyarray -> anyelement
118+
ELSE (SELECT t.oid
119+
FROM pg_type t
120+
WHERE t.typarray = proargtypes[array_length(proargtypes, 1)-1])
121+
END != provariadic;
122+
107123
-- As of 8.0, this check finds refcursor, which is borrowing
108124
-- other types' I/O routines
109125
SELECT p1.oid, p1.typname, p2.oid, p2.proname

0 commit comments

Comments
 (0)