Re: [v9.3] OAT_POST_ALTER object access hooks

From: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: PgHacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [v9.3] OAT_POST_ALTER object access hooks
Date: 2012-12-01 07:57:50
Message-ID: CADyhKSVs4ZXUfewSMyMvujOEFLE+=iJSN0+0aVa7uAY8EU3ueg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/11/20 Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>:
>>> The second hunk to alter.c does not apply anymore; please rebase.
>>>
>> OK,
>
> Oops, I assumed the patch for ALTER RENAME TO reworks. Sorry.
>
> 2012/11/20 Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>:
>> Kohei KaiGai wrote:
>>
>>> I'd like to have catalog/objectaccess.c to wrap-up invocation of hooks, rather
>>> than doing all the stuffs with macros. It allows to use local variables, unlike
>>> macros; that has a risk of naming conflict with temporary variable for
>>> ObjectAccessPostCreate.
>>
>> No objection from me.
>>
The attached patches are revised version of the previous one.
Please note that it assumes my reworks patch on ALTER ... RENAME TO
being applied on top of this patch.

The part-1 stuff simply adds wrap-up functions for object_access_hook.
InvokeObjectPostCreateHookArg() and InvokeObjectDropHookArg() replace
existing invocations of hooks with OAT_POST_CREATE and OAT_DROP.
In case of invocation without argument, callers can use their shorten form
defined in objectaccess.h.

The part-2 stuff is a main portion of this patch.
It newly adds OAT_POST_ALTER event type that shall be invoked just
after catalog updates. Extension side can see the identified object with
SnapshotNow for older version and SnapshotSelf for newer version, thus,
it can know which fields were updated around this event.

I still have a few points to be discussed.
* Do we need OAT_POST_ALTER hook even if no fields were updated
actually? In case when ALTER SET OWNER, it checks object's ownership
only when current and new user-id is not same. Right now, I follow this
manner on OAT_POST_ALTER invocation.
However, I'm inclined to consider the hook should be invoked when no
fields are actually updated also. (It allows extension-side to determine
necessity of processing something.)

* When tablespace of relation was changed, it seems to me the point to
invoke OAT_POST_ALTER hook should be "after" ATRewriteTable().
However, it usually long time to rewrite whole the table if it already have
large number of rows. I'm not 100% certain to put hook here, so this
version does not support hook when tablespace changes.

Any comments please.

Thanks,
--
KaiGai Kohei <kaigai(at)kaigai(dot)gr(dot)jp>

Attachment Content-Type Size
sepgsql-v9.3-post-alter-support.v3.part-1.patch application/octet-stream 23.6 KB
sepgsql-v9.3-post-alter-support.v3.part-2.patch application/octet-stream 93.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2012-12-01 08:09:04 Re: Proposal for Allow postgresql.conf values to be changed via SQL
Previous Message Tom Lane 2012-12-01 04:10:23 --single-transaction hack to pg_upgrade does not work