]> git.ipfire.org Git - thirdparty/postgresql.git/commit
In hstore_plpython, avoid crashing when return value isn't a mapping.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 27 Apr 2023 15:55:06 +0000 (11:55 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 27 Apr 2023 15:55:06 +0000 (11:55 -0400)
commitc74f88c406dced7e23527d036b41e1a3213d27ea
tree6901af74fe916453299f8b0b4fcbf59e06093c87
parentaeb6f4b3b0d079155f9129ff6b043e9c8a926e72
In hstore_plpython, avoid crashing when return value isn't a mapping.

Python 3 changed the behavior of PyMapping_Check(), breaking the
test in plpython_to_hstore() that verifies whether a function result
to be transformed is acceptable.  A backwards-compatible fix is to
first verify that the object doesn't pass PySequence_Check().

Perhaps accidentally, our other uses of PyMapping_Check() already
follow uses of PySequence_Check(), so that no other bugs were
created by this change.

Per bug #17908 from Alexander Lakhin.  Back-patch to all supported
branches.

Dmitry Dolgov and Tom Lane

Discussion: https://postgr.es/m/17908-3f19a125d56a11d6@postgresql.org
contrib/hstore_plpython/expected/hstore_plpython.out
contrib/hstore_plpython/hstore_plpython.c
contrib/hstore_plpython/sql/hstore_plpython.sql