Move provariadic sanity check to a more appropriate place

35f059e9bd put the provariadic sanity
check into type_sanity.sql, even though it's not about types, and
moreover in the middle of some connected test group, which makes it
all very confusing.  Move it to opr_sanity.sql, where it is in better
company.
This commit is contained in:
Peter Eisentraut 2022-12-15 07:49:30 +01:00
parent 3b9d2deb67
commit 2613dec4ed
4 changed files with 57 additions and 57 deletions

View File

@ -472,6 +472,37 @@ WHERE proallargtypes IS NOT NULL AND
-----+---------+-------------+----------------+-------------
(0 rows)
-- Check for type of the variadic array parameter's elements.
-- provariadic should be ANYOID if the type of the last element is ANYOID,
-- ANYELEMENTOID if the type of the last element is ANYARRAYOID,
-- ANYCOMPATIBLEOID if the type of the last element is ANYCOMPATIBLEARRAYOID,
-- and otherwise the element type corresponding to the array type.
SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[]
FROM pg_proc
WHERE provariadic != 0
AND case proargtypes[array_length(proargtypes, 1)-1]
WHEN '"any"'::regtype THEN '"any"'::regtype
WHEN 'anyarray'::regtype THEN 'anyelement'::regtype
WHEN 'anycompatiblearray'::regtype THEN 'anycompatible'::regtype
ELSE (SELECT t.oid
FROM pg_type t
WHERE t.typarray = proargtypes[array_length(proargtypes, 1)-1])
END != provariadic;
oid | provariadic | proargtypes
-----+-------------+-------------
(0 rows)
-- Check that all and only those functions with a variadic type have
-- a variadic argument.
SELECT oid::regprocedure, proargmodes, provariadic
FROM pg_proc
WHERE (proargmodes IS NOT NULL AND 'v' = any(proargmodes))
IS DISTINCT FROM
(provariadic != 0);
oid | proargmodes | provariadic
-----+-------------+-------------
(0 rows)
-- Check for prosupport functions with the wrong signature
SELECT p1.oid, p1.proname, p2.oid, p2.proname
FROM pg_proc AS p1, pg_proc AS p2

View File

@ -132,37 +132,6 @@ WHERE t1.typinput = p1.oid AND NOT
-----+---------+-----+---------
(0 rows)
-- Check for type of the variadic array parameter's elements.
-- provariadic should be ANYOID if the type of the last element is ANYOID,
-- ANYELEMENTOID if the type of the last element is ANYARRAYOID,
-- ANYCOMPATIBLEOID if the type of the last element is ANYCOMPATIBLEARRAYOID,
-- and otherwise the element type corresponding to the array type.
SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[]
FROM pg_proc
WHERE provariadic != 0
AND case proargtypes[array_length(proargtypes, 1)-1]
WHEN '"any"'::regtype THEN '"any"'::regtype
WHEN 'anyarray'::regtype THEN 'anyelement'::regtype
WHEN 'anycompatiblearray'::regtype THEN 'anycompatible'::regtype
ELSE (SELECT t.oid
FROM pg_type t
WHERE t.typarray = proargtypes[array_length(proargtypes, 1)-1])
END != provariadic;
oid | provariadic | proargtypes
-----+-------------+-------------
(0 rows)
-- Check that all and only those functions with a variadic type have
-- a variadic argument.
SELECT oid::regprocedure, proargmodes, provariadic
FROM pg_proc
WHERE (proargmodes IS NOT NULL AND 'v' = any(proargmodes))
IS DISTINCT FROM
(provariadic != 0);
oid | proargmodes | provariadic
-----+-------------+-------------
(0 rows)
-- As of 8.0, this check finds refcursor, which is borrowing
-- other types' I/O routines
SELECT t1.oid, t1.typname, p1.oid, p1.proname

View File

@ -344,6 +344,32 @@ WHERE proallargtypes IS NOT NULL AND
FROM generate_series(1, array_length(proallargtypes, 1)) g(i)
WHERE proargmodes IS NULL OR proargmodes[i] IN ('i', 'b', 'v'));
-- Check for type of the variadic array parameter's elements.
-- provariadic should be ANYOID if the type of the last element is ANYOID,
-- ANYELEMENTOID if the type of the last element is ANYARRAYOID,
-- ANYCOMPATIBLEOID if the type of the last element is ANYCOMPATIBLEARRAYOID,
-- and otherwise the element type corresponding to the array type.
SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[]
FROM pg_proc
WHERE provariadic != 0
AND case proargtypes[array_length(proargtypes, 1)-1]
WHEN '"any"'::regtype THEN '"any"'::regtype
WHEN 'anyarray'::regtype THEN 'anyelement'::regtype
WHEN 'anycompatiblearray'::regtype THEN 'anycompatible'::regtype
ELSE (SELECT t.oid
FROM pg_type t
WHERE t.typarray = proargtypes[array_length(proargtypes, 1)-1])
END != provariadic;
-- Check that all and only those functions with a variadic type have
-- a variadic argument.
SELECT oid::regprocedure, proargmodes, provariadic
FROM pg_proc
WHERE (proargmodes IS NOT NULL AND 'v' = any(proargmodes))
IS DISTINCT FROM
(provariadic != 0);
-- Check for prosupport functions with the wrong signature
SELECT p1.oid, p1.proname, p2.oid, p2.proname
FROM pg_proc AS p1, pg_proc AS p2

View File

@ -105,32 +105,6 @@ WHERE t1.typinput = p1.oid AND NOT
p1.proargtypes[1] = 'oid'::regtype AND
p1.proargtypes[2] = 'int4'::regtype));
-- Check for type of the variadic array parameter's elements.
-- provariadic should be ANYOID if the type of the last element is ANYOID,
-- ANYELEMENTOID if the type of the last element is ANYARRAYOID,
-- ANYCOMPATIBLEOID if the type of the last element is ANYCOMPATIBLEARRAYOID,
-- and otherwise the element type corresponding to the array type.
SELECT oid::regprocedure, provariadic::regtype, proargtypes::regtype[]
FROM pg_proc
WHERE provariadic != 0
AND case proargtypes[array_length(proargtypes, 1)-1]
WHEN '"any"'::regtype THEN '"any"'::regtype
WHEN 'anyarray'::regtype THEN 'anyelement'::regtype
WHEN 'anycompatiblearray'::regtype THEN 'anycompatible'::regtype
ELSE (SELECT t.oid
FROM pg_type t
WHERE t.typarray = proargtypes[array_length(proargtypes, 1)-1])
END != provariadic;
-- Check that all and only those functions with a variadic type have
-- a variadic argument.
SELECT oid::regprocedure, proargmodes, provariadic
FROM pg_proc
WHERE (proargmodes IS NOT NULL AND 'v' = any(proargmodes))
IS DISTINCT FROM
(provariadic != 0);
-- As of 8.0, this check finds refcursor, which is borrowing
-- other types' I/O routines
SELECT t1.oid, t1.typname, p1.oid, p1.proname