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 1iIa2i-0008JY-HJ for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2019 15:07:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIa2g-00036j-Au for pgsql-general@arkaria.postgresql.org; Thu, 10 Oct 2019 15:07:50 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIa2g-00036T-0s for pgsql-general@lists.postgresql.org; Thu, 10 Oct 2019 15:07:50 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIa2b-0001L0-Jk for pgsql-general@postgresql.org; Thu, 10 Oct 2019 15:07:49 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id E7D097A4; Thu, 10 Oct 2019 11:07:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 10 Oct 2019 11:07:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=t iJmcpVlb1UlWUZLJJKvAYwrr/2amy5568KvGxL+83Y=; b=jM584NZxrvHVo9+4W VualGCSK8NwUH7TjRoT2VatbT/QTnttXudEgWBr+KV/Yo33jCI5pgI/7ULbHvrS5 H7lpA1/c9u5QRrZh4loOOfGIYZ61uaz8ik0SSPuQ8a2ADHXYNzQqYmVRNnnGFulc 1faImXbfjfSosdgQ2VGDyrmwL+pmaNtagU0gt2uEACGbFBS7+faNNnRFGZ5wCfHi z0LyaqiPH2yGkuMVJ14Nl0m0HDiRnLg3B70bpfWZn2b/eW/tMLPNz8d2yMBbyl7W j2NAajLsStLveMK+xYRa0pzjFSA+1MAPFmo+1Pbm5DYbNj+95t1qyN2e9QwsrT58 WLp8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=tiJmcpVlb1UlWUZLJJKvAYwrr/2amy5568KvGxL+8 3Y=; b=Fu68HrAjQghYw5hfEAUzVIR2WrKx/VOzQJRUa7BD7aS5DgHduDEY8Ne5E iGFkDxUKz3pjxZRIVEDV21CqBcENQRhIx/U8NR1+U+7dK8nYTxlBgzh/SxhNT/SB nm/+yrHUbHrmPH1srq7clvPGu1+UXtX2sRZ+Ql2TSuB4hAOOYGrEt0hQun+FUdaJ sjGVanQHAIxY6BuaBl37T33BYiLBATKaF6jGcWMaD5gLa3XnjroIGIJHks4jngpr PyaNSHWjBiJD5w/UipgS8SKXEVUTD0KZTTQcGOFFzVrugwZ1LAsgVtypu923w1cY +F++WviFosk6ThM/ieCV/lo5irWbQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrieefgdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtkeertddtfeejnecuhfhrohhmpeetughrihgr nhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh eqnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucfkphepudejgedrvddu rdekledrvddukeenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvh gvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.2] (174-21-89-218.tukw.qwest.net [174.21.89.218]) by mail.messagingengine.com (Postfix) with ESMTPA id A3606D60068; Thu, 10 Oct 2019 11:07:40 -0400 (EDT) Subject: Re: Event Triggers and GRANT/REVOKE To: Miles Elam Cc: PG-General Mailing List References: <80a52d0f-497b-daf5-c1b4-40dc1fad70d0@aklaver.com> From: Adrian Klaver Message-ID: <58abb5fa-ed73-2487-764b-1bf061ba0339@aklaver.com> Date: Thu, 10 Oct 2019 08:07:39 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 10/9/19 3:20 PM, Miles Elam wrote: > Using my example below from another thread, GRANTs and REVOKEs leave all > fields NULL except for command_tag (set to 'GRANT' or 'REVOKE'), > object_type (set to upper case target like 'TABLE'), and in_extension > (set to whatever is appropriate, but typically false). From the source: https://doxygen.postgresql.org/event__trigger_8c.html#a4fc09f5b8231780b7f1abdd2a72f95a7 https://doxygen.postgresql.org/event__trigger_8c.html#a2b4e240a2c0aa9cfcc61f906af134913 Line 2185 case SCT_Grant Looks like the information is never collected. The why is going to need an answer from a developer. As to case it looks like GRANT/REVOKE use a different method of deriving the string then other commands, namely using stringify_adefprivs_objtype() > > ----- > > CREATE TABLE IF NOT EXISTS ddl_info ( >   classid oid, >   objid oid, >   objsubid integer, >   command_tag text, >   object_type text, >   schema_name text, >   object_identity text, >   in_extension bool, >   transaction_id bigint NOT NULL DEFAULT txid_current(), >   inserted timestamptz NOT NULL DEFAULT clock_timestamp() > ); > > CREATE OR REPLACE FUNCTION ddl_log() > RETURNS EVENT_TRIGGER > LANGUAGE plpgsql AS $$ > BEGIN >   INSERT INTO ddl_info ( >     classid, objid, objsubid, command_tag, object_type, >     schema_name, object_identity, in_extension >   ) >   SELECT >     classid, objid, objsubid, command_tag, object_type, >     schema_name, object_identity, in_extension >   FROM pg_event_trigger_ddl_commands(); > END; > $$; > > CREATE EVENT TRIGGER aa_ddl_info ON ddl_command_end > EXECUTE PROCEDURE ddl_log(); > > On Wed, Oct 9, 2019 at 2:27 PM Adrian Klaver > wrote: > > On 10/9/19 1:56 PM, Miles Elam wrote: > > GRANT and REVOKE trigger on a ddl_command_end event trigger but > don't > > provide any information beyond whether it was a table, schema, > function, > > etc. that was affected. No object IDs or the like are included. How > > would you find out which table had its ACLs modified? > > What is the code for trigger and function? > > > > > Also, why do grants and revokes have an object_type of 'TABLE' > instead > > of lower case names like 'table' for all other event types? > > > > > > Thanks, > > > > Miles Elam > > > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com