Re: Cache lookup errors with functions manipulation object addresses
Michael Paquier <michael.paquier@gmail.com>
From: Michael Paquier <michael.paquier@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-hackers@postgresql.org>,
Moshe Jacobson <moshe@neadwerx.com>, Alvaro Herrera <alvherre@2ndquadrant.com>
Date: 2017-07-20T13:59:37Z
Lists: pgsql-hackers
Attachments
- objaddr_nullness_v1.patch.gz (application/x-gzip) patch v1
On Wed, Jul 19, 2017 at 7:29 PM, Robert Haas <robertmhaas@gmail.com> wrote: > On Wed, Jul 19, 2017 at 2:25 AM, Michael Paquier > <michael.paquier@gmail.com> wrote: >> Would we want to improve the error handling of such objects? > > +1 for such an improvement. Attached is a patch for all that. Here are some notes: - format_type_be and friends use allow_invalid. I have added a flag to control the NULL-ness as many code paths rely on existing APIs, and introduced an _extended version of this API. I would argue for the removal of allow_invalid to give more flexibility to callers, but this impacts extensions :( - A similar thing is needed for format_operator(). - We could really add a missing_ok to get_attname, but that does not seem worth the refactoring with modules potentially calling it.. - GetForeignDataWrapper is extended with a missing_ok, unfortunately not saving one cache lookup in GetForeignDataWrapperByName. - Same remark as the previous one for GetForeignServer. - get_publication_name and get_subscription_name gain a missing_ok. - getObjectDescription and getObjectIdentity are called in quite a couple of places. We could have those have a kind of missing_ok, but as the status is just for adding cache lookup errors I have kept the interface simple as this keeps the code in objectaddress.c more simple as well. getObjectIdentity is used mainly in sepgsql, which I have not compiled yet so I may have missed something :) getObjectDescription is used in more places in the backend code, but I am not much into complicating the objaddr API with this patch more. - I have added tests for all the OCLASS objects, for a total more or less 120 cache lookup errors that a user can face. - Some docs are present as well, but I think that they are a bit incomplete. I'll review them a bit later. - The patch is large, 800 lines are used for the tests which is very mechanical: 32 files changed, 1721 insertions(+), 452 deletions(-) Thanks, -- Michael
Commits
-
Eliminate cache lookup errors in SQL functions for object addresses
- 2a10fdc4307a 14.0 landed
-
Refactor routines for name lookups of procedures and operators
- aa38434824c4 14.0 landed
-
Add new flag to format_type_extended() to get NULL for undefined type
- 1185c782943c 14.0 landed
-
Introduce new extended routines for FDW and foreign server lookups
- 8fb569e978af 12.0 landed
-
Refactor routines for subscription and publication lookups
- 1d6fbc38d9ed 12.0 landed
-
get_relid_attribute_name is dead, long live get_attname
- 8237f27b504f 11.0 landed
-
Tweak parser so that there is a defined representation for datatypes
- a585c20d12d0 7.2.1 cited