Re: Fix PL/Python metadata when there is no result

Поиск
Список
Период
Сортировка
От Peter Eisentraut
Тема Re: Fix PL/Python metadata when there is no result
Дата
Msg-id 1331156590.12416.8.camel@vanquo.pezone.net
обсуждение исходный текст
Ответ на Re: Fix PL/Python metadata when there is no result  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Fix PL/Python metadata when there is no result
Список pgsql-hackers
On ons, 2012-03-07 at 15:59 -0500, Tom Lane wrote:
> > Which led me to think, how are you actually expected to know when no
> > rows are expected to be returned, in PL/Python?  You can look at
> > result.status(), which returns a numeric SPI status, but that seems
> > fragile.  I notice that result.nrows() returns None when no rows are
> > returned.  Is that good enough?  In that case, we should document that
> > and then make the new functions throw exceptions like you suggest.
> 
> Wait a minute ... I don't understand why that's not a valid use-case.
> I have seen more than one piece of code that does a SELECT ... LIMIT 0
> or equivalent for the express purpose of finding out the rowtype
> produced by a particular query.  Why would we make it impossible to do
> that in pl/python?  Or are we talking about two different things?
> 
I think so.  I'm wondering here how to detect whether the execution of a
statement has yielded a result set at all.  (For example, you ran SELECT
or INSERT ... RETURNING, versus CREATE TABLE or VACUUM.)




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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: WARNING: concurrent insert in progress within table "resource"
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Fix PL/Python metadata when there is no result