pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Shane Ambler <pgsql@Sheeky.Biz>
To: Rajesh Kumar Mallah <mallah.rajesh@gmail.com>
Cc: Achilleas Mantzios <achill@matrix.gatewaynet.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: conditional logging based on client
Date: Thu, 24 Jul 2008 02:14:25 +0930
Message-ID: <48875FE9.8040408@Sheeky.Biz> (raw)
In-Reply-To: <a97c77030807221040n4a791582tb098b0ba9c54944c@mail.gmail.com>
References: <a97c77030807220517u2324a0cckb8400a359123426a@mail.gmail.com>
	<200807221524.45181.achill@matrix.gatewaynet.com>
	<a97c77030807221040n4a791582tb098b0ba9c54944c@mail.gmail.com>

Rajesh Kumar Mallah wrote:
> On Tue, Jul 22, 2008 at 5:54 PM, Achilleas Mantzios 

>>> The original objective is that we should be able to know what all
>>> hand made SQLs have  been executed in past  (which can date back
>>> as long as 1 year even)
>> You have to adjust log_statement in your postgresql.conf however
>> you will have to bear in mind the performance implications of this.
>>  Normal production sites dont do this. You can enable/disable this
>> kind of logging any time by killing -HUP
> 
> thanks for reply. any hit on performance is not desired. is it
> possible to alter logging behaviour just for the psql session ?
> 

Not quite but the opposite could be a path to look down.

The config specifies logging statements that is applied to all sessions.
Your app could then be setup to alter this at run time.

I haven't tried this - it is only a theory - I would think that you
could create a function to turn off logging but you would also need to
look into restricting access to only your app (your app provides some
sort of code maybe).

The biggest problem here will be preventing users from performing this 
command by hand in psql. This is where the function would allow a point 
that must be 'authenticated' by your app.

http://www.postgresql.org/docs/8.3/interactive/functions-admin.html
and
http://www.postgresql.org/docs/8.3/interactive/view-pg-settings.html

as well as SECURITY DEFINER which is the reason for the function - it
must be run as a superuser.
http://www.postgresql.org/docs/8.3/interactive/sql-createfunction.html


Another option would be to have them use a different user name when 
using psql. Probably not an option unless the app runs with it's own 
username.



-- 

Shane Ambler
pgSQL (at) Sheeky (dot) Biz

Get Sheeky @ http://Sheeky.Biz



view thread (7+ messages)  latest in thread

Message-ID: <48875FE9.8040408@Sheeky.Biz>
Permalink:  ../48875FE9.8040408@Sheeky.Biz/
Also on:    postgresql.org/message-id/48875FE9.8040408@Sheeky.Biz

 · 

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-admin@postgresql.org
  Cc: pgsql@Sheeky.Biz, mallah.rajesh@gmail.com, achill@matrix.gatewaynet.com
  Subject: Re: conditional logging based on client
  In-Reply-To: <48875FE9.8040408@Sheeky.Biz>

* 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