pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Transaction-specific global variable
2+ messages / 2 participants
[nested] [flat]

* Transaction-specific global variable
@ 2011-02-03 09:10 Florian Weimer <fweimer@bfk.de>
  2011-02-03 16:31 ` Re: Transaction-specific global variable Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Florian Weimer @ 2011-02-03 09:10 UTC (permalink / raw)
  To: pgsql-sql

hstore greatly simplifies creating triggers for logging table changes,
which is great.  However, when creating a log record, I would like to
include information about the party who made this change.  We
generally do not allow direct database access for application code, so
the PostgreSQL user does not provide sufficient information on its
own.  Instead, I'd like to create a transaction-specific variable
which stores context information to be included in the log table.  I
suppose I could create a stored procedures in C which provides this
functionality, but I wonder if there is already something similar I
could reuse.  For instance, I could reuse the application_name
configuration variable, but this seems a bit gross.

(If you could recommend logging functionality I could learn from, that
would be welcome, too.)

-- 
Florian Weimer                <fweimer@bfk.de>
BFK edv-consulting GmbH       http://www.bfk.de/
Kriegsstraße 100              tel: +49-721-96201-1
D-76133 Karlsruhe             fax: +49-721-96201-99



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Transaction-specific global variable
  2011-02-03 09:10 Transaction-specific global variable Florian Weimer <fweimer@bfk.de>
@ 2011-02-03 16:31 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2011-02-03 16:31 UTC (permalink / raw)
  To: Florian Weimer <fweimer@bfk.de>; +Cc: pgsql-sql

Florian Weimer <fweimer@bfk.de> writes:
> hstore greatly simplifies creating triggers for logging table changes,
> which is great.  However, when creating a log record, I would like to
> include information about the party who made this change.  We
> generally do not allow direct database access for application code, so
> the PostgreSQL user does not provide sufficient information on its
> own.  Instead, I'd like to create a transaction-specific variable
> which stores context information to be included in the log table.  I
> suppose I could create a stored procedures in C which provides this
> functionality, but I wonder if there is already something similar I
> could reuse.  For instance, I could reuse the application_name
> configuration variable, but this seems a bit gross.

You could abuse the custom-GUC-variable mechanism: just set
custom_variable_classes and then define some variable that doesn't
actually have any underlying loadable module.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2011-02-03 16:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-02-03 09:10 Transaction-specific global variable Florian Weimer <fweimer@bfk.de>
2011-02-03 16:31 ` Tom Lane <tgl@sss.pgh.pa.us>

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