Re: Fix PL/Python metadata when there is no result
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: pgsql-hackers@postgresql.org, Jean-Baptiste Quenot <jbq@caraldi.com>
Date: 2012-04-05T17:54:39Z
Lists: pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes: > The alternatives are now to introduce a new function like has_rows() > that returns True iff result rows exist and therefore result metadata > can be fetched, or go back to having coltypes() et al. return None when > no metadata exists. I'm in favor of the latter, because the former > would add somewhat needless complications and doesn't really add any > robustness or the like. Seems sensible to me. We had better also document what nrows() really does. Should we also introduce a new function that is "number of rows in the resultset", rather than depending on len()? I think it might be useful, or at least consistent, to have a function defined as "number of rows, or None if the resultset does not contain rows". In particular, I think it is important to be able to distinguish between a command result (which cannot possibly contain rows) and a query result that happens to contain zero rows. regards, tom lane