2012/11/20 Kohei KaiGai <kaigai@kaigai.gr.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@2ndquadrant.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@kaigai.gr.jp>