pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Support opfamily members in get_object_address
2+ messages / 2 participants
[nested] [flat]

* pgsql: Support opfamily members in get_object_address
@ 2015-03-16 15:07  Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 1 reply; 2+ messages in thread

From: Alvaro Herrera @ 2015-03-16 15:07 UTC (permalink / raw)
  To: pgsql-committers

Support opfamily members in get_object_address

In the spirit of 890192e99af and 4464303405f: have get_object_address
understand individual pg_amop and pg_amproc objects.  There is no way to
refer to such objects directly in the grammar -- rather, they are almost
always considered an integral part of the opfamily that contains them.
(The only case that deals with them individually is ALTER OPERATOR
FAMILY ADD/DROP, which carries the opfamily address separately and thus
does not need it to be part of each added/dropped element's address.)
In event triggers it becomes possible to become involved with individual
amop/amproc elements, and this commit enables pg_get_object_address to
do so as well.

To make the overall coding simpler, this commit also slightly changes
the get_object_address representation for opclasses and opfamilies:
instead of having the AM name in the objargs array, I moved it as the
first element of the objnames array.  This enables the new code to use
objargs for the type names used by pg_amop and pg_amproc.

Reviewed by: Stephen Frost

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a61fd5334eb1040d0dcec0368702398a5b49152c

Modified Files
--------------
src/backend/catalog/objectaddress.c          |  234 ++++++++++++++++++++------
src/backend/commands/dropcmds.c              |   24 ++-
src/backend/commands/event_trigger.c         |    2 +
src/backend/parser/gram.y                    |   43 ++---
src/include/nodes/parsenodes.h               |    2 +
src/test/regress/expected/object_address.out |   60 ++++---
src/test/regress/sql/object_address.sql      |   16 +-
7 files changed, 264 insertions(+), 117 deletions(-)


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


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: pgsql: Support opfamily members in get_object_address
@ 2015-03-16 20:41  Peter Eisentraut <peter_e@gmx.net>
  parent: Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Peter Eisentraut @ 2015-03-16 20:41 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@alvh.no-ip.org>; pgsql-committers

On 3/16/15 11:07 AM, Alvaro Herrera wrote:
> Support opfamily members in get_object_address

I get compiler warnings from this:

objectaddress.c: In function ‘get_object_address’:
objectaddress.c:1428:12: warning: array subscript is above array bounds
[-Warray-bounds]
objectaddress.c:1430:11: warning: array subscript is above array bounds
[-Warray-bounds]

This looks fishy:

1423   i = 0;
1424   foreach (cell, objargs)
1425   {
1426     ObjectAddress  typaddr;
1427
1428     typenames[i] = strVal(lfirst(cell));
1429     typaddr = get_object_address_type(OBJECT_TYPE, cell, missing_ok);
1430     typeoids[i] = typaddr.objectId;
1431     if (i++ >= 2)
1432       break;
1433   }

Since you're using a postfix increment, the loop will execute with i =
2, which will lead to the array bounds violation.



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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2015-03-16 20:41 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-03-16 15:07 pgsql: Support opfamily members in get_object_address Alvaro Herrera <alvherre@alvh.no-ip.org>
2015-03-16 20:41 ` Peter Eisentraut <peter_e@gmx.net>

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