Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`PostgreSqlDialect` accepts large amounts of non-PostgreSQL syntax

已关闭
#2,237 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
rust, sql

调研方向

先以 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

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/datafusion-sqlparser-rs 的其他 Issue

查看 apache/datafusion-sqlparser-rs 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。