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