Skip to content

LIKE ... ESCAPE '' panics in planner type checking #19562

@TCeason

Description

@TCeason

Repro

SELECT 'a' LIKE 'a' ESCAPE '';

Actual

The query fails with an internal panic:

Code: 1104
called `Option::unwrap()` on a `None` value

Panic site:

  • src/query/sql/src/planner/semantic/type_check.rs:5378

Expected

Databend should reject an empty ESCAPE string with a normal SQL error, or define valid behavior for it. It must not panic during planning.

Why this looks like the root cause

resolve_like() assumes the escape string has at least one character:

escape.chars().next().unwrap()

at:

  • src/query/sql/src/planner/semantic/type_check.rs:5375
  • src/query/sql/src/planner/semantic/type_check.rs:5378

When escape == "", next() returns None, so the planner panics before returning a user-facing error.

Impact

  • panic.log shows this family occurred 2 times in one migration batch.
  • Any generated or user-written query with ESCAPE '' can crash the planner path.

Suggested fix direction

  • Validate ESCAPE length before calling convert_escape_pattern()
  • Return a semantic error for zero-length or multi-character escape strings

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions