Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iPgmK-0001du-1e for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Oct 2019 05:44:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iPgmH-0002Lc-Aq for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Oct 2019 05:44:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iPgmG-0002LV-VM for pgsql-hackers@lists.postgresql.org; Wed, 30 Oct 2019 05:44:17 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iPgmA-00056e-HL for pgsql-hackers@lists.postgresql.org; Wed, 30 Oct 2019 05:44:15 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9U5i5IC029371; Wed, 30 Oct 2019 01:44:05 -0400 From: Tom Lane To: Alvaro Herrera cc: Robert Haas , PostgreSQL Hackers Subject: Re: Rearranging ALTER TABLE to avoid multi-operations bugs In-reply-to: <20191030011039.GA9097@alvherre.pgsql> References: <20191030011039.GA9097@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Tue, 29 Oct 2019 22:10:39 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29369.1572414245.1@sss.pgh.pa.us> Date: Wed, 30 Oct 2019 01:44:05 -0400 Message-ID: <29370.1572414245@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alvaro Herrera writes: > On 2019-Oct-29, Tom Lane wrote: >> The thing I think you are actually worried about is the interaction >> with event triggers, which is already a pretty horrid mess in this >> code today. I don't really follow the comment here about >> "ordering of queued commands". It looks like that comment dates to >> Alvaro's commit b488c580a ... can either of you elucidate that? > The point of that comment is that if you enqueue the commands as they > are returned by pg_event_trigger_ddl_commands() (say by writing them to > a table) they must be emitted in an order that allows them to be > re-executed in a remote server that duplicates this one, and the final > state should be "the same". Hm. I don't think I understand what is the use-case behind all this. If "ALTER TABLE tab DO SOMETHING" generates some subcommands to do what it's supposed to do, and then an event trigger is interested in replaying that ALTER, how is it supposed to avoid having the subcommands happen twice? That is, it seems like we'd be better off to suppress the generated subcommands from the event stream, because they'd just get generated again anyway from execution of the primary command. Or, if there's something that is interested in knowing that those subcommands happened, that's fine, but they'd better be marked somehow as informative rather than something you want to explicitly replay. (And if they are just informative, why is the ordering so critical?) regards, tom lane