Thread: [HACKERS] pg_get_object_address() doesn't support composites
See below. ISTM that pg_get_object_address should support everything pg_identify_object_as_address can output, no? I'm guessing the answer here is to have pg_identify_object_as_address complain if you ask it for something that's not mapable. > ~@decina.local/5621# CREATE TYPE comp AS (a int, b int); > CREATE TYPE > ~@decina.local/5621# select * from pg_identify_object_as_address(1259,'comp'::regclass, 0); > type | object_names | object_args > ----------------+---------------+------------- > composite type | {public,comp} | {} > (1 row) > > ~@decina.local/5621# select * from pg_get_object_address('composite type', '{public,comp}', '{}'); > ERROR: unsupported object type "composite type" > ~@decina.local/5621# -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Analytics, Data Architecture and PostgreSQL Data in Trouble? Get it in Treble! http://BlueTreble.com 855-TREBLE2 (855-873-2532)
Jim Nasby wrote: > See below. ISTM that pg_get_object_address should support everything > pg_identify_object_as_address can output, no? > > I'm guessing the answer here is to have pg_identify_object_as_address > complain if you ask it for something that's not mapable. Yes, I think we should just reject the case in pg_identify_object_as_address. Note that you can refer to the type using it pg_type entry: alvherre=# select * from pg_identify_object_as_address(1247,'comp'::regtype, 0); type │ object_names │ object_args ──────┼───────────────┼─────────────type │ {public.comp} │ {} (1 fila) alvherre=# select * from pg_get_object_address('type', '{public.comp}', '{}');classid │ objid │ subobjid ─────────┼───────┼────────── 1247 │ 16400 │ 0 (1 fila) Trying to accept it using its pg_class entry would require adding an OBJECT_COMPOSITE_TYPE member to the ObjectType enum. I considered it back then, and eventually decided that it was not worth the trouble. Another way to think about this problem is an approach Peter E suggested not long ago, which was to change the objname/objargs representation more completely. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On 2/17/17 9:53 PM, Alvaro Herrera wrote: > Another way to think about this problem is an approach Peter E suggested > not long ago, which was to change the objname/objargs representation > more completely. Hrm, I didn't see that. What was the idea? BTW, I do find it odd (and might eventually find it irritating) that some objname's squash schema and name into a single element. Not sure that's worth fixing at this point, though. -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Analytics, Data Architecture and PostgreSQL Data in Trouble? Get it in Treble! http://BlueTreble.com 855-TREBLE2 (855-873-2532)
On 2/17/17 9:53 PM, Alvaro Herrera wrote: > Jim Nasby wrote: >> See below. ISTM that pg_get_object_address should support everything >> pg_identify_object_as_address can output, no? >> >> I'm guessing the answer here is to have pg_identify_object_as_address >> complain if you ask it for something that's not mapable. > Yes, I think we should just reject the case in > pg_identify_object_as_address. Attached patch does that, and tests for it. Note that there were some unsupported types that were not being tested before. I've added a comment requesting people update the test if they add more types. -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Analytics, Data Architecture and PostgreSQL Data in Trouble? Get it in Treble! http://BlueTreble.com 855-TREBLE2 (855-873-2532) -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Attachment
On 2/18/17 4:26 PM, Jim Nasby wrote: > On 2/17/17 9:53 PM, Alvaro Herrera wrote: >> Jim Nasby wrote: >>> See below. ISTM that pg_get_object_address should support everything >>> pg_identify_object_as_address can output, no? >>> >>> I'm guessing the answer here is to have pg_identify_object_as_address >>> complain if you ask it for something that's not mapable. >> Yes, I think we should just reject the case in >> pg_identify_object_as_address. > > Attached patch does that, and tests for it. Note that there were some > unsupported types that were not being tested before. I've added a > comment requesting people update the test if they add more types. While testing a view on pg_depend, I discovered this has the unfortunate side-effect of meaning you can no longer use pg_identify_object_as_address against pg_depend.ref*. Using it against pg_depend was already problematic though, because it throws an error on the pinned objects if you try and hand it classid, objid or objsubid. So maybe it's OK. -- Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX Experts in Analytics, Data Architecture and PostgreSQL Data in Trouble? Get it in Treble! http://BlueTreble.com 855-TREBLE2 (855-873-2532)