pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Daniel Gordon <dragongordon@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Recording how a table is used
Date: Mon, 29 Jun 2009 23:47:42 -0700
Message-ID: <11c0133d0906292347q4c65cfe2m7b658232d0b13a9f@mail.gmail.com> (raw)

I'm trying to record the results of a select statement into a separate
table.  I need the information selected, the column it was stored in, the
table it was stored in, and the query that selected it.  Everything I've
read so far says that triggers can't trigger from select statements, and
they don't have a variable that stores the query it triggered from.  I would
be happy with partial solutions since my other option is a complicated perl
script that has to parse the query statement to figure out where it is
looking for the information

Also, my next step is to do the same for as many types of statements as
possible, so if anyone knows how to retrieve the insert, update, or delete
statement sent to the database from inside the trigger, that would be useful
as well.

Here is the table I'm trying to fill, in case it is useful

create table sql_query_data_log (
 id serial,
 create_ time timestamp DEFAULT now(),
 query varchar,
 table text,
 column text,
 data varchar
 );

view thread (3+ messages)  latest in thread

Message-ID: <11c0133d0906292347q4c65cfe2m7b658232d0b13a9f@mail.gmail.com>
Permalink:  ../11c0133d0906292347q4c65cfe2m7b658232d0b13a9f@mail.gmail.com/
Also on:    postgresql.org/message-id/11c0133d0906292347q4c65cfe2m7b658232d0b13a9f@mail.gmail.com

 · 

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-sql@postgresql.org
  Cc: dragongordon@gmail.com
  Subject: Re: Recording how a table is used
  In-Reply-To: <11c0133d0906292347q4c65cfe2m7b658232d0b13a9f@mail.gmail.com>

* 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