Skip to content

Planner bug: Forgets LIMIT/OFFSET when merging UNION queries #18360

@systay

Description

@systay

For a query such as:

select id
from user
where id = 42
union
select id
from user
where id = 42
limit 3 offset 7

The planner is forgetting about the outer LIMIT/OFFSET, and sending the query down without them:

{
  "Type": "Passthrough",
  "QueryType": "SELECT",
  "Original": "(select id from user where id = 42) union (select id from user where id = 42) limit 3 offset 7",
  "Instructions": {
    "OperatorType": "Route",
    "Variant": "EqualUnique",
    "Keyspace": {
      "Name": "user",
      "Sharded": true
    },
    "FieldQuery": "select id from `user` where 1 != 1 union select id from `user` where 1 != 1",
    "Query": "select id from `user` where id = 42 union select id from `user` where id = 42",
    "Values": [
      "42"
    ],
    "Vindex": "user_index"
  },
  "TablesUsed": [
    "user.user"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions