mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
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
This commit is contained in:
@ -27,6 +27,17 @@ $$;
|
||||
SELECT test1n('aa=>bb, cc=>NULL'::hstore);
|
||||
|
||||
|
||||
-- test that a non-mapping result is correctly rejected
|
||||
CREATE FUNCTION test1bad() RETURNS hstore
|
||||
LANGUAGE plpython3u
|
||||
TRANSFORM FOR TYPE hstore
|
||||
AS $$
|
||||
return "foo"
|
||||
$$;
|
||||
|
||||
SELECT test1bad();
|
||||
|
||||
|
||||
-- test hstore[] -> python
|
||||
CREATE FUNCTION test1arr(val hstore[]) RETURNS int
|
||||
LANGUAGE plpython3u
|
||||
|
Reference in New Issue
Block a user