some namespace.c refactoring

From: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: some namespace.c refactoring
Date: 2023-02-14 13:32:04
Message-ID: 12f1b1d2-f8cf-c4a2-72ec-441bd79546cb@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here are two patches that refactor the mostly repetitive "${object} is
visible" and get_${object}_oid() functions in namespace.c. This uses
the functions in objectaddress.c to look up the appropriate per-catalog
system caches and attribute numbers, similar to other refactoring
patches I have posted recently.

In both cases, there are some functions that have special behaviors that
are not easy to unify, so I left those alone for now.

Notes on 0001-Refactor-is-visible-functions.patch:

Among the functions that are being unified, some check temp schemas and
some skip them. I suppose that this is because some (most) object types
cannot normally be in temp schemas, but this isn't made explicit in the
code. I added a code comment about this, the way I understand it.

That said, you can create objects explicitly in temp schemas, so I'm not
sure the existing code is completely correct.

Notes on 0002-Refactor-common-parts-of-get_-_oid-functions.patch:

Here, I only extracted the common parts of each function but left the
actual functions alone, because they each have to produce their own
error message. There is a possibility to generalize this further,
perhaps in the style of does_not_exist_skipping(), but that looked like
a separate step to me.

Attachment Content-Type Size
0001-Refactor-is-visible-functions.patch text/plain 26.3 KB
0002-Refactor-common-parts-of-get_-_oid-functions.patch text/plain 8.1 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pradeep Kumar 2023-02-14 13:39:49 Extensible Rmgr for Table Ams
Previous Message Peter Eisentraut 2023-02-14 12:51:02 Re: appendBinaryStringInfo stuff