Skip to content

parse_drop silently discards TEMPORARY and PERSISTENT for most object types #2779

Open

Description

@s5dsn-eqee

parse_drop consumes TEMPORARY (MySQL, Generic, DuckDB) and PERSISTENT (DuckDB) before it reads the object type. Only Statement::Drop and DROP SECRET keep these flags. Every other branch drops them, so the statement parses without error but loses the keyword when printed:

Input Dialect Output
DROP TEMPORARY FUNCTION f Generic DROP FUNCTION f
DROP TEMPORARY TRIGGER tr ON t Generic DROP TRIGGER tr ON t
DROP TEMPORARY PROCEDURE p Generic DROP PROCEDURE p
DROP PERSISTENT TABLE t DuckDB DROP TABLE t

The same applies to POLICY, CONNECTOR, DOMAIN, EXTENSION and OPERATOR.

In most cases the input isn't valid SQL anyway, so it should fail instead of being accepted. DROP TEMPORARY FUNCTION is real syntax in Spark/Databricks and Hive, so there the parser drops meaningful information.

Expected

Reject TEMPORARY/PERSISTENT for object types that don't support them, and keep the flag where a dialect does support it, e.g. DROP TEMPORARY FUNCTION.

Code

src/parser/mod.rs, Parser::parse_drop

Spotted while reviewing #2434

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions