Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id B819A133616B for ; Thu, 3 Feb 2011 12:31:57 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 01950-02 for ; Thu, 3 Feb 2011 16:31:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 39706133655C for ; Thu, 3 Feb 2011 12:31:50 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p13GVlXt023729; Thu, 3 Feb 2011 11:31:47 -0500 (EST) To: Florian Weimer cc: pgsql-sql@postgresql.org Subject: Re: Transaction-specific global variable In-reply-to: <82zkqdscuc.fsf@mid.bfk.de> References: <82zkqdscuc.fsf@mid.bfk.de> Comments: In-reply-to Florian Weimer message dated "Thu, 03 Feb 2011 09:10:19 +0000" Date: Thu, 03 Feb 2011 11:31:46 -0500 Message-ID: <23728.1296750706@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201102/6 X-Sequence-Number: 35082 Florian Weimer 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