Re: Possibly odd question; diff results? - Mailing list pgsql-general

From Merlin Moncure
Subject Re: Possibly odd question; diff results?
Date
Msg-id b42b73150702090553i7d83d41m3a0c329fa9ca5dbd@mail.gmail.com
Whole thread Raw
In response to Possibly odd question; diff results?  (Madison Kelly <linux@alteeve.com>)
Responses Re: Possibly odd question; diff results?  (Madison Kelly <linux@alteeve.com>)
List pgsql-general
On 2/8/07, Madison Kelly <linux@alteeve.com> wrote:
> Hi all,
>
>    I've got a 'history' schema that records changes in the public schema
> tables over time. I use a trigger and function to do this. What I would
> like to do though, and this may not even be possible, is say something
> like (pseudo-code) "SELECT DIFF foo_name FROM history.foo WHERE
> foo_id=X;" and have a *nix 'diff' style results shown (sort of like
> looking at diffs in CVS/SVN).

you can start by using the 'except' boolean query operator;

select * from foo except * from bar;  This will give you rows in foo
that are not exactly in bar (matching every field).  If you want it in
both directions you can:

(select * from foo except select * from bar)
  union
(select * from bar except select * from foo);

you can then take the results of these queries and mark up the text
however you want.  Just a heads up: the boolean sql operators are
famous for generating sequential scans.

merlin

pgsql-general by date:

Previous
From: "Bruce McAlister"
Date:
Subject: Re: Automating databse creation
Next
From: Andreas Kretschmer
Date:
Subject: Re: trigger for pg_authid