Skip to content

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

@Dandandan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions