From 2613dec4ed67c4a963d987cbd29284e0634b65c9 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 15 Dec 2022 07:49:30 +0100 Subject: [PATCH] Move provariadic sanity check to a more appropriate place 35f059e9bdfb3b14ac9d22a9e159d36ec0ccf804 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. --- src/test/regress/expected/opr_sanity.out | 31 +++++++++++++++++++++++ src/test/regress/expected/type_sanity.out | 31 ----------------------- src/test/regress/sql/opr_sanity.sql | 26 +++++++++++++++++++ src/test/regress/sql/type_sanity.sql | 26 ------------------- 4 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out index 330eb0f765..02f5348ab1 100644 --- a/src/test/regress/expected/opr_sanity.out +++ b/src/test/regress/expected/opr_sanity.out @@ -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 diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out index d3ac08c9ee..a640cfc476 100644 --- a/src/test/regress/expected/type_sanity.out +++ b/src/test/regress/expected/type_sanity.out @@ -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 diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql index 2b292851e3..56b54ba988 100644 --- a/src/test/regress/sql/opr_sanity.sql +++ b/src/test/regress/sql/opr_sanity.sql @@ -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 diff --git a/src/test/regress/sql/type_sanity.sql b/src/test/regress/sql/type_sanity.sql index 5edc1f1f6e..79ec410a6c 100644 --- a/src/test/regress/sql/type_sanity.sql +++ b/src/test/regress/sql/type_sanity.sql @@ -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