Re: mysql replace in postgreSQL?

Поиск
Список
Период
Сортировка
Искать
От
Lincoln Yeoh
Тема
Re: mysql replace in postgreSQL?
Дата
Msg-id
5.2.1.1.1.20051030233604.03431fb0@localhost
Ответ на
Список
Дерево обсуждения
mysql replace in postgreSQL? blackwater dev <blackwaterdev@gmail.com>
Re: mysql replace in postgreSQL? David Fetter <david@fetter.org>
Re: mysql replace in postgreSQL? Tino Wildenhain <tino@wildenhain.de>
Re: mysql replace in postgreSQL? David Fetter <david@fetter.org>
Re: mysql replace in postgreSQL? Tino Wildenhain <tino@wildenhain.de>
Re: mysql replace in postgreSQL? Lincoln Yeoh <lyeoh@pop.jaring.my>
Re: mysql replace in postgreSQL? David Fetter <david@fetter.org>
Re: mysql replace in postgreSQL? Lincoln Yeoh <lyeoh@pop.jaring.my>
Re: mysql replace in postgreSQL? Jan Wieck <JanWieck@Yahoo.com>
Re: mysql replace in postgreSQL? Lincoln Yeoh <lyeoh@pop.jaring.my>
Re: mysql replace in postgreSQL? Tzvetan Tzankov <tzankov@noxis.net>
Re: mysql replace in postgreSQL? "Joshua D. Drake" <jd@commandprompt.com>
Re: mysql replace in postgreSQL? Bricklen Anderson <bricklen@shaw.ca>
Re: mysql replace in postgreSQL? Kostas Maistrelis <maisk@ath.forthnet.gr>
Re: mysql replace in postgreSQL? <cristian@clickdiario.com>
At 06:29 AM 10/30/2005 -0800, David Fetter wrote:

>On Fri, Oct 28, 2005 at 09:57:03PM -0400, blackwater dev wrote:
> > In MySQL, I can use the replace statement which either updates the
> > data there or inserts it.  Is there a comporable syntax to use in
> > postgreSQL?
>
>Not really, but here's an example which doesn't have the brokenness of
>MySQL's REPLACE INTO and doesn't have the race conditions that some
>others' proposals have.
>
>http://developer.postgresql.org/docs/postgres/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING

Erm, doesn't it have the same race conditions? It's just fine as long as 
you have an appropriate uniqueness constraint.

If you have the appropriate uniqueness constraint, you'll be fine whatever 
you do as long as you're not doing something too stupid.

If it is possible to lock on something that already exists or has "yet to 
exist" then maybe you can do such an insert/update.

e.g. "SELECT .... FOR INSERT WHERE field1=x"

How about customizable user locking? e.g. lock string "tablename field1=x"

Anyway, I used to lock tables before doing selects before inserts/updates.

Link.






В списке pgsql-general по дате отправления
От: David Fetter
Дата:
От: Tom Lane
Дата:
FAQ