Proposed fix for Bug #15259 (invalid empty array returned by intarray "&" operator)

Alexey Kryuchkov <alexey.kruchkov@gmail.com>

From: Alexey Kryuchkov <alexey.kruchkov@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2018-07-02T17:09:27Z
Lists: pgsql-hackers

Attachments

The attached patch fixes Bug #15259 [1] in the intarray module, making the
'&' array intersection operator return proper zero-dimensional empty arrays
instead of one-dimensional, zero-length "empty" arrays.

In [2] this problem was addressed by changing the behaviour of
construct_[md_]array(), but the intarray module does not use these
functions. The patch I propose contains the relevant fixes to the
intarray module, along with regression tests.

[1]:
https://www.postgresql.org/message-id/153053285112.13258.434620894305716755%40wrigleys.postgresql.org
[2]: https://www.postgresql.org/message-id/20570.1506198383@sss.pgh.pa.us

Best regards,

        Alexey Kryuchkov

Commits

  1. Fix yet more problems with incorrectly-constructed zero-length arrays.