Re: Invoke diff from plpgsql?

From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Invoke diff from plpgsql?
Date: 2006-05-27 22:44:13
Message-ID: 60k6873x6q.fsf@dba2.int.libertyrms.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

survivedsushi(at)yahoo(dot)com (Matthew Peter) writes:
> George Pavlov <gpavlov(at)mynewplace(dot)com> wrote:
>
> > Wondering how to invoke a application like diff from plpgsql? Thanks!
>
> And don't forget that you are working with a database. Most diff-ing
> uses can probably be handled by constructs like EXCEPT and INTERSECT to
> say nothing of OUTER JOINs. Also, IS DISTINCT FROM is your friend if you
> want a comparison that treats NULLs as "normal" data values.
>
>
>
> Thanks for the replies. What I wanted to do was just track the
> changes to a column... like svn does so I can get a history and
> incremental changes of a article per user handled by a
> trigger. Saving the output from diff seemed simple enough rather
> than the entire article. Is there a contrib modules or otherwise to
> enable tracking changes like that in plpgsql?

I suppose it would be *plausible* to store sets of patches in a
database; the fact that updates could be handled within transactions
has some appeal.

Unfortunately, building in a "diff" would be somewhat challenging:

- on the one hand, "stealing code" from C implementations is something
of a stability/security risk;

- on the other hand, "diff" tends to be somewhat complex, such that
reimplementing in one of the pl/languages (pl/pgsql, pl/perl,
pl/python, pl/tcl) is likely to fall prey to "recreating bugs." Mind
you, in languages where strings are "first class" objects, it's
probably a lot easier to implement diff correctly than it is in C...

- I'd ask the question of whether or not it is *actually* worthwhile.
Columns more than 8K in size (and this seems quite likely, for
articles) are compressed in TOAST entries in the database, so you may
already be getting savings you weren't aware of...
--
(format nil "~S(at)~S" "cbbrowne" "ntlug.org")
http://cbbrowne.com/info/x.html
Microsoft Outlook: Deploying Viruses Has Never Been This Easy!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Broussard 2006-05-28 04:13:58 Schema Limitations ?
Previous Message Steve Atkins 2006-05-27 21:31:04 Re: Per session variables