Skip site navigation (1) Skip section navigation (2)

Re: transparently log a right error

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: "Jean-Yves F(dot) Barbier" <12ukwn(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: transparently log a right error
Date: 2009-11-27 03:05:34
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
On 26/11/2009 11:56 PM, Jean-Yves F. Barbier wrote:
> Hi list,
> How could I transparently log an error where user miss a right,
> I know how to write a RULE, but not this way:
> ie: 
> * user don't have a direct access to tables but to procedures that
>    manipulates tables.
> * He try to make a: SELECT * FROM table5
>    which normally returns: "ERROR: right refused for relation table5"
> * I wanna log the user's name into a separate table, but still
>    having PG reporting the usual error (NOT using regular logs)

That sort of thing has a significant issue that makes it hard to use

You're trying to record events about possibly read-only actions by the
user. The user can extract information, then ROLLBACK their transaction.
If you're recording their actions as a log within the database its self,
your log will be rolled back as well.

PostgreSQL doesn't have autonomous transaction support, which would be
required to let the log table changes be retained even if the user rolls
back the transaction. It could be done with dblink, but not particularly

Honestly, processing the regular text logs (or using csv log mode) is
your best bet at this point.

Craig Ringer

In response to

pgsql-general by date

Next:From: Craig RingerDate: 2009-11-27 03:09:30
Subject: Re: Invalid redo in checkpoint record
Previous:From: Thom BrownDate: 2009-11-26 22:18:53
Subject: Re: date_trunct() and start of week

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group