Documentation
¶
Overview ¶
Package parser 封装 TiDB SQL 解析器,提供 VDS SQL 层使用的 AST 类型。
M1 只支持单语句解析,不支持多语句批量解析。 底层使用 github.com/pingcap/tidb/pkg/parser(ADR-004)。
SQL 重写机制:
parser 包实现了 SQL 方言转换层,通过正则表达式重写将非标准 SQL 语法 转换为 TiDB Parser 可接受的形式。当前支持的重写规则:
- ON CONFLICT DO UPDATE → ON DUPLICATE KEY UPDATE(PostgreSQL → MySQL)
- ON CONFLICT DO NOTHING → INSERT IGNORE INTO
- DROP CONSTRAINT → DROP FOREIGN KEY
- ALTER COLUMN SET DEFAULT <time_func> → sentinel 字符串(绕过 TiDB Parser 限制)
重写后的 SQL 由 builder 层识别 sentinel 前缀并转换回正确的表达式类型。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.