Обсуждение: Diff/Patch integration -> SQL cvs clone

Поиск
Список
Период
Сортировка

Diff/Patch integration -> SQL cvs clone

От
Jean-Michel POURE
Дата:
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


Re: Diff/Patch integration -> SQL cvs clone

От
Jean-Michel POURE
Дата:
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



Re: Diff/Patch integration -> SQL cvs clone

От
Peter Eisentraut
Дата:
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



Re: Diff/Patch integration -> SQL cvs clone

От
"Serguei Mokhov"
Дата:
----- 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




Re: Diff/Patch integration -> SQL cvs clone

От
Bruce Momjian
Дата:
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,
Pennsylvania19026
 


Re: Diff/Patch integration -> SQL cvs clone

От
Tom Lane
Дата:
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


Re: Diff/Patch integration -> SQL cvs clone

От
Bruce Momjian
Дата:
> 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,
Pennsylvania19026
 


ALTER OR REPLACE feature

От
Jean-Michel POURE
Дата:
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

Re: ALTER OR REPLACE feature

От
Hannu Krosing
Дата:
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

Re: Diff/Patch integration -> SQL cvs clone

От
Peter Eisentraut
Дата:
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



Re: Diff/Patch integration -> SQL cvs clone

От
Bruce Momjian
Дата:
> 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,
Pennsylvania19026