Skip to content

sql: project set interacts badly with sorting #26720

@knz

Description

@knz

Found this while investigating a test failure on #26628, the following two queries have different results even after manual reordering of result rows.

> SELECT (i.keys).n 
      FROM (SELECT information_schema._pg_expandarray(indkey) AS keys FROM pg_index) AS i ;
> SELECT (i.keys).n 
      FROM (SELECT information_schema._pg_expandarray(indkey) AS keys FROM pg_index) AS i 
      ORDER BY 1;

The specific symptom is that if all the values of n are different in the 1st query, then some of them will become duplicated in the 2nd query.

I suspect some sort node badness i.e. mutating the tuples provided by project set in-place.

@solongordon you may have seen this without realizing

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.S-0-visible-logical-errorDatabase stores inconsistent data in some cases, or queries return invalid results silently.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions