Re: Simple row serialization?

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Ivan Voras <ivoras(at)freebsd(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Simple row serialization?
Date: 2008-01-26 18:01:09
Message-ID: 479B7565.2060805@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ivan Voras wrote:
> Hi,
>
> I'd like to implement some simple data logging via triggers on a small
> number of infrequently updated tables and I'm wondering if there are
> some helpful functions, plugins or idioms that would serialize a row
> (received for example in a AFTER INSERT trigger) into a string that
> I'd store in the log table. There's a limited number of field types
> involved: varchars, integers and booleans. I'm not looking for
> anything fancy, comma-separated string result will be just fine; Even
> better, something like a dictionary ("field_name":"field_value",...)
> would be nice. The reason for trying to do it this way is that I don't
> want to create separate log tables for every table I wish to log.

Why not create the audit tables with composite types rather than strings?

create table audit_foo_table as (who text, when timestamptz, old
foo, new foo);

Or you could use an hstore (see contrib).

Or you could possibly use some of the XML support in 8.3 for serialization.

This is a usage question, so it really doesn't belong on -hackers.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ivan Voras 2008-01-26 18:02:57 Re: Simple row serialization?
Previous Message Pavel Stehule 2008-01-26 17:49:26 Re: Simple row serialization?