pgsql: Tighten array dimensionality checks in Python -> SQL array conve - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Tighten array dimensionality checks in Python -> SQL array conve
Date
Msg-id E1puaRx-000STO-G9@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Tighten array dimensionality checks in Python -> SQL array conversion.

Like plperl before f47004add, plpython wasn't being sufficiently
careful about checking that list-of-list structures represent
rectangular arrays, so that it would accept some cases in which
different parts of the "array" are nested to different depths.
This was exacerbated by Python's weak distinction between
sequences and lists, so that in some cases strings could get
treated as though they are lists (and burst into individual
characters) even though a different ordering of the upper-level
list would give a different result.

Some of this behavior was unreachable (without risking a crash)
before 81eaaf65e.  It seems like a good idea to clean it all up
in the same releases, rather than shipping a non-crashing but
nonetheless visibly buggy behavior in the name of minimal change.
Hence, back-patch.

Per bug #17912 and further testing by Alexander Lakhin.

Discussion: https://postgr.es/m/17912-82ceed78731d9cdc@postgresql.org

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/0e6354ed97833a15a6a7dfa328298ad02e0947e3

Modified Files
--------------
src/pl/plpython/expected/plpython_types.out   |  65 +++++++-
src/pl/plpython/expected/plpython_types_3.out |  65 +++++++-
src/pl/plpython/plpy_typeio.c                 | 212 +++++++++++++-------------
src/pl/plpython/sql/plpython_types.sql        |  50 +++++-
4 files changed, 270 insertions(+), 122 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Tighten array dimensionality checks in Python -> SQL array conve
Next
From: Tom Lane
Date:
Subject: pgsql: In array_position()/array_positions(), beware of empty input arr