diff --git a/crates/parser/tests/skipped.txt b/crates/parser/tests/skipped.txt new file mode 100644 index 00000000..921d9f5c --- /dev/null +++ b/crates/parser/tests/skipped.txt @@ -0,0 +1,212 @@ +advisory_lock +aggregates +alter_generic +alter_operator +alter_table +amutils +arrays +async +bit +bitmapops +boolean +box +brin +brin_bloom +brin_multi +btree_index +case +char +circle +cluster +collate.icu.utf8 +collate.linux.utf8 +collate +combocid +comments +compression +constraints +conversion +copy +copy2 +copydml +copyselect +create_aggregate +create_am +create_cast +create_function_c +create_function_sql +create_index +create_index_spgist +create_misc +create_operator +create_procedure +create_role +create_table +create_table_like +create_type +create_view +date +dbsize +delete +dependency +domain +drop_if_exists +drop_operator +enum +equivclass +errors +event_trigger +explain +expressions +fast_default +float4 +float8 +foreign_data +foreign_key +functional_deps +generated +geometry +gin +gist +groupingsets +guc +hash_func +hash_index +hash_part +horology +identity +incremental_sort +index_including +index_including_gist +indexing +indirect_toast +inet +infinite_recurse +inherit +init_privs +insert +insert_conflict +int2 +int4 +int8 +interval +join +join_hash +json +json_encoding +jsonb +jsonb_jsonpath +jsonpath +jsonpath_encoding +largeobject +limit +line +lock +macaddr +macaddr8 +matview +memoize +merge +misc +misc_functions +misc_sanity +money +multirangetypes +mvcc +name +namespace +numeric +numeric_big +numerology +object_address +oid +oidjoins +opr_sanity +partition_aggregate +partition_info +partition_join +partition_prune +password +path +pg_lsn +plancache +plpgsql +point +polygon +polymorphism +portals +portals_p2 +prepare +prepared_xacts +privileges +psql +psql_crosstab +publication +random +rangefuncs +rangetypes +regex +regproc +reindex_catalog +reloptions +replica_identity +returning +roleattributes +rowsecurity +rowtypes +rules +sanity_check +security_label +select +select_distinct +select_distinct_on +select_having +select_implicit +select_into +select_parallel +select_views +sequence +spgist +stats +stats_ext +strings +subscription +subselect +sysviews +tablesample +tablespace +temp +test_setup +text +tid +tidrangescan +tidscan +time +timestamp +timestamptz +timetz +transactions +triggers +truncate +tsdicts +tsearch +tsrf +tstypes +tuplesort +txid +type_sanity +typed_table +unicode +union +updatable_views +update +uuid +vacuum +vacuum_parallel +varchar +window +with +write_parallel +xid +xml +xmlmap diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@1.snap b/crates/parser/tests/snapshots/statements/valid/lseg@1.snap new file mode 100644 index 00000000..23e17490 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@1.snap @@ -0,0 +1,114 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "--\n-- LSEG\n-- Line segments\n--\n\n--DROP TABLE LSEG_TBL;\nCREATE TABLE LSEG_TBL (s lseg);" +--- +Parse { + cst: SourceFile@0..86 + SqlComment@0..2 "--" + Newline@2..3 "\n" + SqlComment@3..10 "-- LSEG" + Newline@10..11 "\n" + SqlComment@11..27 "-- Line segments" + Newline@27..28 "\n" + SqlComment@28..30 "--" + Newline@30..32 "\n\n" + SqlComment@32..54 "--DROP TABLE LSEG_TBL;" + Newline@54..55 "\n" + CreateStmt@55..86 + Create@55..61 "CREATE" + Whitespace@61..62 " " + Table@62..67 "TABLE" + Whitespace@67..68 " " + RangeVar@68..76 + Ident@68..76 "LSEG_TBL" + Whitespace@76..77 " " + Ascii40@77..78 "(" + ColumnDef@78..84 + Ident@78..79 "s" + Whitespace@79..80 " " + TypeName@80..84 + Ident@80..84 "lseg" + Ascii41@84..85 ")" + Ascii59@85..86 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: CreateStmt( + CreateStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 13, + }, + ), + table_elts: [ + Node { + node: Some( + ColumnDef( + ColumnDef { + colname: "s", + type_name: Some( + TypeName { + names: [ + Node { + node: Some( + String( + String { + sval: "lseg", + }, + ), + ), + }, + ], + type_oid: 0, + setof: false, + pct_type: false, + typmods: [], + typemod: -1, + array_bounds: [], + location: 25, + }, + ), + compression: "", + inhcount: 0, + is_local: true, + is_not_null: false, + is_from_type: false, + storage: "", + raw_default: None, + cooked_default: None, + identity: "", + identity_sequence: None, + generated: "", + coll_clause: None, + coll_oid: 0, + constraints: [], + fdwoptions: [], + location: 23, + }, + ), + ), + }, + ], + inh_relations: [], + partbound: None, + partspec: None, + of_typename: None, + constraints: [], + options: [], + oncommit: OncommitNoop, + tablespacename: "", + access_method: "", + if_not_exists: false, + }, + ), + range: 54..85, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@10.snap b/crates/parser/tests/snapshots/statements/valid/lseg@10.snap new file mode 100644 index 00000000..4e0fa4f1 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@10.snap @@ -0,0 +1,113 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "-- NaN\n\n-- bad values for parser testing\nINSERT INTO LSEG_TBL VALUES ('(3asdf,2 ,3,4r2)');" +--- +Parse { + cst: SourceFile@0..90 + SqlComment@0..6 "-- NaN" + Newline@6..8 "\n\n" + SqlComment@8..40 "-- bad values for par ..." + Newline@40..41 "\n" + InsertStmt@41..90 + Insert@41..47 "INSERT" + Whitespace@47..48 " " + Into@48..52 "INTO" + Whitespace@52..53 " " + RangeVar@53..61 + Ident@53..61 "LSEG_TBL" + Whitespace@61..62 " " + SelectStmt@62..88 + Values@62..68 "VALUES" + Whitespace@68..69 " " + Ascii40@69..70 "(" + List@70..88 + AConst@70..88 + Sconst@70..88 "'(3asdf,2 ,3,4r2)'" + Ascii41@88..89 ")" + Ascii59@89..90 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "(3asdf,2 ,3,4r2)", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 40..89, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@11.snap b/crates/parser/tests/snapshots/statements/valid/lseg@11.snap new file mode 100644 index 00000000..dc2de0f4 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@11.snap @@ -0,0 +1,109 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES ('[1,2,3, 4');" +--- +Parse { + cst: SourceFile@0..42 + InsertStmt@0..42 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..40 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..40 + AConst@29..40 + Sconst@29..40 "'[1,2,3, 4'" + Ascii41@40..41 ")" + Ascii59@41..42 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "[1,2,3, 4", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..41, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@12.snap b/crates/parser/tests/snapshots/statements/valid/lseg@12.snap new file mode 100644 index 00000000..57cd5e38 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@12.snap @@ -0,0 +1,109 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES ('[(,2),(3,4)]');" +--- +Parse { + cst: SourceFile@0..45 + InsertStmt@0..45 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..43 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..43 + AConst@29..43 + Sconst@29..43 "'[(,2),(3,4)]'" + Ascii41@43..44 ")" + Ascii59@44..45 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "[(,2),(3,4)]", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..44, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@13.snap b/crates/parser/tests/snapshots/statements/valid/lseg@13.snap new file mode 100644 index 00000000..8b73208c --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@13.snap @@ -0,0 +1,109 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)');" +--- +Parse { + cst: SourceFile@0..45 + InsertStmt@0..45 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..43 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..43 + AConst@29..43 + Sconst@29..43 "'[(1,2),(3,4)'" + Ascii41@43..44 ")" + Ascii59@44..45 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "[(1,2),(3,4)", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..44, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@14.snap b/crates/parser/tests/snapshots/statements/valid/lseg@14.snap new file mode 100644 index 00000000..2a8668a7 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@14.snap @@ -0,0 +1,99 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: select * from LSEG_TBL; +--- +Parse { + cst: SourceFile@0..23 + SelectStmt@0..23 + Select@0..6 "select" + Whitespace@6..7 " " + ResTarget@7..8 + ColumnRef@7..8 + AStar@7..8 + Ascii42@7..8 "*" + Whitespace@8..9 " " + From@9..13 "from" + Whitespace@13..14 " " + RangeVar@14..22 + Ident@14..22 "LSEG_TBL" + Ascii59@22..23 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [ + Node { + node: Some( + ResTarget( + ResTarget { + name: "", + indirection: [], + val: Some( + Node { + node: Some( + ColumnRef( + ColumnRef { + fields: [ + Node { + node: Some( + AStar( + AStar, + ), + ), + }, + ], + location: 7, + }, + ), + ), + }, + ), + location: 7, + }, + ), + ), + }, + ], + from_clause: [ + Node { + node: Some( + RangeVar( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 14, + }, + ), + ), + }, + ], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + range: 0..22, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@2.snap b/crates/parser/tests/snapshots/statements/valid/lseg@2.snap new file mode 100644 index 00000000..54bb116a --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@2.snap @@ -0,0 +1,109 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES ('[(1,2),(3,4)]');" +--- +Parse { + cst: SourceFile@0..46 + InsertStmt@0..46 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..44 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..44 + AConst@29..44 + Sconst@29..44 "'[(1,2),(3,4)]'" + Ascii41@44..45 ")" + Ascii59@45..46 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "[(1,2),(3,4)]", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..45, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@3.snap b/crates/parser/tests/snapshots/statements/valid/lseg@3.snap new file mode 100644 index 00000000..b3772276 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@3.snap @@ -0,0 +1,109 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES ('(0,0),(6,6)');" +--- +Parse { + cst: SourceFile@0..44 + InsertStmt@0..44 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..42 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..42 + AConst@29..42 + Sconst@29..42 "'(0,0),(6,6)'" + Ascii41@42..43 ")" + Ascii59@43..44 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "(0,0),(6,6)", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..43, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@4.snap b/crates/parser/tests/snapshots/statements/valid/lseg@4.snap new file mode 100644 index 00000000..2b7200b5 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@4.snap @@ -0,0 +1,109 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES ('10,-10 ,-3,-4');" +--- +Parse { + cst: SourceFile@0..46 + InsertStmt@0..46 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..44 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..44 + AConst@29..44 + Sconst@29..44 "'10,-10 ,-3,-4'" + Ascii41@44..45 ")" + Ascii59@45..46 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "10,-10 ,-3,-4", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..45, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@5.snap b/crates/parser/tests/snapshots/statements/valid/lseg@5.snap new file mode 100644 index 00000000..78c14eb2 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@5.snap @@ -0,0 +1,109 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES ('[-1e6,2e2,3e5, -4e1]');" +--- +Parse { + cst: SourceFile@0..53 + InsertStmt@0..53 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..51 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..51 + AConst@29..51 + Sconst@29..51 "'[-1e6,2e2,3e5, -4e1]'" + Ascii41@51..52 ")" + Ascii59@52..53 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "[-1e6,2e2,3e5, -4e1]", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..52, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@6.snap b/crates/parser/tests/snapshots/statements/valid/lseg@6.snap new file mode 100644 index 00000000..c5974449 --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@6.snap @@ -0,0 +1,273 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES (lseg(point(11, 22), point(33,44)));" +--- +Parse { + cst: SourceFile@0..64 + InsertStmt@0..64 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..60 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..60 + FuncCall@29..60 + Ident@29..33 "lseg" + Ascii40@33..34 "(" + FuncCall@34..46 + Ident@34..39 "point" + Ascii40@39..40 "(" + AConst@40..42 + Iconst@40..42 "11" + Ascii44@42..43 "," + Whitespace@43..44 " " + AConst@44..46 + Iconst@44..46 "22" + Ascii41@46..47 ")" + Ascii44@47..48 "," + Whitespace@48..49 " " + FuncCall@49..60 + Ident@49..54 "point" + Ascii40@54..55 "(" + AConst@55..57 + Iconst@55..57 "33" + Ascii44@57..58 "," + AConst@58..60 + Iconst@58..60 "44" + Ascii41@60..61 ")" + Ascii41@61..62 ")" + Ascii41@62..63 ")" + Ascii59@63..64 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + FuncCall( + FuncCall { + funcname: [ + Node { + node: Some( + String( + String { + sval: "lseg", + }, + ), + ), + }, + ], + args: [ + Node { + node: Some( + FuncCall( + FuncCall { + funcname: [ + Node { + node: Some( + String( + String { + sval: "point", + }, + ), + ), + }, + ], + args: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 40, + val: Some( + Ival( + Integer { + ival: 11, + }, + ), + ), + }, + ), + ), + }, + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 44, + val: Some( + Ival( + Integer { + ival: 22, + }, + ), + ), + }, + ), + ), + }, + ], + agg_order: [], + agg_filter: None, + over: None, + agg_within_group: false, + agg_star: false, + agg_distinct: false, + func_variadic: false, + funcformat: CoerceExplicitCall, + location: 34, + }, + ), + ), + }, + Node { + node: Some( + FuncCall( + FuncCall { + funcname: [ + Node { + node: Some( + String( + String { + sval: "point", + }, + ), + ), + }, + ], + args: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 55, + val: Some( + Ival( + Integer { + ival: 33, + }, + ), + ), + }, + ), + ), + }, + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 58, + val: Some( + Ival( + Integer { + ival: 44, + }, + ), + ), + }, + ), + ), + }, + ], + agg_order: [], + agg_filter: None, + over: None, + agg_within_group: false, + agg_star: false, + agg_distinct: false, + func_variadic: false, + funcformat: CoerceExplicitCall, + location: 49, + }, + ), + ), + }, + ], + agg_order: [], + agg_filter: None, + over: None, + agg_within_group: false, + agg_star: false, + agg_distinct: false, + func_variadic: false, + funcformat: CoerceExplicitCall, + location: 29, + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..63, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@7.snap b/crates/parser/tests/snapshots/statements/valid/lseg@7.snap new file mode 100644 index 00000000..12a61e7b --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@7.snap @@ -0,0 +1,109 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "INSERT INTO LSEG_TBL VALUES ('[(-10,2),(-10,3)]');" +--- +Parse { + cst: SourceFile@0..50 + InsertStmt@0..50 + Insert@0..6 "INSERT" + Whitespace@6..7 " " + Into@7..11 "INTO" + Whitespace@11..12 " " + RangeVar@12..20 + Ident@12..20 "LSEG_TBL" + Whitespace@20..21 " " + SelectStmt@21..48 + Values@21..27 "VALUES" + Whitespace@27..28 " " + Ascii40@28..29 "(" + List@29..48 + AConst@29..48 + Sconst@29..48 "'[(-10,2),(-10,3)]'" + Ascii41@48..49 ")" + Ascii59@49..50 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "[(-10,2),(-10,3)]", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 0..49, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@8.snap b/crates/parser/tests/snapshots/statements/valid/lseg@8.snap new file mode 100644 index 00000000..c4a7ec1d --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@8.snap @@ -0,0 +1,111 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "-- vertical\nINSERT INTO LSEG_TBL VALUES ('[(0,-20),(30,-20)]');" +--- +Parse { + cst: SourceFile@0..63 + SqlComment@0..11 "-- vertical" + Newline@11..12 "\n" + InsertStmt@12..63 + Insert@12..18 "INSERT" + Whitespace@18..19 " " + Into@19..23 "INTO" + Whitespace@23..24 " " + RangeVar@24..32 + Ident@24..32 "LSEG_TBL" + Whitespace@32..33 " " + SelectStmt@33..61 + Values@33..39 "VALUES" + Whitespace@39..40 " " + Ascii40@40..41 "(" + List@41..61 + AConst@41..61 + Sconst@41..61 "'[(0,-20),(30,-20)]'" + Ascii41@61..62 ")" + Ascii59@62..63 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "[(0,-20),(30,-20)]", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 11..62, + }, + ], +} diff --git a/crates/parser/tests/snapshots/statements/valid/lseg@9.snap b/crates/parser/tests/snapshots/statements/valid/lseg@9.snap new file mode 100644 index 00000000..671a8bee --- /dev/null +++ b/crates/parser/tests/snapshots/statements/valid/lseg@9.snap @@ -0,0 +1,111 @@ +--- +source: crates/parser/tests/statement_parser_test.rs +description: "-- horizontal\nINSERT INTO LSEG_TBL VALUES ('[(NaN,1),(NaN,90)]');" +--- +Parse { + cst: SourceFile@0..65 + SqlComment@0..13 "-- horizontal" + Newline@13..14 "\n" + InsertStmt@14..65 + Insert@14..20 "INSERT" + Whitespace@20..21 " " + Into@21..25 "INTO" + Whitespace@25..26 " " + RangeVar@26..34 + Ident@26..34 "LSEG_TBL" + Whitespace@34..35 " " + SelectStmt@35..63 + Values@35..41 "VALUES" + Whitespace@41..42 " " + Ascii40@42..43 "(" + List@43..63 + AConst@43..63 + Sconst@43..63 "'[(NaN,1),(NaN,90)]'" + Ascii41@63..64 ")" + Ascii59@64..65 ";" + , + errors: [], + stmts: [ + RawStmt { + stmt: InsertStmt( + InsertStmt { + relation: Some( + RangeVar { + catalogname: "", + schemaname: "", + relname: "lseg_tbl", + inh: true, + relpersistence: "p", + alias: None, + location: 12, + }, + ), + cols: [], + select_stmt: Some( + Node { + node: Some( + SelectStmt( + SelectStmt { + distinct_clause: [], + into_clause: None, + target_list: [], + from_clause: [], + where_clause: None, + group_clause: [], + group_distinct: false, + having_clause: None, + window_clause: [], + values_lists: [ + Node { + node: Some( + List( + List { + items: [ + Node { + node: Some( + AConst( + AConst { + isnull: false, + location: 29, + val: Some( + Sval( + String { + sval: "[(NaN,1),(NaN,90)]", + }, + ), + ), + }, + ), + ), + }, + ], + }, + ), + ), + }, + ], + sort_clause: [], + limit_offset: None, + limit_count: None, + limit_option: Default, + locking_clause: [], + with_clause: None, + op: SetopNone, + all: false, + larg: None, + rarg: None, + }, + ), + ), + }, + ), + on_conflict_clause: None, + returning_list: [], + with_clause: None, + r#override: OverridingNotSet, + }, + ), + range: 13..64, + }, + ], +} diff --git a/crates/parser/tests/statement_parser_test.rs b/crates/parser/tests/statement_parser_test.rs index 93bb19d7..f5d8fbcc 100644 --- a/crates/parser/tests/statement_parser_test.rs +++ b/crates/parser/tests/statement_parser_test.rs @@ -7,51 +7,60 @@ use pg_query::split_with_parser; use std::{fs, panic}; const VALID_STATEMENTS_PATH: &str = "tests/data/statements/valid/"; +const POSTGRES_REGRESS_PATH: &str = "../../libpg_query/test/sql/postgres_regress/"; +const SKIPPED_REGRESS_TESTS: &str = include_str!("skipped.txt"); #[test] fn valid_statements() { common::setup(); - let mut paths: Vec<_> = fs::read_dir(VALID_STATEMENTS_PATH) - .unwrap() - .map(|r| r.unwrap()) - .collect(); - paths.sort_by_key(|dir| dir.path()); + for path in [VALID_STATEMENTS_PATH, POSTGRES_REGRESS_PATH] { + let mut paths: Vec<_> = fs::read_dir(path).unwrap().map(|r| r.unwrap()).collect(); + paths.sort_by_key(|dir| dir.path()); - for f in paths.iter() { - let path = f.path(); - let test_name = path.file_stem().unwrap().to_str().unwrap(); + for f in paths.iter() { + let path = f.path(); + let test_name = path.file_stem().unwrap().to_str().unwrap(); - let contents = fs::read_to_string(&path).unwrap(); - let cases = split_with_parser(&contents).unwrap(); + if SKIPPED_REGRESS_TESTS + .lines() + .collect::>() + .contains(&test_name) + { + continue; + } - for (i, case) in cases.iter().enumerate() { - let case = format!("{};", case.trim()); + let contents = fs::read_to_string(&path).unwrap(); + let cases = split_with_parser(&contents).unwrap(); - debug!("Parsing statement {}\n{}", test_name, case); + for (i, case) in cases.iter().enumerate() { + let case = format!("{};", case.trim()); - let result = panic::catch_unwind(|| parse_source(&case)); + debug!("Parsing statement {}\n{}", test_name, case); - if result.is_err() { - assert!(false, "Failed to parse statement {}:\n{}", test_name, case); - } else { - info!( - "Successfully parsed statement {}\n'{}'\n{:#?}", - test_name, - case, - result.as_ref().unwrap().cst - ); - } + let result = panic::catch_unwind(|| parse_source(&case)); - let mut settings = Settings::clone_current(); - settings.set_input_file(&path); - settings.set_prepend_module_to_snapshot(false); - settings.set_description(case.to_string()); - settings.set_omit_expression(true); - settings.set_snapshot_path("snapshots/statements/valid"); - settings.set_snapshot_suffix((i + 1).to_string()); + if result.is_err() { + assert!(false, "Failed to parse statement {}:\n{}", test_name, case); + } else { + info!( + "Successfully parsed statement {}\n'{}'\n{:#?}", + test_name, + case, + result.as_ref().unwrap().cst + ); + } - settings.bind(|| assert_debug_snapshot!(test_name, result.unwrap())); + let mut settings = Settings::clone_current(); + settings.set_input_file(&path); + settings.set_prepend_module_to_snapshot(false); + settings.set_description(case.to_string()); + settings.set_omit_expression(true); + settings.set_snapshot_path("snapshots/statements/valid"); + settings.set_snapshot_suffix((i + 1).to_string()); + + settings.bind(|| assert_debug_snapshot!(test_name, result.unwrap())); + } } } }