Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcEHm-0005k0-8w for pgsql-general@arkaria.postgresql.org; Sun, 08 Jul 2018 18:19:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fcEHk-0004gx-11 for pgsql-general@arkaria.postgresql.org; Sun, 08 Jul 2018 18:19:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcEHj-0004gp-LQ for pgsql-general@lists.postgresql.org; Sun, 08 Jul 2018 18:19:47 +0000 Received: from mail-qk0-x243.google.com ([2607:f8b0:400d:c09::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fcEHX-0006oh-Jl for pgsql-general@postgresql.org; Sun, 08 Jul 2018 18:19:46 +0000 Received: by mail-qk0-x243.google.com with SMTP id t79-v6so8704193qke.4 for ; Sun, 08 Jul 2018 11:19:35 -0700 (PDT) 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=XaVM2aB/lvYDD0/1Zh3UACHO3oFl5JsMrOHR5CeUGO8=; b=t6+at7qrzopXq8neTRQ1L9V18QaC5sUIfHYgDFmIzqmIPBY5BT79uaembncKGCGfxw eIUB+x2/cWqs+u3CPZWlp05IpcVMQV1RATPJevYbMXHQdfeNZFNHuE0e259ZkSK01Lj2 i6CWLZSiORvSfLal88VwFfu3rpxgIJ+rDcLwanX+54rKG63UCUgdnX7F0IV8vh8nFeO+ S178TcPsKrrY8IhrJOblyVrzjAc3NH6z89DPMGtxsvA1H6oPkDGZ2RRJRrmsdACzIuln F6mQjRh3+e9ZU2/aIGXye6YHz6Jqj27TMZQH29DwCsivj/HhQwx3BXC6mA4WD+UaXY7i nwbw== 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=XaVM2aB/lvYDD0/1Zh3UACHO3oFl5JsMrOHR5CeUGO8=; b=PlyXAqWRUf/N5Jyoo7ZPyw94jy3A1TpgouqftKk3nsf9zH2fItDpG3dKoeS+x/bhdl d86cGMTGEmL0cy9bwo6zjwwacY33cJfKD/6DKLJN/G73zJeLj/U0HxFICCjLdPoW3ohs wzl0MFNtg/fV+JNMBS5HXwvtFpepWrwRJgnX1Trk9tU9iXzEwZI+o7BAkFvrdpl/2DL0 JfSz2lfU9HWnmR5DZvqL+vmv8Bu2BKJFRY+WuVBUboABnpaaJErxRU4Pob2lbDj8kAaH g0lxfN4FV1dNmN4Bl4fvMJHZSWub5fr01T0wsmUZK69ni1vCN5xwkGkAZ779BPlUfDpL Qd1g== X-Gm-Message-State: APt69E0jf27UfMz+d4v6D8Wg3NFmvk0u/YN/EKLpOGVj/lxEqvIDk+Dp Mfa2yzKuajgqKWv1yxDJBEYf8g== X-Google-Smtp-Source: AAOMgpdDgdaekk3X2k7md5zTufL3wh16Hv5TfsCngsSupwNUMJ7QiqTfcx91PDH+N7J2dTLAGdYF1Q== X-Received: by 2002:a37:3609:: with SMTP id d9-v6mr15009535qka.419.1531073973575; Sun, 08 Jul 2018 11:19:33 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([201.186.80.250]) by smtp.gmail.com with ESMTPSA id j6-v6sm10539304qtj.92.2018.07.08.11.19.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 08 Jul 2018 11:19:32 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id EE2AD454; Sun, 8 Jul 2018 14:19:29 -0400 (-04) Date: Sun, 8 Jul 2018 14:19:29 -0400 From: Alvaro Herrera To: Demitri Muna Cc: pgsql-general@postgresql.org Subject: Re: ddl_command_end not firing DROP events Message-ID: <20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Jul-08, Demitri Muna wrote: Hi > I’ve created a trigger where I want to capture schema-changing events. > I’m finding that DROP events are not being triggered when using > “ddl_command_end". The test case below demonstrates this. I am running > PostgreSQL 10.4. The trigger is fired for the CREATE event, but not > DROP TYPE or DROP TABLE. > > I came across the same question on the mailing list, but the solution > was to use the “sql_drop” trigger instead. > > https://www.postgresql.org/message-id/CAHE3wgjX-N%3DX9mccp4Bs-y-%3DHE%3DqayHEpXpCs1jMT%3DW0ZsYc5A%40mail.gmail.com As I recall, handling of DROP events in the ddl_command_end event is not completely consistent. You may even find that some DROP events are not returned by pg_event_trigger_ddl_commands. I suggest you stick to pg_event_trigger_dropped_objects() instead (for which you need sql_drop). -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services