Skip to content

panic: INSERT VALUES placeholder $0 underflows parameter index inference #22224

Closed

Description

@Dandandan

Describe the bug

Planning an INSERT ... VALUES statement with placeholder $0 panics. Other statement forms reject $0, but this DML path parses the placeholder index as usize and subtracts one without checking for zero.

To Reproduce

CREATE TABLE t AS SELECT 1 AS x;
EXPLAIN INSERT INTO t VALUES ($0);

Actual behavior

thread 'main' panicked at datafusion/sql/src/statement.rs:2339:29:
attempt to subtract with overflow

Expected behavior

Return a planning error such as Invalid placeholder, zero is not a valid index: $0.

Notes

SELECT $0 and PREPARE p AS SELECT $0 already return a clean planning error; the INSERT ... VALUES inference path should do the same.

Activity

  1. nathanb9 commented on May 15, 2026

    @nathanb9
    Contributor

    @Dandandan Are these issues found from fuzzing? Could you link that if so please?

  2. Dandandan commented on May 15, 2026

    @Dandandan
    ContributorAuthor

    @Dandandan Are these issues found from fuzzing? Could you link that if so please?

    This one was from instructing Codex to find distinct query crashes using

    /goal and then something like "find 20 unique crashes in sql / planner. Continue until you found 20 distinct issues and create a github issue with a minimal reproducer for each"

  3. Dandandan commented on May 15, 2026

    @Dandandan
    ContributorAuthor

    The earlier ones where from setting up https://github.com/rust-fuzz/cargo-fuzz and have it generate random inputs while parsing / planning.

  4. added a commit that references this issue on Jun 1, 2026
    a8761a6
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions