Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4A5E09FA0C4 for ; Mon, 20 Nov 2006 06:37:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 89559-10 for ; Mon, 20 Nov 2006 06:37:23 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.178]) by postgresql.org (Postfix) with ESMTP id C816F9F9EB3 for ; Mon, 20 Nov 2006 06:37:22 -0400 (AST) Received: by py-out-1112.google.com with SMTP id u77so1066091pyb for ; Mon, 20 Nov 2006 02:37:21 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Vd7adFrAACIZv103Y0vmawevw26SDw6tl9LmsKFh1cC+rwvp0pKJU6vqY5xkilNecENlf+J3VWdEjOngQaKEjxqPQ3AVMyYYK/enh4cf6uqUVs8ZipQFauH/xHDB7lXJkBT7dHGlmSIIbL8X4Jmv8tawtjIWJ2Jjm4B2Nw+G7M8= Received: by 10.35.39.13 with SMTP id r13mr360134pyj.1164019040044; Mon, 20 Nov 2006 02:37:20 -0800 (PST) Received: by 10.35.80.10 with HTTP; Mon, 20 Nov 2006 02:37:19 -0800 (PST) Message-ID: Date: Mon, 20 Nov 2006 16:07:19 +0530 From: "Rajesh Kumar Mallah" To: "Tom Lane" Subject: Re: transactional shared variable in postgresql Cc: pgsql-sql@postgresql.org In-Reply-To: <532.1163875210@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <532.1163875210@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/212 X-Sequence-Number: 26864 On 11/19/06, Tom Lane wrote: > "Rajesh Kumar Mallah" writes: > > In our webapps, we use the same username to connect to the database > > for all kind of updates. Hence we are not able to makeout whoo modified > > what . However at application level we have different "userid" for > different > > users of the system. we want to somehow pass this "userid" to the > databasee > > server and accesss it from the triggers that implement the audit > functions. > > Perhaps it would be better to make your "userid" be the actual database > user? But anyway, the custom GUC variable facility might serve your > needs. > http://www.postgresql.org/docs/8.1/static/runtime-config-custom.html Dear Tom, Thanks for the suggestion , it seems to be working. i used GetConfigOption of guc.c to retrieve the value. I am setting the variable from psql eg: SET general.employee to 101; I hope what i am doing is correct . I have very little experience in using C for triggers. can you please tell if its fine. in postgresql.conf i declared. custom_variable_classes = 'general' And inside the TRIGGER FUNCTION i use the below ------------ x------------------------ int employee = 0 ; /* int for holding employee_id */ char *employee_str ; /* for storing result for GetConfigOption */ employee_str = (char *) GetConfigOption("general.employee") ; if (employee_str != NULL) { employee = atoi(employee_str); } -------------x---------------------------- also if i do not cast using (char *) the compiler gives a warning: audit_trail.c:82: warning: assignment discards qualifiers from pointer target type why so? I have verified that the variable is isolated in transaction and serves my purpose. Regards Mallah. > > regards, tom lane >