Re: Transaction-specific global variable

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Florian Weimer <fweimer(at)bfk(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Transaction-specific global variable
Date: 2011-02-03 16:31:46
Message-ID: 23728.1296750706@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Florian Weimer <fweimer(at)bfk(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Gerardo Herzig 2011-02-03 18:40:02 using of select (myfunction()).* is so slow
Previous Message Andreas Gaab 2011-02-03 15:48:23 Re: UNIQUE on everything except primary key