Dear all,

I need to store text documents in PosgreSQL with revision management.
Chora PHP cvs library can be used for this purpose.

Did anyone think of integrating diff/patch within PostgreSQL?
If it were the case, we could build the first SQL CVS clone...

Best regards, Jean-Michel POURE

Sat, 10 Nov 2001 18:29:56 +0100
Jean-Michel POURE <jm.poure@freesurf.fr>
Diff/Patch integration -> SQL cvs clone
Jean-Michel POURE writes:

> Did anyone think of integrating diff/patch within PostgreSQL?

CREATE OR REPLACE FUNCTION diff(text, text) RETURNS text AS '
#!/bin/sh
    echo "$1" > /tmp/$$-one
    echo "$2" > /tmp/$$-two
    diff -c /tmp/$$-one /tmp/$$-two
    echo ""
    rm -f /tmp/$$-one /tmp/$$-two
' LANGUAGE plsh;

peter=> \t\a
peter=> select diff('one\ntwo\nthree\n', 'one\nfive\nthree\n');

*** /tmp/17580-one      Sun Nov 11 16:09:08 2001
--- /tmp/17580-two      Sun Nov 11 16:09:08 2001
***************
*** 1,4 ****
  one
! two
  three

--- 1,4 ----
  one
! five
  three

patch() is left as an exercise. ;-)

-- 
Peter Eisentraut   peter_e@gmx.net


Sun, 11 Nov 2001 16:40:26 +0100 (CET)
Peter Eisentraut <peter_e@gmx.net>
Re: Diff/Patch integration -> SQL cvs clone
Hello Peter,

Fantastic. It is possible to provide wrappers around most utilities.
I am stuck down on my chair. Cannot believe it...

Cheers,
Jean-Michel POURE

At 16:40 11/11/01 +0100, you wrote:
>Jean-Michel POURE writes:
>
> > Did anyone think of integrating diff/patch within PostgreSQL?
>
>CREATE OR REPLACE FUNCTION diff(text, text) RETURNS text AS '
>#!/bin/sh
>     echo "$1" > /tmp/$$-one
>     echo "$2" > /tmp/$$-two
>     diff -c /tmp/$$-one /tmp/$$-two
>     echo ""
>     rm -f /tmp/$$-one /tmp/$$-two
>' LANGUAGE plsh;
>
>peter=> \t\a
>peter=> select diff('one\ntwo\nthree\n', 'one\nfive\nthree\n');
>
>*** /tmp/17580-one      Sun Nov 11 16:09:08 2001
>--- /tmp/17580-two      Sun Nov 11 16:09:08 2001
>***************
>*** 1,4 ****
>   one
>! two
>   three
>
>--- 1,4 ----
>   one
>! five
>   three
>
>patch() is left as an exercise. ;-)
>
>--
>Peter Eisentraut   peter_e@gmx.net


Sun, 11 Nov 2001 16:41:04 +0100
Jean-Michel POURE <jm.poure@freesurf.fr>
Re: Diff/Patch integration -> SQL cvs clone
----- Original Message ----- 
From: Jean-Michel POURE <jm.poure@freesurf.fr>
Sent: Sunday, November 11, 2001 10:41 AM

> Fantastic. It is possible to provide wrappers around most utilities.

Which is not always portable and/or inconsistent, unfortunately;
depending on whether an OS you're running PG on has such utilities
and they behave all in the same way or not...

-s

> >Jean-Michel POURE writes:
> >
> > > Did anyone think of integrating diff/patch within PostgreSQL?
> >
> >CREATE OR REPLACE FUNCTION diff(text, text) RETURNS text AS '
> >#!/bin/sh
> >     echo "$1" > /tmp/$$-one
> >     echo "$2" > /tmp/$$-two
> >     diff -c /tmp/$$-one /tmp/$$-two
> >     echo ""
> >     rm -f /tmp/$$-one /tmp/$$-two
> >' LANGUAGE plsh;
> >
> >peter=> \t\a
> >peter=> select diff('one\ntwo\nthree\n', 'one\nfive\nthree\n');
> >
> >*** /tmp/17580-one      Sun Nov 11 16:09:08 2001
> >--- /tmp/17580-two      Sun Nov 11 16:09:08 2001
> >***************
> >*** 1,4 ****
> >   one
> >! two
> >   three
> >
> >--- 1,4 ----
> >   one
> >! five
> >   three
> >
> >patch() is left as an exercise. ;-)
> >
> >--
> >Peter Eisentraut   peter_e@gmx.net



Sun, 11 Nov 2001 17:20:12 -0500
"Serguei Mokhov" <sa_mokho@alcor.concordia.ca>
Re: Diff/Patch integration -> SQL cvs clone

Peter, should plsh be added to our supplied server-side programming
languages?  Seems like a major feature to me and to others as well.

---------------------------------------------------------------------------

> Jean-Michel POURE writes:
> 
> > Did anyone think of integrating diff/patch within PostgreSQL?
> 
> CREATE OR REPLACE FUNCTION diff(text, text) RETURNS text AS '
> #!/bin/sh
>     echo "$1" > /tmp/$$-one
>     echo "$2" > /tmp/$$-two
>     diff -c /tmp/$$-one /tmp/$$-two
>     echo ""
>     rm -f /tmp/$$-one /tmp/$$-two
> ' LANGUAGE plsh;
> 
> peter=> \t\a
> peter=> select diff('one\ntwo\nthree\n', 'one\nfive\nthree\n');
> 
> *** /tmp/17580-one      Sun Nov 11 16:09:08 2001
> --- /tmp/17580-two      Sun Nov 11 16:09:08 2001
> ***************
> *** 1,4 ****
>   one
> ! two
>   three
> 
> --- 1,4 ----
>   one
> ! five
>   three
> 
> patch() is left as an exercise. ;-)
> 
> -- 
> Peter Eisentraut   peter_e@gmx.net
> 
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
> 

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Wed, 21 Nov 2001 22:11:30 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Diff/Patch integration -> SQL cvs clone
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Peter, should plsh be added to our supplied server-side programming
> languages?  Seems like a major feature to me and to others as well.

While plsh is surely a cool hack, I've got considerable unease about
making it into an officially supported feature.  The only reasons I can
see for wanting to use it (over plpgsql, pltcl, plperl, etc) are
inherently violations of transaction semantics.  Who's going to roll
back your sendmail call when the calling transaction later aborts?
What's going to ensure that the order of external effects has something
to do with the serialization order that the database assigns to several
concurrent transactions?

IMHO plsh is a great tool for shooting yourself in the foot (with a
large-gauge firearm, in fact).  People who know what they're doing are
welcome to use it ... but those sorts of people can find and install
it for themselves.

Of course the same worries apply to the untrusted variants of pltcl,
plperl, etc.  Perhaps we need to document the risks they carry.  But
plsh hasn't even got the possibility of a trusted variant :-(

			regards, tom lane

Wed, 21 Nov 2001 22:36:52 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: Diff/Patch integration -> SQL cvs clone 
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Peter, should plsh be added to our supplied server-side programming
> > languages?  Seems like a major feature to me and to others as well.
> 
> While plsh is surely a cool hack, I've got considerable unease about
> making it into an officially supported feature.  The only reasons I can
> see for wanting to use it (over plpgsql, pltcl, plperl, etc) are
> inherently violations of transaction semantics.  Who's going to roll
> back your sendmail call when the calling transaction later aborts?
> What's going to ensure that the order of external effects has something
> to do with the serialization order that the database assigns to several
> concurrent transactions?
> 
> IMHO plsh is a great tool for shooting yourself in the foot (with a
> large-gauge firearm, in fact).  People who know what they're doing are
> welcome to use it ... but those sorts of people can find and install
> it for themselves.
> 
> Of course the same worries apply to the untrusted variants of pltcl,
> plperl, etc.  Perhaps we need to document the risks they carry.  But
> plsh hasn't even got the possibility of a trusted variant :-(

Yes, I see your point, but if you need to do something in the operating
system, like send mail, you are stuck with leaving transactions
semantics and security anyway.  If they have to leave those anyway, why
not give them simple shell scripts?

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Wed, 21 Nov 2001 22:44:38 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Diff/Patch integration -> SQL cvs clone
Dear friends

I was surprised to notice that INTERBASE already has more than a dozen 
graphical administration interfaces:
- http://www.interbase2000.org/tools_dbman.htm,
- http://delphree.clexpert.com.

In my dreams, I would welcome ALTER OR REPLACE VIEW + ALTER OR REPLACE 
TRIGGER (sorry, this is on my whish list again). Without these two features, 
this is not easily ***possible*** to build a graphical admin & IDE interface 
for PostgreSQL.

KDE3/QT3 makes it possible to build cross-platform database administration 
tools. We don't need a dozen of them, just one good IDE with migration 
features from MySQL, Oracle, MS SQL, Interbase...

The community is waiting for ALTER OR REPLACE, my friends... We also need 
ALTER TABLE DROP FIELD, but this is probably more tricky.

Cheers,
Jean-Michel POURE

Thu, 22 Nov 2001 12:01:54 +0100
Jean-Michel POURE <jm.poure@freesurf.fr>
ALTER OR REPLACE feature
Jean-Michel POURE wrote:
> 
> Dear friends
> 
> I was surprised to notice that INTERBASE already has more than a dozen
> graphical administration interfaces:
> - http://www.interbase2000.org/tools_dbman.htm,
> - http://delphree.clexpert.com.
> 
> In my dreams, I would welcome ALTER OR REPLACE VIEW + ALTER OR REPLACE
> TRIGGER (sorry, this is on my whish list again). Without these two features,
> this is not easily ***possible*** to build a graphical admin & IDE interface
> for PostgreSQL.
> 
> KDE3/QT3 makes it possible to build cross-platform database administration
> tools. We don't need a dozen of them, just one good IDE with migration
> features from MySQL, Oracle, MS SQL, Interbase...

Check out TOra - this is currently for Oracle only, but teher is no
inherent 
reason why you can't alter it for others.

> The community is waiting for ALTER OR REPLACE, my friends... We also need
> ALTER TABLE DROP FIELD, but this is probably more tricky.
> 
> Cheers,
> Jean-Michel POURE
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster

Thu, 22 Nov 2001 13:44:01 +0200
Hannu Krosing <hannu@tm.ee>
Re: [HACKERS] ALTER OR REPLACE feature
> Bruce Momjian writes:
> 
> > Peter, should plsh be added to our supplied server-side programming
> > languages?  Seems like a major feature to me and to others as well.
> 
> I get mail from people that are using it for some pretty ugly
> applications.  Not the sort of stuff we want to let loose on newbies.  I
> should probably stick a warning in there somewhere.

Yes, if we outline the cases where they should/shouldn't be use plsh, it
seems fine to me.

Added to TODO:

	* Add plsh server-side shell language (Peter E)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Thu, 22 Nov 2001 12:18:33 -0500 (EST)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: Diff/Patch integration -> SQL cvs clone
Bruce Momjian writes:

> Peter, should plsh be added to our supplied server-side programming
> languages?  Seems like a major feature to me and to others as well.

I get mail from people that are using it for some pretty ugly
applications.  Not the sort of stuff we want to let loose on newbies.  I
should probably stick a warning in there somewhere.

-- 
Peter Eisentraut   peter_e@gmx.net


Thu, 22 Nov 2001 18:21:30 +0100 (CET)
Peter Eisentraut <peter_e@gmx.net>
Re: Diff/Patch integration -> SQL cvs clone