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 1ijmtR-0000hI-JG for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Dec 2019 16:18:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ijmtP-00039C-C8 for pgsql-bugs@arkaria.postgresql.org; Tue, 24 Dec 2019 16:18:43 +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 1ijmtO-000395-Ts for pgsql-bugs@lists.postgresql.org; Tue, 24 Dec 2019 16:18:43 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ijmtI-00058O-12 for pgsql-bugs@lists.postgresql.org; Tue, 24 Dec 2019 16:18:41 +0000 Received: by mail-pf1-x443.google.com with SMTP id z16so10964756pfk.0 for ; Tue, 24 Dec 2019 08:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=N0OLu+FjwTL04gX9E8i56W/ahvbMLFrNSAOjErtyhn0=; b=OXQImnhr+CNTHRYDzCPzve7W8SA6V+EZGwbG+EHFTFEWZZvsbwimlvxaq7H//bpkKv 0InohrYavEbqz0Jab2QXvnC0bZo1OKJSc2TKpVdkOkTQDMVHgStt2xjKn7rP19eazAwx 4rqj0x7wb5NsWH4Am7HIe0QB6i4O8q0vhaYZm69NX3hNaOczgh9OvXQhtg4m2DeDfOM9 +30b6FCCZcjv5A365ylyiSW7KxWYfCxGIalYaKdtCIxw8/PLUshVJ/Np7ruNnDrfxqJG rPOx+gurhiQyTwOTaMuRmDRqmlGvkxKOYfROQH93aaGMl2nVuhk0NUuIAaDFRZNCkTDP EwPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=N0OLu+FjwTL04gX9E8i56W/ahvbMLFrNSAOjErtyhn0=; b=YkveEExjmINUvX+u2/Y5RX9dOz6DPfAwI6WHjdL/5umFV5m2QaV75POpSUOxH3R0mO qDBitJTo96/b30zn6BJSZDl+Qso3O+WqTQoB/LGJ5OjKIRJEkfDbpFzYaA+WvjMJwzM5 WSL6N0NKtOj2yl1+ZO4+hCmauFJpBuPY6HCuRf8UY0MaTXrGOmHYKdFP5ykq4ft5rRfO Y+5zZRaSW0gJ74B2eXW4D5pDnlKHTVvB4tna+6JnmriEMKlaClMk6I2JJj939D5SPFG5 Mi8byXOUpk15IzW62bzIpTCFf3oBU7Y9yxXbu77pi667ZXDRH7GiyRpfwQnGwEbQ5Hq3 dQFg== X-Gm-Message-State: APjAAAXtYQj/7mSnESq1sCMdeJRpVMRCf6fenD7hhaTfCu4LVDCnW6ka hn/LWijQnRJ4aUe1l60lH59+1Q== X-Google-Smtp-Source: APXvYqyqAYT5Ynk0ag4B7YFKfCyxAuPipldc8+Gcw5MUlICsnBhxKIYu2csrjfqNuIivSo5W64cXrA== X-Received: by 2002:a62:3343:: with SMTP id z64mr37360677pfz.150.1577204314847; Tue, 24 Dec 2019 08:18:34 -0800 (PST) Received: from nimloth.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id m14sm3857119pjf.10.2019.12.24.08.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2019 08:18:34 -0800 (PST) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 23517300A8F; Tue, 24 Dec 2019 13:18:28 -0300 (-03) Date: Tue, 24 Dec 2019 13:18:28 -0300 From: Alvaro Herrera To: Andrei Pozolotin Cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16177: pg_event_trigger_ddl_commands() returns empty set for ddl_command_start and "drop table" Message-ID: <20191224161828.GA14840@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <511b78e6435d03faa20d605a51aa3578@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello, On 2019-Dec-23, Andrei Pozolotin wrote: > 1. thank you for the idea, I have just tried that > > 2. I could not make it work, since "sql_drop" event > happens **after** the "drop table" has already being attempted > and failed due to table oid dependencies Well, that's really disappointing, but now that you say it, I remember that yes we had to save all table info prior to firing the trigger because it (the trigger) would run after the drop. I think there was a restriction that forced us to do things that way, but TBH I don't remember clearly. > 3. you may find it curious that I was in fact trying to improve on the > following trigger function: > https://github.com/2ndQuadrant/pglogical#automatic-assignment-of-replication-sets-for-new-tables > to make it work for "drop table" as well That makes sense. > 4. my current workaround is to move trigger logic for "create table"/"drop > table" > outside of postgre into the app layer, essentially doing via execute() > intercept: > * replicate_ddl_command("create table; replication_set_add_table();") > * replicate_ddl_command("replication_set_remove_table(); drop table;") That seems a decent workaround, if suboptimal. > 5. nonetheless, can you suggest any other way to make "event_trigger" work > for this scenario: > https://github.com/2ndQuadrant/pglogical#automatic-assignment-of-replication-sets-for-new-tables > ? I wonder if it's possible for pglogical to register pg_depend entries to the replication set, so that the repset membership is dropped alongside the table. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services