pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedmismatching proargtypes/proallargtypes (bug #10122)
4+ messages / 3 participants
[nested] [flat]
* mismatching proargtypes/proallargtypes (bug #10122)
@ 2014-04-24 00:22 Andres Freund <andres@2ndquadrant.com>
2014-04-24 00:37 ` Re: mismatching proargtypes/proallargtypes (bug #10122) Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Andres Freund @ 2014-04-24 00:22 UTC (permalink / raw)
To: pgsql-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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: mismatching proargtypes/proallargtypes (bug #10122)
2014-04-24 00:22 mismatching proargtypes/proallargtypes (bug #10122) Andres Freund <andres@2ndquadrant.com>
@ 2014-04-24 00:37 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-04-24 01:06 ` Re: mismatching proargtypes/proallargtypes (bug #10122) Alvaro Herrera <alvherre@2ndquadrant.com>
0 siblings, 1 reply; 4+ messages in thread
From: Tom Lane @ 2014-04-24 00:37 UTC (permalink / raw)
To: Andres Freund <andres@2ndquadrant.com>; +Cc: pgsql-bugs
Andres Freund <andres@2ndquadrant.com> writes:
> '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.
Ugh, how annoying.
> Surpringsly there's no regression check testing for that.
Yeah, that's clearly an oversight :-(
> 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 think it's probably non-critical, especially since it took this
long for anybody to notice. It's fortunate that the two bad cases
are just integer vs oid --- if the types weren't binary-compatible
then we'd have had bigger issues.
What I'm inclined to do in the back branches is just correct the
catalogs without bumping catversion (since we can't do that).
At least installations initdb'd in future will have it right.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: mismatching proargtypes/proallargtypes (bug #10122)
2014-04-24 00:22 mismatching proargtypes/proallargtypes (bug #10122) Andres Freund <andres@2ndquadrant.com>
2014-04-24 00:37 ` Re: mismatching proargtypes/proallargtypes (bug #10122) Tom Lane <tgl@sss.pgh.pa.us>
@ 2014-04-24 01:06 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2014-04-24 01:26 ` Re: mismatching proargtypes/proallargtypes (bug #10122) Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 4+ messages in thread
From: Alvaro Herrera @ 2014-04-24 01:06 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Andres Freund <andres@2ndquadrant.com>; pgsql-bugs
Tom Lane wrote:
> Andres Freund <andres@2ndquadrant.com> writes:
> > '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.
>
> Ugh, how annoying.
Argh!
> What I'm inclined to do in the back branches is just correct the
> catalogs without bumping catversion (since we can't do that).
> At least installations initdb'd in future will have it right.
Maybe we can provide an UPDATE to fix it in existing installations, for
those interested in doing so.
--
Álvaro Herrera 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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: mismatching proargtypes/proallargtypes (bug #10122)
2014-04-24 00:22 mismatching proargtypes/proallargtypes (bug #10122) Andres Freund <andres@2ndquadrant.com>
2014-04-24 00:37 ` Re: mismatching proargtypes/proallargtypes (bug #10122) Tom Lane <tgl@sss.pgh.pa.us>
2014-04-24 01:06 ` Re: mismatching proargtypes/proallargtypes (bug #10122) Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2014-04-24 01:26 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Tom Lane @ 2014-04-24 01:26 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Andres Freund <andres@2ndquadrant.com>; pgsql-bugs
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Tom Lane wrote:
>> Andres Freund <andres@2ndquadrant.com> writes:
>>> '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.
>> Ugh, how annoying.
> Argh!
On reflection it's not quite as bad as it seems: the correct signature of
the function is pg_identify_object(oid,oid,integer) and the regprocedure
code does accept that. AFAICT the only readily visible effect of the bug
is that psql's \df lies about what the input argument datatypes are.
> Maybe we can provide an UPDATE to fix it in existing installations, for
> those interested in doing so.
Doubt it's worth the trouble really ...
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2014-04-24 01:26 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-04-24 00:22 mismatching proargtypes/proallargtypes (bug #10122) Andres Freund <andres@2ndquadrant.com>
2014-04-24 00:37 ` Tom Lane <tgl@sss.pgh.pa.us>
2014-04-24 01:06 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2014-04-24 01:26 ` Tom Lane <tgl@sss.pgh.pa.us>
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