Skip to content

array_append mishandles NULL values with non-empty offset ranges #25222

Closed

Description

@neilconway

Describe the bug

The result is computed from the input's offset ranges without considering the validity buffer; it is possible for the validity buffer to indicate that a value is NULL, in which case non-empty offsets are allowed but should be ignored.

To Reproduce

  CREATE TABLE t AS VALUES ([1,2,3], [1,2,3], 1), ([4,5,6], [7], 2);
  CREATE VIEW v AS SELECT column3 AS id, column1 AS l, NULLIF(column1, column2) AS nl FROM t;

  SELECT id, nl, array_append(nl, 9), array_prepend(9, nl) FROM v ORDER BY id;
  -- row 1: nl = NULL  →  [1, 2, 3, 9]  and  [9, 1, 2, 3]
  -- expected (matches a true NULL input): [9] and [9]

Expected behavior

No response

Additional context

No response

Activity

  1. added theissue type on Sep 12, 2026
  2. self-assigned this
    on Sep 12, 2026
  3. added a commit that references this issue on Sep 12, 2026
    00c58db
  4. added a commit that references this issue on Oct 11, 2026
    5c45370
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions