tshprecher / antlr_psql Goto Github PK
View Code? Open in Web Editor NEWANTLR v4 grammar for Postgres SQL v10 (work in progress)
License: MIT License
ANTLR v4 grammar for Postgres SQL v10 (work in progress)
License: MIT License
Hi! What do you think about adding your grammar to official grammars repository grammars-v4? We already have PL/SQL, T-SQL, MySQL. It would be easier to maintain and fix by the community. There is at least one request on it: antlr/grammars-v4#1501
The script to generate psql tests has a hack to support queries starting with WITH
, but WITH
is not a type of query. We should be smarter about how we slot queries by properly slotting SELECT, UPDATE, etc... queries with a WITH
statement.
I am interested in contributing to this project. I have written several SQL parsers and optimisers over many years. I have also written my own ODBMS back in the day when Postgres started out.
I use antlr regularly.
Cheers
Steve T
([email protected])
I see there are some motheds is not completed, such as create_table_stmt, create_table_stmt_as and so on. could you provider the implementes of those mothed;
Once the grammar is correct, I'd like to do a pass over the tests to improve performance. We've seen high variance in the time it takes to run tests based on seemingly innocuous changes. If there's some recursion would could avoid, we should.
This would involve adding timing data to each test and check for outliers.
@mebelousov, since we're both committed to getting this done by the end of the year, I think we should start segmenting some of the low hanging fruit so we don't both work on the same things. This week, I'd like to knock the following completions:
LISTEN | 0/3 (0.00%)
LOCK | 0/34 (0.00%)
MOVE | 1/10 (10.00%)
NOTIFY | 0/2 (0.00%)
PREPARE | 0/46 (0.00%)
REASSIGN OWNED | 0/4 (0.00%)
REINDEX | 0/6 (0.00%)
RELEASE SAVEPOINT | 0/9 (0.00%)
RESET | 0/49 (0.00%)
REVOKE | 2/77 (2.60%)
ROLLBACK | 0/12 (0.00%)
ROLLBACK PREPARED | 0/4 (0.00%)
ROLLBACK TO SAVEPOINT | 0/10 (0.00%)
SAVEPOINT | 0/22 (0.00%)
SECURITY LABEL | 0/8 (0.00%)
They should be easy and bring lots more green into the test coverage status. I'm creating this issue so we don't end up working on the same things.
While trying to generate test cases (run ./scripts/gen_psql_tests src/test/regress/sql /tmp/my_local_psql_tests/
), the script fails at psql -U postgres -f /tmp/query.sql
, since it tries to connect with psql. It is required as the script connects with database to check for any syntactical errors.
Running the example parse shell script from the README produces an exception
git clone https://github.com/tshprecher/antlr_psql.git
cd antlr_psql
mvn compile
./scripts/parse "selectttt 1" stmt
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at org.antlr.v4.Tool.handleArgs(Tool.java:207)
at org.antlr.v4.Tool.<init>(Tool.java:195)
at org.antlr.v4.Tool.main(Tool.java:164)
[TOKENS]
IDENTIFIER 'selectttt'
INTEGER_LITERAL '1'
EOF '<EOF>'
[PARSE-TREE]
(stmt
(abort_stmt
(identifier selectttt)))
java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)
./scripts/parse "select 1" stmt
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:658)
at org.antlr.v4.Tool.handleArgs(Tool.java:207)
at org.antlr.v4.Tool.<init>(Tool.java:195)
at org.antlr.v4.Tool.main(Tool.java:164)
[TOKENS]
SELECT 'select'
INTEGER_LITERAL '1'
EOF '<EOF>'
[PARSE-TREE]
(stmt
(select_stmt select
(selector_clause
(column_list
(expr 1)))))
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.