Should we replace the checks for access method OID with handler OID?

From: Ashutosh Sharma <ashu(dot)coek88(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Should we replace the checks for access method OID with handler OID?
Date: 2020-08-27 09:37:31
Message-ID: CAE9k0Pmm4yyozqcfz5RiL0CawAyu6FVQu4Su8ViAt0G0eaQyew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi All,

While reviewing the patch for pg_surgery contrib module - [1], Asim
Praveen suggested that it would be better to replace the check for
access method OID with handler OID. Otherwise, if someone creates a
new AM using the AM handler that is originally supported for e.g.
"heap_tableam_handler" and if this new AM is used to create a table,
then one cannot perform surgery on such tables because we have checks
for access method OID which would reject this new AM as we only allow
heap AM. For e.g. if we do this:

create access method myam type table handler heap_tableam_handler;
create table mytable (…) using myam;

And use an access method OID check, we won't be able to perform
surgery on mytable created above because it isn't the heap table
although its table structure is actually heap.

This problem won't be there if the check for access method OID is
replaced with handler OID. I liked this suggestion from Asim and did
the changes accordingly. However, while browsing the code for other
contrib modules, I could find such checks present in some of the
contrib modules like pgstattuple, pageinspect and pgrowlocks as well.
So, just wondering if we should be doing similar changes in these
contrib modules also.

Thoughts?

[1] - https://www.postgresql.org/message-id/1D56CEFD-E195-4E6B-B870-3383E3E8C65E%40vmware.com

--
With Regards,
Ashutosh Sharma
EnterpriseDB:http://www.enterprisedb.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sachin Khanna 2020-08-27 09:55:52 RE: Help needed configuring postgreSQL with xml support
Previous Message John Naylor 2020-08-27 09:24:37 Re: factorial function/phase out postfix operators?