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 1g76Kv-0000jV-Nz for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Oct 2018 22:06:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g76Kt-0000TY-U8 for pgsql-hackers@arkaria.postgresql.org; Mon, 01 Oct 2018 22:06:39 +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 1g76Kt-0000TR-Mi for pgsql-hackers@lists.postgresql.org; Mon, 01 Oct 2018 22:06:39 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1g76Kq-0002KO-Sp for pgsql-hackers@postgresql.org; Mon, 01 Oct 2018 22:06:38 +0000 Received: by mail-qt1-x841.google.com with SMTP id v19-v6so2463372qtg.2 for ; Mon, 01 Oct 2018 15:06:36 -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=REwOzrvQUM/dO1aXdnS0fo4Ape0MWSlOse3OsJO7SWg=; b=VhJsAOWcAMxzTn8+Ia60A8why6kQvlifM7iUrDctqLta5mbMdwExOTcVzzvVOIgR6L MCay+9/x76qXowad+2omi74O19MOWksH+eGnqWijAQSupKoqo7aXCezzpCkjumj5DpO9 EiCBB8sS/APf3JD1a7AJixKlJOojcWdtZ8MWdpRjADO7B4X4RfYCiD8Z8a7hQyWwJKNu RMSxs7BU8Be1GRjCEbpgRNg5iJnCCo3QyYjNaVzFyiCxD4TDvvkJ0n7jIifp9jVgVYV2 VmKXvWrWPvF5iH7oSiteOA8jZOBReXUb58u4yQhMUNzEGmmgfBNpN6qrUuXQV34v9JmN Tvrw== 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=REwOzrvQUM/dO1aXdnS0fo4Ape0MWSlOse3OsJO7SWg=; b=X0j6bFvGtEnjnRoRFtOc/IvorRALbvotskaSfOXUVmR0dyEck7QLxD+9uQz/lGXyyj 8ATI6qRh6MScFb/OxCQUUMYT4v9JUwHUckwXIVl/ja51EMDDnJxU1Rkwow+VaaCGoe61 A9/Qkb4fhQ2sbUhDOVdDYVLgvDTSZOJctIz2cMXhziuA7Q/57CNBBsLx8DbIa4UCL4xc kY8RCJy/h3dn2fikM2zOrOGvAY1IIv/woKuS63YkGdEKmWk5GvaAZOpin5c6tCI5l+jH dbItXEC/eojGmeh6bjqnKw0MUpXFa+douWhzGGOkATAi2+6F3UTbyEueAcSqkopC1Vls QrsQ== X-Gm-Message-State: ABuFfojd33Fzxe7usx9GIp4X3xzw2CtB0I3iNdEk5sb+3QRXGTcmujEO +Iol7TIQR5BsnqmNkXu2w/PWAQ== X-Google-Smtp-Source: ACcGV62u/3nlx8kMtkcPRvmsOtjJ+u+bOwf4ZyKf7kLP7+HbYcice5nkXVx2VGB9H/4xWVAxQli74w== X-Received: by 2002:a0c:96a1:: with SMTP id a30-v6mr10187491qvd.143.1538431595148; Mon, 01 Oct 2018 15:06:35 -0700 (PDT) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id x191-v6sm7524279qkb.93.2018.10.01.15.06.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Oct 2018 15:06:34 -0700 (PDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 986A570B; Mon, 1 Oct 2018 19:06:32 -0300 (-03) Date: Mon, 1 Oct 2018 19:06:32 -0300 From: Alvaro Herrera To: Peter Eisentraut Cc: Michael Paquier , "Yotsunaga, Naoki" , 'Postgres hackers' Subject: Re: automatic restore point Message-ID: <20181001220632.7a4jnzph2cwntq6w@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <544ca174-f0a1-fe75-ce74-3625fbc09447@2ndquadrant.com> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Oct-01, Peter Eisentraut wrote: > The following appears to work: > > CREATE FUNCTION evt_automatic_restart_point() RETURNS event_trigger > LANGUAGE plpgsql > AS $$ > BEGIN > PERFORM pg_create_restore_point(tg_tag); > END > $$; > > CREATE EVENT TRIGGER automatic_restart_point ON ddl_command_start > EXECUTE PROCEDURE evt_automatic_restart_point(); > > Are there any concerns about this? Mumble. Re-reading the implementation in standard_ProcessUtility, I wonder what is PROCESS_UTILITY_QUERY_NONATOMIC -- there seems to be a maze through SPI that determines whether this flag is set or not, which could affect whether the event trigger is useful. Are utilities executed through a procedure detected by event triggers? If so, then this mechanism seems good enough to me. But if there's a way to sneak utility commands (DROP TABLE) without the event trigger being invoked, then no (and in that case maybe it's just a bug in procedures and we can still not include this patch). (Grepping for "atomic" is unsurprisingly unhelpful. I really wish we didn't use plain words as struct member names ...) On the TRUNCATE case it's a bit annoying that you can't do it with event triggers -- you have to create individual regular triggers on truncate for each table (so you probably need yet another event trigger that creates such triggers). -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services