Skip to content

DuckDB: exponential parse time on unclosed nested qualified calls with a named argument (regression from #2685) #3002

Open

Description

@alpaylan

Unclosed nested qualified calls whose argument is name = value (or name := value) double the parse time per level in DuckDB. Before #2685 (0.63.0) the same input failed in microseconds:

SELECT u.u(k=u.u(k=u.u(k=1            -- nested n levels, no closing parentheses
        bytes   main      0.63.0
  n=16   104   197 ms    0.034 ms
  n=20   128   3.1 s     0.032 ms
  n=22   140  12.7 s     0.037 ms

The closed form, the unqualified form u(k=u(k=...1 and other dialects stay linear.

use sqlparser::{dialect::DuckDbDialect, parser::Parser};
let sql = format!("SELECT {}1", "u.u(k=".repeat(22));
let _ = Parser::parse_sql(&DuckDbDialect {}, &sql); // error after ~13 s

Tested on main 9429cd3 and crates.io 0.64.0 and 0.63.0.

Found with a coverage-guided performance fuzzer; I used AI assistance for triage and verified every case above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions