pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Florian Weimer <fweimer@bfk.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: Transaction-specific global variable
Date: Thu, 03 Feb 2011 11:31:46 -0500
Message-ID: <23728.1296750706@sss.pgh.pa.us> (raw)
In-Reply-To: <82zkqdscuc.fsf@mid.bfk.de>
References: <82zkqdscuc.fsf@mid.bfk.de>

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



view thread (2+ messages)

Message-ID: <23728.1296750706@sss.pgh.pa.us>
Permalink:  ../23728.1296750706@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/23728.1296750706@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, fweimer@bfk.de
  Subject: Re: Transaction-specific global variable
  In-Reply-To: <23728.1296750706@sss.pgh.pa.us>

* 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