Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wd7Qn-0001Aa-Ck for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Apr 2014 00:22:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Wd7Qm-0008CU-JP for pgsql-bugs@arkaria.postgresql.org; Thu, 24 Apr 2014 00:22:24 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wd7Qk-0008CL-Ee for pgsql-bugs@postgresql.org; Thu, 24 Apr 2014 00:22:22 +0000 Received: from moutng.kundenserver.de ([212.227.17.13]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Wd7Qc-0006jP-FO for pgsql-bugs@postgresql.org; Thu, 24 Apr 2014 00:22:21 +0000 Received: from anarazel.de (p5DDC7F28.dip0.t-ipconnect.de [93.220.127.40]) by mrelayeu.kundenserver.de (node=mreue104) with ESMTP (Nemesis) id 0LyDKf-1X0a9J3NJN-015XiL; Thu, 24 Apr 2014 02:22:12 +0200 Received: by anarazel.de (Postfix, from userid 1000) id 08A78100598; Thu, 24 Apr 2014 02:22:12 +0200 (CEST) Date: Thu, 24 Apr 2014 02:22:11 +0200 From: Andres Freund To: pgsql-bugs@postgresql.org Subject: mismatching proargtypes/proallargtypes (bug #10122) Message-ID: <20140424002211.GD12442@awork2.anarazel.de> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k1lZvvs/B4yU6o8G" Content-Disposition: inline X-Provags-ID: V02:K0:v+rYq3R1J3cBNJcch/Ddzo/QpBNS1nxxefUJ/xnxHx8 gFh5juam3YaZNd7bWOSh0EBc3Kc1qQr1vnptyqbRA7iYyPNOv/ ZCNjU3QWwnFuts42i3v8fZxEZ/jSRtLkzWYezOeKWR9GClgtoy 12cHP4CNYYsswnTYY75q1SKf7DiIBX0F1n9VIqg+4+QuWIfUSn rLtWxZPtovf2Pt9i+upGu3KPR0PAUm+OZvC38k+SAB/ws/ohbi ynbQwmmwTsWM7PxgajQArLyIUXy1jYC+/MHTSN/QgEZ6Sase2R FUEd/5NGcWl04nJ2iNCKsjPzU3bgagxsQjNaCiAnkQMVS5s4BV MwxjITqgxTdKQtVidDBdRwtOGXWX9zmiMpNbMP9vu X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --k1lZvvs/B4yU6o8G Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-Fix-pg_proc-entries-with-mismatching-proargtypes-pro.patch" From 05c0d9b859b59c9ef85ed24b3b83df3104ffcef6 Mon Sep 17 00:00:00 2001 From: Andres Freund 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 --k1lZvvs/B4yU6o8G Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --k1lZvvs/B4yU6o8G--