pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: a <372660931@qq.com>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: Re:  Is it possible to get username information while writingtrigger?
Date: Mon, 07 May 2018 10:59:20 +0200
Message-ID: <1525683560.2414.8.camel@cybertec.at> (raw)
In-Reply-To: <tencent_130940D2578FB98F02A3245C@qq.com>
References: <tencent_5889CA742370FDD1149BA470@qq.com>
	<1525679840.2414.3.camel@cybertec.at>
	<tencent_130940D2578FB98F02A3245C@qq.com>

a wrote:
> Please allow me to ask few more questions:
> 
> 1, Since I'm writing a C trigger function, is there any method for me to get some of the
>    basic information like the follow:
> 
>      (1) Total number of rows;
>      (2) Rows' names;
>      (3) Value of OLD and NEW;
> 
> 2, Is there any possibility of passing the SQL statement it self into the trigger?
> 
> 3, Is it possible for me to exam before statement trigger so that I would be able to loop it
>    once and copying the update information to the rest of rows.

I don't know if there is a reliable way to get the SQL statement from
a C trigger.

For the other things, perhaps a statement level trigger with transition
relations can help.

You can then access the transition relations from your C code with
the tg_oldtable and tg_newtable tuplestores.
(https://www.postgresql.org/docs/current/static/trigger-interface.html)

Yours,
Laurenz Albe
-- 
+43-670-6056265
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26, A-2700 Wiener Neustadt
Web: https://www.cybertec-postgresql.com




view thread (5+ messages)  latest in thread

Message-ID: <1525683560.2414.8.camel@cybertec.at>
Permalink:  ../1525683560.2414.8.camel@cybertec.at/
Also on:    postgresql.org/message-id/1525683560.2414.8.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: laurenz.albe@cybertec.at, 372660931@qq.com
  Subject: Re: Is it possible to get username information while writingtrigger?
  In-Reply-To: <1525683560.2414.8.camel@cybertec.at>
  References: <tencent_5889CA742370FDD1149BA470@qq.com> <1525679840.2414.3.camel@cybertec.at> <tencent_130940D2578FB98F02A3245C@qq.com> <1525683560.2414.8.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox