From be92769e4e63de949fe3ba29e0bf5c0a96f54ae3 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 17 Nov 2017 11:53:00 -0500 Subject: [PATCH] Set proargmodes for satisfies_hash_partition. It appears that proargmodes should always be set for variadic functions, but satifies_hash_partition had it as NULL. In addition to fixing the problem, add a regression test to guard against future mistakes of this type. --- src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_proc.h | 2 +- src/test/regress/expected/type_sanity.out | 11 +++++++++++ src/test/regress/sql/type_sanity.sql | 8 ++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index bd4014a69d0..a30ce6b81d8 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201711092 +#define CATALOG_VERSION_NO 201711171 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 0330c04f169..c9693759811 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -5523,7 +5523,7 @@ DATA(insert OID = 3354 ( pg_ls_waldir PGNSP PGUID 12 10 20 0 0 f f f f t t DESCR("list of files in the WAL directory"); /* hash partitioning constraint function */ -DATA(insert OID = 5028 ( satisfies_hash_partition PGNSP PGUID 12 1 0 2276 0 f f f f f f i s 4 0 16 "26 23 23 2276" _null_ _null_ _null_ _null_ _null_ satisfies_hash_partition _null_ _null_ _null_ )); +DATA(insert OID = 5028 ( satisfies_hash_partition PGNSP PGUID 12 1 0 2276 0 f f f f f f i s 4 0 16 "26 23 23 2276" _null_ "{i,i,i,v}" _null_ _null_ _null_ satisfies_hash_partition _null_ _null_ _null_ )); DESCR("hash partition CHECK constraint"); /* diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out index c6440060dcb..b1419d4bc21 100644 --- a/src/test/regress/expected/type_sanity.out +++ b/src/test/regress/expected/type_sanity.out @@ -147,6 +147,17 @@ AND case proargtypes[array_length(proargtypes, 1)-1] -----+-------------+------------- (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 p1.oid, p1.typname, p2.oid, p2.proname diff --git a/src/test/regress/sql/type_sanity.sql b/src/test/regress/sql/type_sanity.sql index 428c2d324dd..f9aeea32144 100644 --- a/src/test/regress/sql/type_sanity.sql +++ b/src/test/regress/sql/type_sanity.sql @@ -120,6 +120,14 @@ AND case proargtypes[array_length(proargtypes, 1)-1] 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 p1.oid, p1.typname, p2.oid, p2.proname -- 2.30.2