Repository navigation
PostgreSQL: Support CREATE FOREIGN DATA WRAPPER - #2317
fmguerreiro wants to merge 16 commits into
Conversation
|
I suggest to split the PR into two, once for each statement |
538c418 to
54177bd
Compare
|
split. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2317 +/- ##
==========================================
+ Coverage 81.31% 81.32% +0.01%
==========================================
Files 42 42
Lines 33977 34040 +63
Branches 33977 34040 +63
==========================================
+ Hits 27628 27684 +56
Misses 2785 2785
- Partials 3564 3571 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| #[test] | ||
| fn test_create_foreign_data_wrapper_span_includes_option_keys() { | ||
| let dialect = &crate::dialect::PostgreSqlDialect {}; | ||
| let sql = "CREATE FOREIGN DATA WRAPPER myfdw HANDLER myhandler OPTIONS (debug 'true')"; | ||
| let mut test = SpanTest::new(dialect, sql); | ||
|
|
||
| // Ends at the option key, not the statement: a quoted option value is an | ||
| // Ident with an empty span, so it contributes nothing to the union. | ||
| let stmt = test.0.parse_statement().unwrap(); | ||
| assert_eq!( | ||
| test.get_source(stmt.span()), | ||
| "myfdw HANDLER myhandler OPTIONS (debug" | ||
| ); | ||
| } |
There was a problem hiding this comment.
You should drop this test. It asserts the truncated span ... OPTIONS (debug, which comes from parse_identifier returning Span::empty() for single-quoted strings (src/parser/mod.rs:13877). The test turns that defect into a contract, so a later fix of the value span would break it.
| #[test] | |
| fn test_create_foreign_data_wrapper_span_includes_option_keys() { | |
| let dialect = &crate::dialect::PostgreSqlDialect {}; | |
| let sql = "CREATE FOREIGN DATA WRAPPER myfdw HANDLER myhandler OPTIONS (debug 'true')"; | |
| let mut test = SpanTest::new(dialect, sql); | |
| // Ends at the option key, not the statement: a quoted option value is an | |
| // Ident with an empty span, so it contributes nothing to the union. | |
| let stmt = test.0.parse_statement().unwrap(); | |
| assert_eq!( | |
| test.get_source(stmt.span()), | |
| "myfdw HANDLER myhandler OPTIONS (debug" | |
| ); | |
| } |
| // Pinning the message keeps this from passing on the old positional parser, | ||
| // which also errored here but on the trailing tokens instead. |
There was a problem hiding this comment.
Differential comment with previous code.
| // Pinning the message keeps this from passing on the old positional parser, | |
| // which also errored here but on the trailing tokens instead. |
| }]) | ||
| ); | ||
|
|
||
| // A single hardcoded Display label would render this as `NO HANDLER NO HANDLER`. |
There was a problem hiding this comment.
Do not include comments describing the PR change, comments are for describing the code.
| // A single hardcoded Display label would render this as `NO HANDLER NO HANDLER`. |
59608c6 to
4d03db2
Compare
LucaCappelletti94
left a comment
There was a problem hiding this comment.
Do please also add some seed entries for the fuzzer corpus, so it can better search bugs that are relevant to this syntax.
Share one has_modifier check between the FOREIGN TABLE and FOREIGN DATA WRAPPER arms so temporary/or-alter/global no longer parse and render as a bare CREATE FOREIGN DATA WRAPPER. Add fuzz seeds.
LucaCappelletti94
left a comment
There was a problem hiding this comment.
Most likely "A repeated clause errors." should be dropped from the description once the parser keeps repeats, given the pg_query reference.
Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com>
Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com>
Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com>
Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com>
Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com>
Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com>
Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com>
Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com>
# Conflicts: # tests/sqlparser_postgres.rs
# Conflicts: # tests/sqlparser_postgres.rs
# Conflicts: # tests/sqlparser_postgres.rs
Parses
CREATE FOREIGN DATA WRAPPER name [HANDLER fn | NO HANDLER] [VALIDATOR fn | NO VALIDATOR] [OPTIONS (...)](docs).Split out of this PR at @LucaCappelletti94's request.
CREATE FOREIGN TABLEis now #2515.HANDLERandVALIDATORare accepted in either order, because the PostgreSQL grammar takes them as an unordered list even though the doc synopsis shows one order.ALTER FOREIGN DATA WRAPPERandCREATE USER MAPPINGare out of scope.Ported from the
pgmold-sqlparserfork.