pgsql: Consistently catch errors from Python _New() functions

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Consistently catch errors from Python _New() functions
Date: 2017-11-18 18:40:02
Message-ID: E1eG826-0004jr-Jx@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Consistently catch errors from Python _New() functions

Python Py*_New() functions can fail and return NULL in out-of-memory
conditions. The previous code handled that inconsistently or not at
all. This change organizes that better. If we are in a function that
is called from Python, we just check for failure and return NULL
ourselves, which will cause any exception information to be passed up.
If we are called from PostgreSQL, we consistently create an "out of
memory" error.

Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d0aa965c0a0ac2ff7906ae1b1dad50a7952efa56

Modified Files
--------------
contrib/hstore_plpython/hstore_plpython.c | 4 ++++
contrib/ltree_plpython/ltree_plpython.c | 4 ++++
src/pl/plpython/plpy_cursorobject.c | 25 ++++++++++++++++---------
src/pl/plpython/plpy_exec.c | 10 +++++++++-
src/pl/plpython/plpy_main.c | 2 +-
src/pl/plpython/plpy_plpymodule.c | 4 ++--
src/pl/plpython/plpy_procedure.c | 2 ++
src/pl/plpython/plpy_resultobject.c | 11 +++++++++++
src/pl/plpython/plpy_spi.c | 27 ++++++++++++++++++---------
src/pl/plpython/plpy_typeio.c | 4 +++-
10 files changed, 70 insertions(+), 23 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2017-11-18 21:24:11 pgsql: Merge near-duplicate code in RI triggers.
Previous Message Tom Lane 2017-11-18 17:43:00 pgsql: Improve to_date/to_number/to_timestamp behavior with multibyte c