pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andres Freund <andres@2ndquadrant.com>
To: pgsql-bugs@postgresql.org
Subject: mismatching proargtypes/proallargtypes (bug #10122)
Date: Thu, 24 Apr 2014 02:22:11 +0200
Message-ID: <20140424002211.GD12442@awork2.anarazel.de> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Hi,

'trinque' on irc reported that "SELECT pg_catalog.pg_identify_object(oid,
integer, integer)'::regprocedure" doesn't work and Andrew Gierth noticed
it's because proargtypes doesn't match proallargtypes.

Surpringsly there's no regression check testing for that. I recall
running into problems with mismatches there myself in the past. The
attached patch fixes the two wrong cases and adds a regression test to
prevent further occurances.
The broken functions are:
 oid  |                 oid                 | proargtypes |     proallargtypes     | filtered_allargtypes |   proargmodes   
------+-------------------------------------+-------------+------------------------+----------------------+-----------------
 3078 | pg_sequence_parameters(oid)         | {26}        | {23,20,20,20,20,16}    | {23}                 | {i,o,o,o,o,o}
 3839 | pg_identify_object(oid,oid,integer) | {26,26,23}  | {26,23,23,25,25,25,25} | {26,23,23}           | {i,i,i,o,o,o,o}

sequence_parameters is wrong in 9.1+, identify_object in 9.3+.

Luckily neither is particularly important. It's really a pity that we
don't have infrastructure for fixing this like this :/.

Do we need a note in the release notes for fixing those functions?

I am sending this as a separate thread as the actual bugreport is
still stuck in moderation and I going to bed. Don't want somebody to
waste their time duplicating this.

Greetings,

Andres Freund

-- 
 Andres Freund	                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

0001-Fix-pg_proc-entries-with-mismatching-proargtypes-pro.patch (text/x-patch, 5.3K) download From 05c0d9b859b59c9ef85ed24b3b83df3104ffcef6 Mon Sep 17 00:00:00 2001 From: Andres Freund <andres@anarazel.de> Date: Thu, 24 Apr 2014 02:01:07 +0200 Subject: [PATCH] Fix pg_proc entries with mismatching proargtypes/proallargtypes. Also add a regression test to prevent further corrupted entries. --- src/include/catalog/pg_proc.h | 4 ++-- src/test/regress/expected/opr_sanity.out | 25 +++++++++++++++++++++++++ src/test/regress/sql/opr_sanity.sql | 22 ++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index c77c036..0df3994 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -1775,7 +1775,7 @@ DATA(insert OID = 1576 ( setval PGNSP PGUID 12 1 0 0 0 f f f f t f v 2 0 20 " DESCR("set sequence value"); DATA(insert OID = 1765 ( setval PGNSP PGUID 12 1 0 0 0 f f f f t f v 3 0 20 "2205 20 16" _null_ _null_ _null_ _null_ setval3_oid _null_ _null_ _null_ )); DESCR("set sequence value and is_called status"); -DATA(insert OID = 3078 ( pg_sequence_parameters PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2249 "26" "{23,20,20,20,20,16}" "{i,o,o,o,o,o}" "{sequence_oid,start_value,minimum_value,maximum_value,increment,cycle_option}" _null_ pg_sequence_parameters _null_ _null_ _null_)); +DATA(insert OID = 3078 ( pg_sequence_parameters PGNSP PGUID 12 1 0 0 0 f f f f t f s 1 0 2249 "26" "{26,20,20,20,20,16}" "{i,o,o,o,o,o}" "{sequence_oid,start_value,minimum_value,maximum_value,increment,cycle_option}" _null_ pg_sequence_parameters _null_ _null_ _null_)); DESCR("sequence parameters, for use by information schema"); DATA(insert OID = 1579 ( varbit_in PGNSP PGUID 12 1 0 0 0 f f f f t f i 3 0 1562 "2275 26 23" _null_ _null_ _null_ _null_ varbit_in _null_ _null_ _null_ )); @@ -2981,7 +2981,7 @@ DESCR("view members of a multixactid"); DATA(insert OID = 3537 ( pg_describe_object PGNSP PGUID 12 1 0 0 0 f f f f t f s 3 0 25 "26 26 23" _null_ _null_ _null_ _null_ pg_describe_object _null_ _null_ _null_ )); DESCR("get identification of SQL object"); -DATA(insert OID = 3839 ( pg_identify_object PGNSP PGUID 12 1 0 0 0 f f f f t f s 3 0 2249 "26 26 23" "{26,23,23,25,25,25,25}" "{i,i,i,o,o,o,o}" "{classid,objid,subobjid,type,schema,name,identity}" _null_ pg_identify_object _null_ _null_ _null_ )); +DATA(insert OID = 3839 ( pg_identify_object PGNSP PGUID 12 1 0 0 0 f f f f t f s 3 0 2249 "26 26 23" "{26,26,23,25,25,25,25}" "{i,i,i,o,o,o,o}" "{classid,objid,subobjid,type,schema,name,identity}" _null_ pg_identify_object _null_ _null_ _null_ )); DESCR("get machine-parseable identification of SQL object"); DATA(insert OID = 2079 ( pg_table_is_visible PGNSP PGUID 12 10 0 0 0 f f f f t f s 1 0 16 "26" _null_ _null_ _null_ _null_ pg_table_is_visible _null_ _null_ _null_ )); diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out index b2d671a..7ae7b38 100644 --- a/src/test/regress/expected/opr_sanity.out +++ b/src/test/regress/expected/opr_sanity.out @@ -332,6 +332,31 @@ WHERE proargmodes IS NOT NULL AND proargnames IS NOT NULL AND -----+--------- (0 rows) +-- Check for mismatching proargtypes/proallargtypes +SELECT * +FROM ( + SELECT + oid, + oid::regprocedure, + -- plain arrays, not oidvector, please + ARRAY(SELECT unnest(proargtypes)) proargtypes, + proallargtypes, + ARRAY( -- remove output parameters from proallargtypes + SELECT proallargtypes[i] + FROM generate_series(1, array_length(proargmodes, 1)) g(i) + WHERE proargmodes[i] IN ('i', 'b', 'v') + ) filtered_allargtypes, + proargmodes + FROM pg_proc + WHERE proallargtypes IS NOT NULL + ) sensible_pgproc +WHERE + proargtypes <> filtered_allargtypes +; + oid | oid | proargtypes | proallargtypes | filtered_allargtypes | proargmodes +-----+-----+-------------+----------------+----------------------+------------- +(0 rows) + -- Check for protransform 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/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql index dc1acb9..3276472 100644 --- a/src/test/regress/sql/opr_sanity.sql +++ b/src/test/regress/sql/opr_sanity.sql @@ -258,6 +258,28 @@ FROM pg_proc as p1 WHERE proargmodes IS NOT NULL AND proargnames IS NOT NULL AND array_length(proargmodes,1) <> array_length(proargnames,1); +-- Check for mismatching proargtypes/proallargtypes +SELECT * +FROM ( + SELECT + oid, + oid::regprocedure, + -- plain arrays, not oidvector, please + ARRAY(SELECT unnest(proargtypes)) proargtypes, + proallargtypes, + ARRAY( -- remove output parameters from proallargtypes + SELECT proallargtypes[i] + FROM generate_series(1, array_length(proargmodes, 1)) g(i) + WHERE proargmodes[i] IN ('i', 'b', 'v') + ) filtered_allargtypes, + proargmodes + FROM pg_proc + WHERE proallargtypes IS NOT NULL + ) sensible_pgproc +WHERE + proargtypes <> filtered_allargtypes +; + -- Check for protransform functions with the wrong signature SELECT p1.oid, p1.proname, p2.oid, p2.proname FROM pg_proc AS p1, pg_proc AS p2 -- 1.8.5.rc2.dirty

view thread (4+ messages)  latest in thread

Message-ID: <20140424002211.GD12442@awork2.anarazel.de>
Permalink:  ../20140424002211.GD12442@awork2.anarazel.de/
Also on:    postgresql.org/message-id/20140424002211.GD12442@awork2.anarazel.de

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: andres@2ndquadrant.com
  Subject: Re: mismatching proargtypes/proallargtypes (bug #10122)
  In-Reply-To: <20140424002211.GD12442@awork2.anarazel.de>
  References: <20140424002211.GD12442@awork2.anarazel.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox