Re: why does plperl cache functions using just a bool for is_trigger

Поиск
Список
Период
Сортировка
От Hannu Krosing
Тема Re: why does plperl cache functions using just a bool for is_trigger
Дата
Msg-id 1288863970.2686.17.camel@hvost
обсуждение исходный текст
Ответ на Re: why does plperl cache functions using just a bool for is_trigger  (Jan Urbański <wulczer@wulczer.org>)
Ответы Re: why does plperl cache functions using just a bool for is_trigger  (Hannu Krosing <hannu@2ndQuadrant.com>)
Re: why does plperl cache functions using just a bool for is_trigger  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Wed, 2010-11-03 at 21:43 +0100, Jan Urbański wrote:
> The validator is ready, once I'm done with the hash tables I'll try to
> fix up the error checking (get rid of the global error state) and
> finally do what started it all, that is make plpythonu use
> subtransactions for SPI and be able to do:
> 
> try:
>     plpy.execute("insert into foo values(1)")
> except plpy.UniqueViolation, e:
>     plpy.notice("Ooops, you got yourself a SQLSTATE %d", e.sqlstate)

Are you sure that having each try/except use a subtransaction is the
right way to do it ?

I'd like to make it more explicit and use 

with plpy.subtransaction():   do your stuff

adding subtransactions to try/except would also act differently on
postgresql and python data, that is things in postgresql tables would
get rolled back but those made to python would not 

or at least make the "rollback to savepoint x" optional

try:   plpy.savepoint('sp1')   for i in range(-5,5)       plpy.execute("insert into foo values(%s)", [abs(10/i)])
except plpy.UniqueViolation, e:   plpy.rollback('sp1')   plpy.notice("Ooops, you got yourself a SQLSTATE %d",
e.sqlstate)
except ZeroDivisionError:   plpy.notice("Only some values were inserted")



-------
Hannu Krosing
PostgreSQL Infinite Scalability and Preformance Consultant
PG Admin Book: http://www.2ndQuadrant.com/books/




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Itagaki Takahiro
Дата:
Сообщение: Re: SQL/MED estimated time of arrival?
Следующее
От: Hannu Krosing
Дата:
Сообщение: Re: why does plperl cache functions using just a bool for is_trigger