Re: Fix PL/Python metadata when there is no result - Mailing list pgsql-hackers

From Jean-Baptiste Quenot
Subject Re: Fix PL/Python metadata when there is no result
Date
Msg-id CAK6bCax5ps4qSPzD=6+h8eArfDej3YvssNf919Ge1=8edAbtDQ@mail.gmail.com
Whole thread Raw
In response to Re: Fix PL/Python metadata when there is no result  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Fix PL/Python metadata when there is no result
List pgsql-hackers
2012/2/24 Peter Eisentraut <peter_e@gmx.net>:
> On fre, 2012-02-10 at 17:44 +0100, Jean-Baptiste Quenot wrote:
>>
>> Please find attached a patch that solves this issue.  Instead of a PG
>> crash, we get the following message:
>>
>> ERROR:  plpy.Error: no result fetched
>
> Hmm, should it be an error or just return None?  Python DB-API
> cursor.description returns None if no result set was returned.

IMO raising an error is much better because:

1) It is not a valid usecase to retrieve result metadata when no rows
are expected to be returned

2) The various metadata methods return a sequence.  Checking for null
value in this case is not a very good programming style.  I expect to
find an empty list when no data is available.

Cheers,
--
Jean-Baptiste Quenot


pgsql-hackers by date:

Previous
From: Thom Brown
Date:
Subject: Re: Command Triggers, patch v11
Next
From: "Kevin Grittner"
Date:
Subject: Re: foreign key locks, 2nd attempt