dbTalk Databases Forums  

[SQL] Transaction-specific global variable

mailing.database.pgsql-sql mailing.database.pgsql-sql


Discuss [SQL] Transaction-specific global variable in the mailing.database.pgsql-sql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Florian Weimer
 
Posts: n/a

Default [SQL] Transaction-specific global variable - 02-03-2011 , 03:10 AM






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 (AT) bfk (DOT) 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

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [SQL] Transaction-specific global variable - 02-03-2011 , 10:31 AM






Florian Weimer <fweimer (AT) bfk (DOT) de> writes:
Quote:
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

--
Sent via pgsql-sql mailing list (pgsql-sql (AT) postgresql (DOT) org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.