Re: Collect ObjectAddress for ATTACH DETACH PARTITION to use in event trigger

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: "houzj(dot)fnst(at)fujitsu(dot)com" <houzj(dot)fnst(at)fujitsu(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, "kuroda(dot)hayato(at)fujitsu(dot)com" <kuroda(dot)hayato(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Collect ObjectAddress for ATTACH DETACH PARTITION to use in event trigger
Date: 2022-07-20 11:06:13
Message-ID: CAA4eK1KEZ86w-k+yZFyZTMrWUW6BfF21V8tiOBpSiA4pz4A0hw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 15, 2022 at 11:39 AM houzj(dot)fnst(at)fujitsu(dot)com
<houzj(dot)fnst(at)fujitsu(dot)com> wrote:
>
> On Friday, July 15, 2022 11:41 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> Hi,
> >
> > On Fri, Jul 15, 2022 at 03:21:30AM +0000, kuroda(dot)hayato(at)fujitsu(dot)com wrote:
> > > Sounds good. I grepped ATExecXXX() functions called in ATExecCmd(),
> > > and I confirmed that all returned values have been collected except them.
> > >
> > > While checking test code test about EVENT TRIGGER, I found there were
> > > no tests related with partitions in that.
> > > How about adding them?
> >
> > Agreed. It would be good to track down what changes once those
> > ObjectAddresses are collected.
>
> Thanks for having a look. It was a bit difficult to add a test for this.
> Because we currently don't have a user function which can return these
> collected ObjectAddresses for ALTER TABLE. And It seems we don't have tests for
> already collected ObjectAddresses as well :(
>
> The collected ObjectAddresses is in
> "currentEventTriggerState->currentCommand->d.alterTable.subcmds.address" while
> the public function pg_event_trigger_ddl_commands doesn't return these
> information. It can only be used in user defined event trigger function (C
> code).
>
> If we want to add some tests for both already existed and newly added
> ObjectAddresses, we might need to add some test codes in test_ddl_deparse.c.
> What do you think ?
>

Right. But, I noticed that get_altertable_subcmdtypes() doesn't handle
AT_AttachPartition or AT_DetachPartition. We can handle those and at
least have a test for those in test_ddl_deparse\sql\slter_table.sql. I
know it is not directly related to your patch but that way we will at
least have some tests for Attach/Detach partition and in the future
when we extend it to test ObjectAddresses of subcommands that would be
handy. Feel free to write a separate patch for the same.

--
With Regards,
Amit Kapila.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amul Sul 2022-07-20 11:08:17 GetStandbyFlushRecPtr() : OUT param is not optional like elsewhere.
Previous Message Matthias van de Meent 2022-07-20 11:00:48 Re: Make name optional in CREATE STATISTICS