Re: BUG #17912: Invalid memory access when converting plpython' array containing empty array
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2023-04-28T19:17:09Z
Lists: pgsql-bugs
Attachments
- tighten-multidim-array-shape-checks.patch (text/x-diff) patch
I wrote: > Yeah. AFAICT, the idea of the existing code is to descend through > the first item at each nest level till we hit a non-list, then take > the lengths of those lists as the array dimensions, and then complain > if we find any later items that don't fit those dimensions. That leads > to some symmetry problems, in that the error you get for inconsistent > sequence lengths depends on the order in which the items are presented. The real problem here is that we don't check that the list nesting depth is the same throughout the array: if lists are more deeply nested in later elements, we'll treat those sub-lists as scalars, leading to inconsistent results. Conversely, a less-deeply-nested list structure in a later element might still work, if it can be treated as a sequence. I think the second and third examples I gave should both throw errors. I also notice that the error messages in this area speak of "sequences", but it is more correct to call them "lists", because Python draws a distinction. (All lists are sequences, but not vice versa, eg a string is a sequence but not a list.) So I'm thinking about the attached. I do not propose this for back-patching, because it could break applications that work today. But it seems like good tightening-up for HEAD, or maybe we should wait for v17 at this point? regards, tom lane
Commits
-
Tighten array dimensionality checks in Python -> SQL array conversion.
- b7fcf3824b42 12.15 landed
- b7001c6b6a77 15.3 landed
- aa7e5e404324 11.20 landed
- 9d517339e991 14.8 landed
- 0e6354ed9783 13.11 landed
- 0553528e7c2b 16.0 landed
-
Tighten array dimensionality checks in Perl -> SQL array conversion.
- f47004add160 16.0 landed
- ee24b5e792e0 13.11 landed
- ea96fbe772a7 11.20 landed
- ce9a1a3ea8fe 15.3 landed
- 900a8d526ff5 12.15 landed
- 1e868bb6c67a 14.8 landed
-
Handle zero-length sublist correctly in Python -> SQL array conversion.
- ff9203f46069 12.15 landed
- b7c6af375da6 11.20 landed
- a1d9aacc4128 14.8 landed
- 81eaaf65e393 16.0 landed
- 7dcd9998c19d 13.11 landed
- 512c555221c3 15.3 landed