`PostgreSqlDialect` accepts large amounts of non-PostgreSQL syntax
还没有人认领这个 Issue。
评估
调研方向
先以 pg_query.rs 作为 PostgreSQL 的事实标准,并查看 PostgreSQL 专用测试文件和通用方言测试文件,然后将列出的已接受语句与其预期行为进行比较。首先确定 PostgreSqlDialect 是否应拒绝这些情况,并定义一个有界范围;完成的标准是就方向达成一致,并为选定的语法提供回归覆盖。
由索引模型根据 Issue 内容生成。
描述
While building a parser correctness benchmark using libpg_query (pg_query.rs) as the PostgreSQL ground truth, we measured how often PostgreSqlDialect accepts SQL that real PostgreSQL rejects. The numbers are surprisingly high.
Against SQL extracted from the sqlparser-rs test suite itself:
- 28.7% of statements rejected by pg_query are silently accepted by
PostgreSqlDialect(37/129, PostgreSQL-specific test file) - 30.0% in the broader common-dialect test file (141/470)
We understand sqlparser-rs is intentionally permissive. The question is: is this level of permissiveness intentional for PostgreSqlDialect, or is it leakage that would be worth tightening?
Examples of what PostgreSqlDialect currently accepts
A selection from the 141 cases found, grouped by the dialect the syntax originates from:
-- Oracle
FETCH NEXT IN my_cursor INTO result_table -- INTO clause on FETCH
-- SQL Server / T-SQL
SELECT TOP 3 * FROM tbl
EXEC my_proc N'param'
MERGE … OUTPUT inserted.* INTO log_target
EXECUTE FUNCTION f -- trigger EXECUTE without ()
-- MySQL / MariaDB
INSERT customer VALUES (1, 2, 3) -- missing INTO
INSERT OR REPLACE INTO t (id) VALUES(1)
DROP FUNCTION IF EXISTS f(a INTEGER, IN b INTEGER = 1) -- defaults in DROP
-- Snowflake / BigQuery
SELECT i FROM qt QUALIFY ROW_NUMBER() OVER (...) = 1
CREATE OR REPLACE TABLE t (a INT)
CREATE OR REPLACE USER IF NOT EXISTS u1 PASSWORD='secret'
-- ClickHouse
ALTER TABLE t ON CLUSTER my_cluster ADD CONSTRAINT bar PRIMARY KEY (baz)
-- HiveQL
ALTER TABLE t SET TBLPROPERTIES('classification' = 'parquet')
-- Unclear origin / possibly over-permissive parsing
ALTER TABLE t ALTER COLUMN id ADD GENERATED AS IDENTITY -- missing ALWAYS/BY DEFAULT
COPY t FROM 'f.csv' BINARY DELIMITER ',' CSV HEADER -- mutually exclusive formats
SHOW search_path search_path -- duplicate trailing token
Happy to help with PRs if the direction is clear.
- 主要语言
- Rust
- 星标
- 3.5k
- 派生
- 774
- 平均合并
- 2 天 23 小时
- 30 天内合并 PR
- 37
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
apache/datafusion-sqlparser-rs 的其他 Issue
-
难度 2/5 1-2 天 新手友好度 72/100
apache/datafusion-sqlparser-rs#2495 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
apache/datafusion-sqlparser-rs#2461 · 2 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 73/100
apache/datafusion-sqlparser-rs#2407 ·
-
难度 2/5 1-3 小时 新手友好度 65/100
apache/datafusion-sqlparser-rs#2393 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
apache/datafusion-sqlparser-rs#2390 · 1 条评论 ·
查看 apache/datafusion-sqlparser-rs 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 75/100
TheLarkInn/aipm#2413 ·
-
documentation
难度 1/5 1 小时以内 新手友好度 90/100
alexgorbatchev/simple-ptt#15 ·
-
tooling
难度 2/5 1-3 小时 新手友好度 75/100
-
todo:ticket
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
taikoxyz/taiko-mono#22168 · 1 条评论 ·