*WORK IN PROGRESS*
# Antlr4 grammar for PostgresSQL v10.
This project is in development. See `/test_coverage.html` for a breakdown of test results
by query type. Development is test driven, with tests generated by scraping sql commands
directly from the source postgres repo. See the scripts section below for details.
# Setup
This project was built on MacOs v.10.14 using
- Maven v.3.3.9
- Python v.2.7.13
- Java v.1.8.0_144
Maven and Java are used for building and testing. Some scripts use Python.
# Generating the parser
To generate the Java parser code used for testing, run ` mvn compile`.
# Testing
Test queries live in `src/test/resources` categorized by query type. Each has been
scraped from code in the source postgres repo and each query type has a Java test harness.
For example, running `mvn -Dtest=SelectCommandTest test` runs tests against all `SELECT`
queries. To run tests against all queries, run `mvn test`.
Most tests fail simply because this project is incomplete. The development process
has been test -> fail -> pick a failing query -> fix it. Addressing the root cause
of a single failing test often fixes others, although diminishing returns applies
as total accuracy increases.
Note that since each test lives in its own file and filesystems have minimum page sizes
(e.g. 4K), the size of this repo can be over 80MB. Having each test in single file
has been helpful for debugging. Test queries may be consolidated into fewer files
when this project reaches a stable state.
# Scripts
## Generating test files
As mentioned, tests have been generated from the official postgres repo
(https://github.com/postgres/postgres). To regenerate them, fetch the repository
at the desired version and run `./scripts/gen_psql_tests src/test/regress/sql /tmp/my_local_psql_tests/`
where `src/test/regress/sql` is a directory in the source postgres project.
## Parsing a specific query
Sometimes it is useful to see exactly where the parser fails on a specific query.
You could use [IntelliJ Idea Plugin for ANTLR v4](https://github.com/antlr/intellij-plugin-v4) for testing.
Also there's a script for that. To see where the parser fails on `selectttt 1`, run `./scripts/parse "selectttt 1" stmt`.
The first argument is the query and the second the grammar rule, with `stmt` being the root rule defined
in `PostgreSQLParser.g4`.
## Generate test coverage report
The `/test_coverage.html` test coverage report can be generated from piping a script that runs all
the tests and filters out summary lines into one that formats those lines into an html table.
Simply run `./scripts/get_test_output | ./scripts/format_test_results > test_coverage.html`. Note
that this can take a minute through the entire suite.
`./scripts/get_test_output` also fills `failed.log` with the names of currently failed scripts.
Sometimes small changes in parser could cause a decrease of the success rates in the coverage report.
`scripts/print_uncommitted_failed_sql` prints to console a code of the statements that previously were
success and now have status 'failed'. In normal way the length of `failed.log` should only decrease.
没有合适的资源?快使用搜索试试~ 我知道了~
antlr_psql:适用于Postgres SQL v10的ANTLR v4语法(正在进行中)
共21102个文件
sql:21078个
java:9个
g4:2个
5 下载量 95 浏览量
2021-01-28
13:16:08
上传
评论 1
收藏 6.5MB ZIP 举报
温馨提示
工作正在进行中 PostgresSQL v10的Antlr4语法。 该项目正在开发中。 有关按查询类型分类的测试结果的详细/test_coverage.html ,请参见/test_coverage.html 。 开发是测试驱动的,测试是通过直接从源postgres存储库中抓取sql命令生成的。 有关详细信息,请参见下面的脚本部分。 设定 该项目基于MacOs v.10.14构建,使用 Maven v.3.3.9 Python v.2.7.13 Java v.1.8.0_144 Maven和Java用于构建和测试。 一些脚本使用Python。 生成解析器 要生成用于测试的Java解析器代码,请运行mvn compile 。 测验 测试查询位于按查询类型分类的src/test/resources 。 每个已从源postgres存储库中的代码中删除,每个查询类型都具有Java测试工具。 例如,运行mvn -Dtest=SelectCommandTest test测试针对所有SELECT查询运行测试。 要针对所有查询运行测试,请运行mvn test 。 大多数测试失败仅是因为该
资源详情
资源评论
资源推荐
收起资源包目录
antlr_psql:适用于Postgres SQL v10的ANTLR v4语法(正在进行中) (21102个子文件)
format_test_results 1KB
PostgreSQLParser.g4 59KB
PostgreSQLLexer.g4 48KB
gen_psql_tests 7KB
get_test_output 162B
.gitignore 74B
test_coverage.html 11KB
AlterCommandTest.java 6KB
DropCommandTest.java 6KB
MiscCommandTest.java 6KB
CreateCommandTest.java 5KB
CommandTest.java 3KB
SelectCommandTest.java 390B
UpdateCommandTest.java 263B
DeleteCommandTest.java 263B
InsertCommandTest.java 263B
LICENSE 1KB
LICENSE 1KB
failed.log 65KB
README.md 3KB
parse 4KB
print_uncommitted_failed_sql 160B
README 211B
b8909bf7.sql 7KB
f8fe46fd.sql 5KB
59192aa4.sql 3KB
2ec081f7.sql 2KB
5988d2e5.sql 2KB
479f5ab5.sql 2KB
5ea4442f.sql 2KB
16d0ff96.sql 2KB
b71f5a16.sql 2KB
e4510aed.sql 2KB
e2a32241.sql 2KB
c7056f4f.sql 1KB
cc992edb.sql 1KB
7116e5f8.sql 1KB
2025b76c.sql 1KB
316ab813.sql 1KB
17e7e1cd.sql 1KB
8f59c4f0.sql 1KB
2f7fbd15.sql 1KB
8dbe62f6.sql 1KB
3835e496.sql 1KB
2e0ae8d5.sql 987B
f71ae27d.sql 976B
76d56604.sql 970B
8e67f7ff.sql 958B
08d916ef.sql 958B
b5f240dd.sql 957B
d9168217.sql 953B
419868fb.sql 953B
4cd98a0f.sql 944B
c40ba312.sql 942B
cd79eb23.sql 941B
7ffb7270.sql 941B
23c3e63b.sql 938B
20203213.sql 937B
8ea0f40c.sql 935B
8e8a187b.sql 930B
248bb140.sql 929B
68576dc4.sql 929B
0b1f0acf.sql 929B
5d23b099.sql 929B
e022ed9d.sql 928B
0ee2aad3.sql 927B
f183130b.sql 927B
c9cb6f79.sql 926B
06fd6dbf.sql 924B
a9249162.sql 924B
23b65845.sql 923B
e5b11990.sql 923B
d811db71.sql 923B
015377d0.sql 923B
fddfdc4c.sql 922B
045631c0.sql 922B
8a9302b5.sql 921B
47790383.sql 921B
fb316d79.sql 921B
aed1abe6.sql 919B
5b465c6e.sql 919B
9fdc5bd3.sql 918B
466b4298.sql 918B
c4bd6dc1.sql 918B
ef6171d7.sql 915B
67a6ee85.sql 914B
ca30237c.sql 914B
6c47e8bb.sql 912B
b04dfabf.sql 912B
057d6bf1.sql 912B
39975791.sql 912B
3f26bc7d.sql 912B
1d430fc4.sql 911B
2ad89e7b.sql 911B
45537ed3.sql 910B
c0de9f13.sql 910B
58f012b1.sql 909B
c9268d59.sql 909B
8a423ec7.sql 909B
e94bbb44.sql 908B
共 21102 条
- 1
- 2
- 3
- 4
- 5
- 6
- 212
weixin_38662089
- 粉丝: 5
- 资源: 915
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1