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

From: Jean-Baptiste Quenot <jbq(at)caraldi(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Fix PL/Python metadata when there is no result
Date: 2012-02-25 17:03:27
Message-ID: CAK6bCax5ps4qSPzD=6+h8eArfDej3YvssNf919Ge1=8edAbtDQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2012/2/24 Peter Eisentraut <peter_e(at)gmx(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2012-02-25 18:06:38 Re: foreign key locks, 2nd attempt
Previous Message Thom Brown 2012-02-25 16:36:41 Re: Command Triggers, patch v11