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.92) (envelope-from ) id 1jB3Er-0004S1-T5 for pgsql-general@arkaria.postgresql.org; Sun, 08 Mar 2020 21:13:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jB3Ep-0005XQ-G2 for pgsql-general@arkaria.postgresql.org; Sun, 08 Mar 2020 21:13:31 +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 1jB3Ep-0005UB-2e for pgsql-general@lists.postgresql.org; Sun, 08 Mar 2020 21:13:31 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jB3El-0002YV-Ej for pgsql-general@lists.postgresql.org; Sun, 08 Mar 2020 21:13:29 +0000 Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mailbackend.panix.com (Postfix) with ESMTP id 48bDbp03PRz1bHj; Sun, 8 Mar 2020 17:13:25 -0400 (EDT) Received: by panix5.panix.com (Postfix, from userid 17622) id 48bDbn5MhbzfYm; Sun, 8 Mar 2020 17:13:25 -0400 (EDT) Date: Sun, 8 Mar 2020 17:13:25 -0400 From: stan To: S??ndor Daku Cc: pgsql-general@lists.postgresql.org Subject: Re: Another INSTEAD OF TRIGGER question Message-ID: <20200308211325.GA29529@panix.com> References: <20200308142909.GA20937@panix.com> <20200308143130.GA1498@panix.com> <20200308202651.GA15465@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Editor: gVim List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Mar 08, 2020 at 10:07:24PM +0100, S??ndor Daku wrote: > On Sun, 8 Mar 2020 at 21:26, stan wrote: > > > On Sun, Mar 08, 2020 at 03:56:56PM +0100, S??ndor Daku wrote: > > > On Sun, 8 Mar 2020 at 15:31, stan wrote: > > > > > > > On Sun, Mar 08, 2020 at 10:29:09AM -0400, stan wrote: > > > > > Still working on updateable views. > > > > > > > > > > Wish list item, a way to see the entire query that caused the > > trigger to > > > > > fire. > > > > > > > > > > Now on to something i hope I can get. Can I see what the verb that > > caused > > > > > the trigger to fire is? IE UPDATE, INSERT, DELETE? > > > > > > > > > > -- > > > > > "They that would give up essential liberty for temporary safety > > deserve > > > > > neither liberty nor safety." > > > > > -- Benjamin Franklin > > > > > > > > > > > > > > > > > > OH, what was I thinking, that is controled by the trigger. > > > > > > > > -- > > > > "They that would give up essential liberty for temporary safety deserve > > > > neither liberty nor safety." > > > > -- Benjamin Franklin > > > > > > > > > > Hi, > > > > > > Still, you can access that information in the TG_OP variable available in > > > trigger functions because you can define triggers firing on > > > multiple operation types. > > > For instance this is an example from the Postgres documentation: > > > > > > CREATE TRIGGER emp_audit > > > INSTEAD OF INSERT OR UPDATE OR DELETE ON emp_view > > > FOR EACH ROW EXECUTE FUNCTION update_emp_view(); > > > > > > > Thaks for the info. > > > > Could yoou clarify how to acces this variable: > > > > This does not work: > > > > elog( NOTICE, "For OP $_TD->{TG_OP}" ) > > > > But this does work > > > > elog( NOTICE, "On Table $_TD->{table_name}" ); > > -- > > "They that would give up essential liberty for temporary safety deserve > > neither liberty nor safety." > > -- Benjamin Franklin > > > > Hi, > > Sorry I didn't know you are using something different than plpgsql. > You can check the actual syntax for your language(plperl I guess) here: > > https://www.postgresql.org/docs/11/server-programming.html > > Look for the "Trigger functions" section below the corresponding language. > Yes, it is not there, which explains why I did not see it. I can execute an SQL queryy from within plperl, do you think that will get this value? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin