tree-sitter-postgres 1.2.4 → 19.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -50,12 +50,18 @@ extern "C" {
50
50
  /// memory allocated for the array's contents.
51
51
  #define array_clear(self) ((self)->size = 0)
52
52
 
53
+ #ifdef __cplusplus
54
+ #define _array__cast(self, expr) (decltype((self)->contents))(expr)
55
+ #else
56
+ #define _array__cast(self, expr) (expr)
57
+ #endif
58
+
53
59
  /// Reserve `new_capacity` elements of space in the array. If `new_capacity` is
54
60
  /// less than the array's current capacity, this function has no effect.
55
- #define array_reserve(self, new_capacity) \
56
- ((self)->contents = _array__reserve( \
57
- (void *)(self)->contents, &(self)->capacity, \
58
- array_elem_size(self), new_capacity) \
61
+ #define array_reserve(self, new_capacity) \
62
+ ((self)->contents = _array__cast(self, _array__reserve( \
63
+ (void *)(self)->contents, &(self)->capacity, \
64
+ array_elem_size(self), new_capacity)) \
59
65
  )
60
66
 
61
67
  /// Free any memory allocated for this array. Note that this does not free any
@@ -71,10 +77,10 @@ extern "C" {
71
77
  /// Push a new `element` onto the end of the array.
72
78
  #define array_push(self, element) \
73
79
  do { \
74
- (self)->contents = _array__grow( \
80
+ (self)->contents = _array__cast(self, _array__grow( \
75
81
  (void *)(self)->contents, (self)->size, &(self)->capacity, \
76
82
  1, array_elem_size(self) \
77
- ); \
83
+ )); \
78
84
  (self)->contents[(self)->size++] = (element); \
79
85
  } while(0)
80
86
 
@@ -83,10 +89,10 @@ extern "C" {
83
89
  #define array_grow_by(self, count) \
84
90
  do { \
85
91
  if ((count) == 0) break; \
86
- (self)->contents = _array__grow( \
92
+ (self)->contents = _array__cast(self, _array__grow( \
87
93
  (self)->contents, (self)->size, &(self)->capacity, \
88
94
  count, array_elem_size(self) \
89
- ); \
95
+ )); \
90
96
  memset((self)->contents + (self)->size, 0, (count) * array_elem_size(self)); \
91
97
  (self)->size += (count); \
92
98
  } while (0)
@@ -98,26 +104,26 @@ extern "C" {
98
104
  /// Append `count` elements to the end of the array, reading their values from the
99
105
  /// `contents` pointer.
100
106
  #define array_extend(self, count, other_contents) \
101
- (self)->contents = _array__splice( \
107
+ ((self)->contents = _array__cast(self, _array__splice( \
102
108
  (void*)(self)->contents, &(self)->size, &(self)->capacity, \
103
109
  array_elem_size(self), (self)->size, 0, count, other_contents \
104
- )
110
+ )))
105
111
 
106
112
  /// Remove `old_count` elements from the array starting at the given `index`. At
107
113
  /// the same index, insert `new_count` new elements, reading their values from the
108
114
  /// `new_contents` pointer.
109
115
  #define array_splice(self, _index, old_count, new_count, new_contents) \
110
- (self)->contents = _array__splice( \
116
+ ((self)->contents = _array__cast(self, _array__splice( \
111
117
  (void *)(self)->contents, &(self)->size, &(self)->capacity, \
112
118
  array_elem_size(self), _index, old_count, new_count, new_contents \
113
- )
119
+ )))
114
120
 
115
121
  /// Insert one `element` into the array at the given `index`.
116
122
  #define array_insert(self, _index, element) \
117
- (self)->contents = _array__splice( \
123
+ ((self)->contents = _array__cast(self, _array__splice( \
118
124
  (void *)(self)->contents, &(self)->size, &(self)->capacity, \
119
125
  array_elem_size(self), _index, 0, 1, &(element) \
120
- )
126
+ )))
121
127
 
122
128
  /// Remove one element from the array at the given `index`.
123
129
  #define array_erase(self, _index) \
@@ -128,17 +134,17 @@ extern "C" {
128
134
 
129
135
  /// Assign the contents of one array to another, reallocating if necessary.
130
136
  #define array_assign(self, other) \
131
- (self)->contents = _array__assign( \
137
+ ((self)->contents = _array__cast(self, _array__assign( \
132
138
  (void *)(self)->contents, &(self)->size, &(self)->capacity, \
133
139
  (const void *)(other)->contents, (other)->size, array_elem_size(self) \
134
- )
140
+ )))
135
141
 
136
142
  /// Swap one array with another
137
143
  #define array_swap(self, other) \
138
144
  do { \
139
145
  void *_array_swap_tmp = (void *)(self)->contents; \
140
146
  (self)->contents = (other)->contents; \
141
- (other)->contents = _array_swap_tmp; \
147
+ (other)->contents = _array__cast(other, _array_swap_tmp); \
142
148
  _array__swap(&(self)->size, &(self)->capacity, \
143
149
  &(other)->size, &(other)->capacity); \
144
150
  } while (0)
@@ -36,12 +36,12 @@ module.exports = grammar({
36
36
  [$.utility_option_name, $.unreserved_keyword],
37
37
  [$.ConstDatetime, $.col_name_keyword],
38
38
  [$.simple_select, $.simple_select],
39
- [$.a_expr, $.a_expr],
40
39
  [$.target_el, $.target_el],
41
40
  [$.ConstDatetime, $.ConstDatetime],
42
41
  [$.table_ref, $.table_ref],
43
42
  [$.OptTempTableName, $.unreserved_keyword],
44
43
  [$.func_table, $.func_table],
44
+ [$.copy_generic_opt_elem, $.unreserved_keyword],
45
45
  ],
46
46
 
47
47
  rules: {
@@ -92,7 +92,6 @@ module.exports = grammar({
92
92
  $.CallStmt,
93
93
  $.CheckPointStmt,
94
94
  $.ClosePortalStmt,
95
- $.ClusterStmt,
96
95
  $.CommentStmt,
97
96
  $.ConstraintsSetStmt,
98
97
  $.CopyStmt,
@@ -166,6 +165,7 @@ module.exports = grammar({
166
165
  $.RemoveFuncStmt,
167
166
  $.RemoveOperStmt,
168
167
  $.RenameStmt,
168
+ $.RepackStmt,
169
169
  $.RevokeStmt,
170
170
  $.RevokeRoleStmt,
171
171
  $.RuleStmt,
@@ -179,15 +179,32 @@ module.exports = grammar({
179
179
  $.VariableResetStmt,
180
180
  $.VariableSetStmt,
181
181
  $.VariableShowStmt,
182
- $.ViewStmt
182
+ $.ViewStmt,
183
+ $.WaitStmt
183
184
  ),
184
185
  opt_single_name: $ => $.ColId,
185
186
  opt_qualified_name: $ => $.any_name,
186
187
  opt_concurrently: $ => $.kw_concurrently,
188
+ opt_usingindex: $ => seq($.kw_using, $.kw_index),
187
189
  opt_drop_behavior: $ => choice(
188
190
  $.kw_cascade,
189
191
  $.kw_restrict
190
192
  ),
193
+ opt_utility_option_list: $ => prec.left(20, prec.dynamic(20, seq('(', $.utility_option_list, ')'))),
194
+ utility_option_list: $ => choice(
195
+ $.utility_option_elem,
196
+ seq($.utility_option_list, ',', $.utility_option_elem)
197
+ ),
198
+ utility_option_elem: $ => seq($.utility_option_name, optional($.utility_option_arg)),
199
+ utility_option_name: $ => choice(
200
+ $.NonReservedWord,
201
+ $.analyze_keyword,
202
+ $.kw_format
203
+ ),
204
+ utility_option_arg: $ => choice(
205
+ $.opt_boolean_or_string,
206
+ $.NumericOnly
207
+ ),
191
208
  CallStmt: $ => seq($.kw_call, $.func_application),
192
209
  CreateRoleStmt: $ => seq($.kw_create, $.kw_role, $.RoleId, optional($.opt_with), optional($.OptRoleList)),
193
210
  opt_with: $ => choice(
@@ -269,6 +286,8 @@ module.exports = grammar({
269
286
  generic_set: $ => choice(
270
287
  seq($.var_name, $.kw_to, $.var_list),
271
288
  prec.left(7, prec.dynamic(7, seq($.var_name, '=', $.var_list))),
289
+ seq($.var_name, $.kw_to, $.kw_null),
290
+ prec.left(7, prec.dynamic(7, seq($.var_name, '=', $.kw_null))),
272
291
  seq($.var_name, $.kw_to, $.kw_default),
273
292
  prec.left(7, prec.dynamic(7, seq($.var_name, '=', $.kw_default)))
274
293
  ),
@@ -361,7 +380,7 @@ module.exports = grammar({
361
380
  $.kw_deferred,
362
381
  $.kw_immediate
363
382
  ),
364
- CheckPointStmt: $ => $.kw_checkpoint,
383
+ CheckPointStmt: $ => seq($.kw_checkpoint, optional($.opt_utility_option_list)),
365
384
  DiscardStmt: $ => choice(
366
385
  seq($.kw_discard, $.kw_all),
367
386
  seq($.kw_discard, $.kw_temp),
@@ -559,6 +578,7 @@ module.exports = grammar({
559
578
  seq($.kw_delimiter, optional($.opt_as), $.Sconst),
560
579
  seq($.kw_null, optional($.opt_as), $.Sconst),
561
580
  $.kw_csv,
581
+ $.kw_json,
562
582
  $.kw_header,
563
583
  seq($.kw_quote, optional($.opt_as), $.Sconst),
564
584
  prec.left(9, prec.dynamic(9, seq($.kw_escape, optional($.opt_as), $.Sconst))),
@@ -577,7 +597,10 @@ module.exports = grammar({
577
597
  $.copy_generic_opt_elem,
578
598
  seq($.copy_generic_opt_list, ',', $.copy_generic_opt_elem)
579
599
  ),
580
- copy_generic_opt_elem: $ => seq($.ColLabel, optional($.copy_generic_opt_arg)),
600
+ copy_generic_opt_elem: $ => choice(
601
+ seq($.ColLabel, optional($.copy_generic_opt_arg)),
602
+ seq($.kw_format, optional($.copy_generic_opt_arg))
603
+ ),
581
604
  copy_generic_opt_arg: $ => choice(
582
605
  $.opt_boolean_or_string,
583
606
  $.NumericOnly,
@@ -915,7 +938,9 @@ module.exports = grammar({
915
938
  seq($.kw_handler, $.handler_name),
916
939
  seq($.kw_no, $.kw_handler),
917
940
  seq($.kw_validator, $.handler_name),
918
- seq($.kw_no, $.kw_validator)
941
+ seq($.kw_no, $.kw_validator),
942
+ seq($.kw_connection, $.handler_name),
943
+ seq($.kw_no, $.kw_connection)
919
944
  ),
920
945
  fdw_options: $ => choice(
921
946
  $.fdw_option,
@@ -1309,13 +1334,13 @@ module.exports = grammar({
1309
1334
  fetch_args: $ => choice(
1310
1335
  $.cursor_name,
1311
1336
  seq($.from_in, $.cursor_name),
1337
+ seq($.SignedIconst, optional($.opt_from_in), $.cursor_name),
1312
1338
  seq($.kw_next, optional($.opt_from_in), $.cursor_name),
1313
1339
  seq($.kw_prior, optional($.opt_from_in), $.cursor_name),
1314
1340
  seq($.kw_first, optional($.opt_from_in), $.cursor_name),
1315
1341
  seq($.kw_last, optional($.opt_from_in), $.cursor_name),
1316
1342
  seq($.kw_absolute, $.SignedIconst, optional($.opt_from_in), $.cursor_name),
1317
1343
  seq($.kw_relative, $.SignedIconst, optional($.opt_from_in), $.cursor_name),
1318
- seq($.SignedIconst, optional($.opt_from_in), $.cursor_name),
1319
1344
  seq($.kw_all, optional($.opt_from_in), $.cursor_name),
1320
1345
  seq($.kw_forward, optional($.opt_from_in), $.cursor_name),
1321
1346
  seq($.kw_forward, $.SignedIconst, optional($.opt_from_in), $.cursor_name),
@@ -1670,9 +1695,9 @@ module.exports = grammar({
1670
1695
  ),
1671
1696
  DropTransformStmt: $ => seq($.kw_drop, $.kw_transform, optional($.opt_if_exists), $.kw_for, $.Typename, $.kw_language, $.name, optional($.opt_drop_behavior)),
1672
1697
  ReindexStmt: $ => choice(
1673
- seq($.kw_reindex, optional($.opt_reindex_option_list), $.reindex_target_relation, optional($.opt_concurrently), $.qualified_name),
1674
- seq($.kw_reindex, optional($.opt_reindex_option_list), $.kw_schema, optional($.opt_concurrently), $.name),
1675
- seq($.kw_reindex, optional($.opt_reindex_option_list), $.reindex_target_all, optional($.opt_concurrently), optional($.opt_single_name))
1698
+ seq($.kw_reindex, optional($.opt_utility_option_list), $.reindex_target_relation, optional($.opt_concurrently), $.qualified_name),
1699
+ seq($.kw_reindex, optional($.opt_utility_option_list), $.kw_schema, optional($.opt_concurrently), $.name),
1700
+ seq($.kw_reindex, optional($.opt_utility_option_list), $.reindex_target_all, optional($.opt_concurrently), optional($.opt_single_name))
1676
1701
  ),
1677
1702
  reindex_target_relation: $ => choice(
1678
1703
  $.kw_index,
@@ -1682,7 +1707,6 @@ module.exports = grammar({
1682
1707
  $.kw_system,
1683
1708
  $.kw_database
1684
1709
  ),
1685
- opt_reindex_option_list: $ => prec.left(20, prec.dynamic(20, seq('(', $.utility_option_list, ')'))),
1686
1710
  AlterTblSpcStmt: $ => choice(
1687
1711
  prec.left(11, prec.dynamic(11, seq($.kw_alter, $.kw_tablespace, $.name, $.kw_set, $.reloptions))),
1688
1712
  seq($.kw_alter, $.kw_tablespace, $.name, $.kw_reset, $.reloptions)
@@ -1830,7 +1854,7 @@ module.exports = grammar({
1830
1854
  ),
1831
1855
  CreatePublicationStmt: $ => choice(
1832
1856
  seq($.kw_create, $.kw_publication, $.name, optional($.opt_definition)),
1833
- seq($.kw_create, $.kw_publication, $.name, $.kw_for, $.kw_all, $.kw_tables, optional($.opt_definition)),
1857
+ seq($.kw_create, $.kw_publication, $.name, $.kw_for, $.pub_all_obj_type_list, optional($.opt_definition)),
1834
1858
  seq($.kw_create, $.kw_publication, $.name, $.kw_for, $.pub_obj_list, optional($.opt_definition))
1835
1859
  ),
1836
1860
  PublicationObjSpec: $ => choice(
@@ -1846,17 +1870,37 @@ module.exports = grammar({
1846
1870
  $.PublicationObjSpec,
1847
1871
  seq($.pub_obj_list, ',', $.PublicationObjSpec)
1848
1872
  ),
1873
+ opt_pub_except_clause: $ => prec.left(1, prec.dynamic(1, seq($.kw_except, '(', $.kw_table, $.pub_except_obj_list, ')'))),
1874
+ PublicationAllObjSpec: $ => choice(
1875
+ seq($.kw_all, $.kw_tables, optional($.opt_pub_except_clause)),
1876
+ seq($.kw_all, $.kw_sequences)
1877
+ ),
1878
+ pub_all_obj_type_list: $ => choice(
1879
+ $.PublicationAllObjSpec,
1880
+ seq($.pub_all_obj_type_list, ',', $.PublicationAllObjSpec)
1881
+ ),
1882
+ PublicationExceptObjSpec: $ => $.relation_expr,
1883
+ pub_except_obj_list: $ => choice(
1884
+ $.PublicationExceptObjSpec,
1885
+ seq($.pub_except_obj_list, ',', optional($.opt_table), $.PublicationExceptObjSpec)
1886
+ ),
1849
1887
  AlterPublicationStmt: $ => choice(
1850
1888
  prec.left(11, prec.dynamic(11, seq($.kw_alter, $.kw_publication, $.name, $.kw_set, $.definition))),
1851
1889
  seq($.kw_alter, $.kw_publication, $.name, $.kw_add, $.pub_obj_list),
1852
1890
  prec.left(11, prec.dynamic(11, seq($.kw_alter, $.kw_publication, $.name, $.kw_set, $.pub_obj_list))),
1891
+ prec.left(11, prec.dynamic(11, seq($.kw_alter, $.kw_publication, $.name, $.kw_set, $.pub_all_obj_type_list))),
1853
1892
  seq($.kw_alter, $.kw_publication, $.name, $.kw_drop, $.pub_obj_list)
1854
1893
  ),
1855
- CreateSubscriptionStmt: $ => seq($.kw_create, $.kw_subscription, $.name, $.kw_connection, $.Sconst, $.kw_publication, $.name_list, optional($.opt_definition)),
1894
+ CreateSubscriptionStmt: $ => choice(
1895
+ seq($.kw_create, $.kw_subscription, $.name, $.kw_connection, $.Sconst, $.kw_publication, $.name_list, optional($.opt_definition)),
1896
+ seq($.kw_create, $.kw_subscription, $.name, $.kw_server, $.name, $.kw_publication, $.name_list, optional($.opt_definition))
1897
+ ),
1856
1898
  AlterSubscriptionStmt: $ => choice(
1857
1899
  prec.left(11, prec.dynamic(11, seq($.kw_alter, $.kw_subscription, $.name, $.kw_set, $.definition))),
1858
1900
  seq($.kw_alter, $.kw_subscription, $.name, $.kw_connection, $.Sconst),
1901
+ seq($.kw_alter, $.kw_subscription, $.name, $.kw_server, $.name),
1859
1902
  seq($.kw_alter, $.kw_subscription, $.name, $.kw_refresh, $.kw_publication, optional($.opt_definition)),
1903
+ seq($.kw_alter, $.kw_subscription, $.name, $.kw_refresh, $.kw_sequences),
1860
1904
  seq($.kw_alter, $.kw_subscription, $.name, $.kw_add, $.kw_publication, $.name_list, optional($.opt_definition)),
1861
1905
  seq($.kw_alter, $.kw_subscription, $.name, $.kw_drop, $.kw_publication, $.name_list, optional($.opt_definition)),
1862
1906
  prec.left(11, prec.dynamic(11, seq($.kw_alter, $.kw_subscription, $.name, $.kw_set, $.kw_publication, $.name_list, optional($.opt_definition)))),
@@ -2023,11 +2067,14 @@ module.exports = grammar({
2023
2067
  $.kw_with
2024
2068
  ),
2025
2069
  CreateConversionStmt: $ => seq($.kw_create, optional($.opt_default), $.kw_conversion, $.any_name, $.kw_for, $.Sconst, $.kw_to, $.Sconst, $.kw_from, $.any_name),
2026
- ClusterStmt: $ => choice(
2070
+ RepackStmt: $ => choice(
2071
+ seq($.kw_repack, optional($.opt_utility_option_list), $.qualified_name, optional($.opt_name_list), $.kw_using, $.kw_index, $.name),
2072
+ seq($.kw_repack, optional($.opt_utility_option_list), $.qualified_name, optional($.opt_name_list), optional($.opt_usingindex)),
2073
+ seq($.kw_repack, optional($.opt_utility_option_list), optional($.opt_usingindex)),
2027
2074
  prec.left(20, prec.dynamic(20, seq($.kw_cluster, '(', $.utility_option_list, ')', $.qualified_name, optional($.cluster_index_specification)))),
2028
- prec.left(20, prec.dynamic(20, seq($.kw_cluster, '(', $.utility_option_list, ')'))),
2075
+ seq($.kw_cluster, optional($.opt_utility_option_list)),
2029
2076
  seq($.kw_cluster, optional($.opt_verbose), $.qualified_name, optional($.cluster_index_specification)),
2030
- seq($.kw_cluster, optional($.opt_verbose)),
2077
+ seq($.kw_cluster, $.kw_verbose),
2031
2078
  seq($.kw_cluster, optional($.opt_verbose), $.name, $.kw_on, $.qualified_name)
2032
2079
  ),
2033
2080
  cluster_index_specification: $ => seq($.kw_using, $.name),
@@ -2036,27 +2083,13 @@ module.exports = grammar({
2036
2083
  prec.left(20, prec.dynamic(20, seq($.kw_vacuum, '(', $.utility_option_list, ')', optional($.opt_vacuum_relation_list))))
2037
2084
  ),
2038
2085
  AnalyzeStmt: $ => choice(
2039
- seq($.analyze_keyword, optional($.opt_verbose), optional($.opt_vacuum_relation_list)),
2040
- prec.left(20, prec.dynamic(20, seq($.analyze_keyword, '(', $.utility_option_list, ')', optional($.opt_vacuum_relation_list))))
2041
- ),
2042
- utility_option_list: $ => choice(
2043
- $.utility_option_elem,
2044
- seq($.utility_option_list, ',', $.utility_option_elem)
2086
+ seq($.analyze_keyword, optional($.opt_utility_option_list), optional($.opt_vacuum_relation_list)),
2087
+ seq($.analyze_keyword, $.kw_verbose, optional($.opt_vacuum_relation_list))
2045
2088
  ),
2046
2089
  analyze_keyword: $ => choice(
2047
2090
  $.kw_analyze,
2048
2091
  $.kw_analyse
2049
2092
  ),
2050
- utility_option_elem: $ => seq($.utility_option_name, optional($.utility_option_arg)),
2051
- utility_option_name: $ => choice(
2052
- $.NonReservedWord,
2053
- $.analyze_keyword,
2054
- $.kw_format
2055
- ),
2056
- utility_option_arg: $ => choice(
2057
- $.opt_boolean_or_string,
2058
- $.NumericOnly
2059
- ),
2060
2093
  opt_analyze: $ => $.analyze_keyword,
2061
2094
  opt_verbose: $ => $.kw_verbose,
2062
2095
  opt_full: $ => prec.left(23, prec.dynamic(23, $.kw_full)),
@@ -2129,6 +2162,7 @@ module.exports = grammar({
2129
2162
  ),
2130
2163
  insert_column_item: $ => seq($.ColId, optional($.opt_indirection)),
2131
2164
  opt_on_conflict: $ => choice(
2165
+ seq($.kw_on, $.kw_conflict, optional($.opt_conf_expr), $.kw_do, $.kw_select, optional($.opt_for_locking_strength), optional($.where_clause)),
2132
2166
  prec.left(11, prec.dynamic(11, seq($.kw_on, $.kw_conflict, optional($.opt_conf_expr), $.kw_do, $.kw_update, $.kw_set, $.set_clause_list, optional($.where_clause)))),
2133
2167
  seq($.kw_on, $.kw_conflict, optional($.opt_conf_expr), $.kw_do, $.kw_nothing)
2134
2168
  ),
@@ -2186,11 +2220,11 @@ module.exports = grammar({
2186
2220
  seq($.merge_when_list, $.merge_when_clause)
2187
2221
  ),
2188
2222
  merge_when_clause: $ => choice(
2189
- seq($.merge_when_tgt_matched, $.opt_merge_when_condition, $.kw_then, $.merge_update),
2190
- seq($.merge_when_tgt_matched, $.opt_merge_when_condition, $.kw_then, $.merge_delete),
2191
- seq($.merge_when_tgt_not_matched, $.opt_merge_when_condition, $.kw_then, $.merge_insert),
2192
- seq($.merge_when_tgt_matched, $.opt_merge_when_condition, $.kw_then, $.kw_do, $.kw_nothing),
2193
- seq($.merge_when_tgt_not_matched, $.opt_merge_when_condition, $.kw_then, $.kw_do, $.kw_nothing)
2223
+ seq($.merge_when_tgt_matched, optional($.opt_merge_when_condition), $.kw_then, $.merge_update),
2224
+ seq($.merge_when_tgt_matched, optional($.opt_merge_when_condition), $.kw_then, $.merge_delete),
2225
+ seq($.merge_when_tgt_not_matched, optional($.opt_merge_when_condition), $.kw_then, $.merge_insert),
2226
+ seq($.merge_when_tgt_matched, optional($.opt_merge_when_condition), $.kw_then, $.kw_do, $.kw_nothing),
2227
+ seq($.merge_when_tgt_not_matched, optional($.opt_merge_when_condition), $.kw_then, $.kw_do, $.kw_nothing)
2194
2228
  ),
2195
2229
  merge_when_tgt_matched: $ => choice(
2196
2230
  seq($.kw_when, $.kw_matched),
@@ -2388,6 +2422,7 @@ module.exports = grammar({
2388
2422
  seq($.kw_for, $.kw_share),
2389
2423
  seq($.kw_for, $.kw_key, $.kw_share)
2390
2424
  ),
2425
+ opt_for_locking_strength: $ => $.for_locking_strength,
2391
2426
  locked_rels_list: $ => seq($.kw_of, $.qualified_name_list),
2392
2427
  values_clause: $ => choice(
2393
2428
  prec.left(20, prec.dynamic(20, seq($.kw_values, '(', $.expr_list, ')'))),
@@ -2657,15 +2692,15 @@ module.exports = grammar({
2657
2692
  prec.left(15, prec.dynamic(15, seq($.a_expr_prec, '^', $.a_expr_prec))),
2658
2693
  prec.left(7, prec.dynamic(7, seq($.a_expr_prec, '<', $.a_expr_prec))),
2659
2694
  prec.left(7, prec.dynamic(7, seq($.a_expr_prec, '>', $.a_expr_prec))),
2660
- prec.left(7, prec.dynamic(7, seq($.a_expr_prec, '=', $.a_expr_prec)))
2695
+ prec.left(7, prec.dynamic(7, seq($.a_expr_prec, '=', $.a_expr_prec))),
2696
+ prec.left(7, prec.dynamic(7, seq($.a_expr_prec, '<=', $.a_expr_prec))),
2697
+ prec.left(7, prec.dynamic(7, seq($.a_expr_prec, '>=', $.a_expr_prec))),
2698
+ prec.left(7, prec.dynamic(7, seq($.a_expr_prec, '<>', $.a_expr_prec)))
2661
2699
  ),
2662
2700
  a_expr: $ => choice(
2663
2701
  alias($.a_expr_prec, $.a_expr),
2664
2702
  prec.left(16, prec.dynamic(16, seq($.a_expr, $.kw_at, $.kw_time, $.kw_zone, $.a_expr))),
2665
2703
  prec.left(16, prec.dynamic(16, seq($.a_expr, $.kw_at, $.kw_local))),
2666
- prec.left(7, prec.dynamic(7, seq($.a_expr, '<=', $.a_expr))),
2667
- prec.left(7, prec.dynamic(7, seq($.a_expr, '>=', $.a_expr))),
2668
- prec.left(7, prec.dynamic(7, seq($.a_expr, '<>', $.a_expr))),
2669
2704
  prec.left(12, prec.dynamic(12, seq($.a_expr, $.qual_Op, $.a_expr))),
2670
2705
  prec.left(12, prec.dynamic(12, seq($.qual_Op, $.a_expr))),
2671
2706
  prec.left(4, prec.dynamic(4, seq($.a_expr, $.kw_and, $.a_expr))),
@@ -2731,13 +2766,13 @@ module.exports = grammar({
2731
2766
  prec.left(15, prec.dynamic(15, seq($.b_expr_prec, '^', $.b_expr_prec))),
2732
2767
  prec.left(7, prec.dynamic(7, seq($.b_expr_prec, '<', $.b_expr_prec))),
2733
2768
  prec.left(7, prec.dynamic(7, seq($.b_expr_prec, '>', $.b_expr_prec))),
2734
- prec.left(7, prec.dynamic(7, seq($.b_expr_prec, '=', $.b_expr_prec)))
2769
+ prec.left(7, prec.dynamic(7, seq($.b_expr_prec, '=', $.b_expr_prec))),
2770
+ prec.left(7, prec.dynamic(7, seq($.b_expr_prec, '<=', $.b_expr_prec))),
2771
+ prec.left(7, prec.dynamic(7, seq($.b_expr_prec, '>=', $.b_expr_prec))),
2772
+ prec.left(7, prec.dynamic(7, seq($.b_expr_prec, '<>', $.b_expr_prec)))
2735
2773
  ),
2736
2774
  b_expr: $ => choice(
2737
2775
  alias($.b_expr_prec, $.b_expr),
2738
- prec.left(7, prec.dynamic(7, seq($.b_expr, '<=', $.b_expr))),
2739
- prec.left(7, prec.dynamic(7, seq($.b_expr, '>=', $.b_expr))),
2740
- prec.left(7, prec.dynamic(7, seq($.b_expr, '<>', $.b_expr))),
2741
2776
  prec.left(12, prec.dynamic(12, seq($.b_expr, $.qual_Op, $.b_expr))),
2742
2777
  prec.left(12, prec.dynamic(12, seq($.qual_Op, $.b_expr))),
2743
2778
  prec.left(6, prec.dynamic(6, seq($.b_expr, $.kw_is, $.kw_distinct, $.kw_from, $.b_expr))),
@@ -2771,7 +2806,7 @@ module.exports = grammar({
2771
2806
  prec.left(20, prec.dynamic(20, seq($.func_name, '(', '*', ')')))
2772
2807
  ),
2773
2808
  func_expr: $ => choice(
2774
- seq($.func_application, optional($.within_group_clause), optional($.filter_clause), optional($.over_clause)),
2809
+ seq($.func_application, optional($.within_group_clause), optional($.filter_clause), optional($.null_treatment), optional($.over_clause)),
2775
2810
  seq($.json_aggregate_func, optional($.filter_clause), optional($.over_clause)),
2776
2811
  $.func_expr_common_subexpr
2777
2812
  ),
@@ -2822,7 +2857,7 @@ module.exports = grammar({
2822
2857
  prec.left(20, prec.dynamic(20, seq($.kw_xmlelement, '(', $.kw_name, $.ColLabel, ',', $.expr_list, ')'))),
2823
2858
  prec.left(20, prec.dynamic(20, seq($.kw_xmlelement, '(', $.kw_name, $.ColLabel, ',', $.xml_attributes, ',', $.expr_list, ')'))),
2824
2859
  prec.left(20, prec.dynamic(20, seq($.kw_xmlexists, '(', $.c_expr, $.xmlexists_argument, ')'))),
2825
- prec.left(20, prec.dynamic(20, seq($.kw_xmlforest, '(', $.xml_attribute_list, ')'))),
2860
+ prec.left(20, prec.dynamic(20, seq($.kw_xmlforest, '(', $.labeled_expr_list, ')'))),
2826
2861
  prec.left(20, prec.dynamic(20, seq($.kw_xmlparse, '(', $.document_or_content, $.a_expr, optional($.xml_whitespace_option), ')'))),
2827
2862
  prec.left(20, prec.dynamic(20, seq($.kw_xmlpi, '(', $.kw_name, $.ColLabel, ')'))),
2828
2863
  prec.left(20, prec.dynamic(20, seq($.kw_xmlpi, '(', $.kw_name, $.ColLabel, ',', $.a_expr, ')'))),
@@ -2851,12 +2886,12 @@ module.exports = grammar({
2851
2886
  seq(',', $.kw_standalone, $.kw_no),
2852
2887
  prec.left(11, prec.dynamic(11, seq(',', $.kw_standalone, $.kw_no, $.kw_value)))
2853
2888
  ),
2854
- xml_attributes: $ => prec.left(20, prec.dynamic(20, seq($.kw_xmlattributes, '(', $.xml_attribute_list, ')'))),
2855
- xml_attribute_list: $ => choice(
2856
- $.xml_attribute_el,
2857
- seq($.xml_attribute_list, ',', $.xml_attribute_el)
2889
+ xml_attributes: $ => prec.left(20, prec.dynamic(20, seq($.kw_xmlattributes, '(', $.labeled_expr_list, ')'))),
2890
+ labeled_expr_list: $ => choice(
2891
+ $.labeled_expr,
2892
+ seq($.labeled_expr_list, ',', $.labeled_expr)
2858
2893
  ),
2859
- xml_attribute_el: $ => choice(
2894
+ labeled_expr: $ => choice(
2860
2895
  seq($.a_expr, $.kw_as, $.ColLabel),
2861
2896
  $.a_expr
2862
2897
  ),
@@ -2882,8 +2917,14 @@ module.exports = grammar({
2882
2917
  seq($.kw_by, $.kw_ref),
2883
2918
  prec.left(11, prec.dynamic(11, seq($.kw_by, $.kw_value)))
2884
2919
  ),
2920
+ WaitStmt: $ => seq($.kw_wait, $.kw_for, $.kw_lsn, $.Sconst, optional($.opt_wait_with_clause)),
2921
+ opt_wait_with_clause: $ => prec.left(11, prec.dynamic(11, seq($.kw_with, '(', $.utility_option_list, ')'))),
2885
2922
  within_group_clause: $ => prec.left(20, prec.dynamic(20, seq($.kw_within, $.kw_group, '(', $.sort_clause, ')'))),
2886
2923
  filter_clause: $ => prec.left(20, prec.dynamic(20, seq($.kw_filter, '(', $.kw_where, $.a_expr, ')'))),
2924
+ null_treatment: $ => choice(
2925
+ seq($.kw_ignore, $.kw_nulls),
2926
+ seq($.kw_respect, $.kw_nulls)
2927
+ ),
2887
2928
  window_clause: $ => seq($.kw_window, $.window_definition_list),
2888
2929
  window_definition_list: $ => choice(
2889
2930
  $.window_definition,
@@ -3478,6 +3519,7 @@ module.exports = grammar({
3478
3519
  $.kw_lock,
3479
3520
  $.kw_locked,
3480
3521
  $.kw_logged,
3522
+ $.kw_lsn,
3481
3523
  $.kw_mapping,
3482
3524
  $.kw_match,
3483
3525
  $.kw_matched,
@@ -3574,6 +3616,7 @@ module.exports = grammar({
3574
3616
  $.kw_relative,
3575
3617
  $.kw_release,
3576
3618
  $.kw_rename,
3619
+ $.kw_repack,
3577
3620
  $.kw_repeatable,
3578
3621
  $.kw_replace,
3579
3622
  $.kw_replica,
@@ -3689,6 +3732,7 @@ module.exports = grammar({
3689
3732
  $.kw_views,
3690
3733
  $.kw_virtual,
3691
3734
  $.kw_volatile,
3735
+ $.kw_wait,
3692
3736
  $.kw_when,
3693
3737
  $.kw_whitespace,
3694
3738
  $.kw_work,
@@ -3829,6 +3873,7 @@ module.exports = grammar({
3829
3873
  $.kw_hour,
3830
3874
  $.kw_identity,
3831
3875
  $.kw_if,
3876
+ $.kw_ignore,
3832
3877
  $.kw_immediate,
3833
3878
  $.kw_immutable,
3834
3879
  $.kw_implicit,
@@ -3864,6 +3909,7 @@ module.exports = grammar({
3864
3909
  $.kw_lock,
3865
3910
  $.kw_locked,
3866
3911
  $.kw_logged,
3912
+ $.kw_lsn,
3867
3913
  $.kw_mapping,
3868
3914
  $.kw_match,
3869
3915
  $.kw_matched,
@@ -3943,10 +3989,12 @@ module.exports = grammar({
3943
3989
  $.kw_relative,
3944
3990
  $.kw_release,
3945
3991
  $.kw_rename,
3992
+ $.kw_repack,
3946
3993
  $.kw_repeatable,
3947
3994
  $.kw_replace,
3948
3995
  $.kw_replica,
3949
3996
  $.kw_reset,
3997
+ $.kw_respect,
3950
3998
  $.kw_restart,
3951
3999
  $.kw_restrict,
3952
4000
  $.kw_return,
@@ -4033,6 +4081,7 @@ module.exports = grammar({
4033
4081
  $.kw_views,
4034
4082
  $.kw_virtual,
4035
4083
  $.kw_volatile,
4084
+ $.kw_wait,
4036
4085
  $.kw_whitespace,
4037
4086
  $.kw_within,
4038
4087
  $.kw_without,
@@ -4398,6 +4447,7 @@ module.exports = grammar({
4398
4447
  kw_hour: _ => token(prec(1, /[hH][oO][uU][rR]/)),
4399
4448
  kw_identity: _ => token(prec(1, /[iI][dD][eE][nN][tT][iI][tT][yY]/)),
4400
4449
  kw_if: _ => token(prec(1, /[iI][fF]/)),
4450
+ kw_ignore: _ => token(prec(1, /[iI][gG][nN][oO][rR][eE]/)),
4401
4451
  kw_ilike: _ => token(prec(1, /[iI][lL][iI][kK][eE]/)),
4402
4452
  kw_immediate: _ => token(prec(1, /[iI][mM][mM][eE][dD][iI][aA][tT][eE]/)),
4403
4453
  kw_immutable: _ => token(prec(1, /[iI][mM][mM][uU][tT][aA][bB][lL][eE]/)),
@@ -4465,6 +4515,7 @@ module.exports = grammar({
4465
4515
  kw_lock: _ => token(prec(1, /[lL][oO][cC][kK]/)),
4466
4516
  kw_locked: _ => token(prec(1, /[lL][oO][cC][kK][eE][dD]/)),
4467
4517
  kw_logged: _ => token(prec(1, /[lL][oO][gG][gG][eE][dD]/)),
4518
+ kw_lsn: _ => token(prec(1, /[lL][sS][nN]/)),
4468
4519
  kw_mapping: _ => token(prec(1, /[mM][aA][pP][pP][iI][nN][gG]/)),
4469
4520
  kw_match: _ => token(prec(1, /[mM][aA][tT][cC][hH]/)),
4470
4521
  kw_matched: _ => token(prec(1, /[mM][aA][tT][cC][hH][eE][dD]/)),
@@ -4570,10 +4621,12 @@ module.exports = grammar({
4570
4621
  kw_relative: _ => token(prec(1, /[rR][eE][lL][aA][tT][iI][vV][eE]/)),
4571
4622
  kw_release: _ => token(prec(1, /[rR][eE][lL][eE][aA][sS][eE]/)),
4572
4623
  kw_rename: _ => token(prec(1, /[rR][eE][nN][aA][mM][eE]/)),
4624
+ kw_repack: _ => token(prec(1, /[rR][eE][pP][aA][cC][kK]/)),
4573
4625
  kw_repeatable: _ => token(prec(1, /[rR][eE][pP][eE][aA][tT][aA][bB][lL][eE]/)),
4574
4626
  kw_replace: _ => token(prec(1, /[rR][eE][pP][lL][aA][cC][eE]/)),
4575
4627
  kw_replica: _ => token(prec(1, /[rR][eE][pP][lL][iI][cC][aA]/)),
4576
4628
  kw_reset: _ => token(prec(1, /[rR][eE][sS][eE][tT]/)),
4629
+ kw_respect: _ => token(prec(1, /[rR][eE][sS][pP][eE][cC][tT]/)),
4577
4630
  kw_restart: _ => token(prec(1, /[rR][eE][sS][tT][aA][rR][tT]/)),
4578
4631
  kw_restrict: _ => token(prec(1, /[rR][eE][sS][tT][rR][iI][cC][tT]/)),
4579
4632
  kw_return: _ => token(prec(1, /[rR][eE][tT][uU][rR][nN]/)),
@@ -4690,6 +4743,7 @@ module.exports = grammar({
4690
4743
  kw_views: _ => token(prec(1, /[vV][iI][eE][wW][sS]/)),
4691
4744
  kw_virtual: _ => token(prec(1, /[vV][iI][rR][tT][uU][aA][lL]/)),
4692
4745
  kw_volatile: _ => token(prec(1, /[vV][oO][lL][aA][tT][iI][lL][eE]/)),
4746
+ kw_wait: _ => token(prec(1, /[wW][aA][iI][tT]/)),
4693
4747
  kw_when: _ => token(prec(1, /[wW][hH][eE][nN]/)),
4694
4748
  kw_where: _ => token(prec(1, /[wW][hH][eE][rR][eE]/)),
4695
4749
  kw_whitespace: _ => token(prec(1, /[wW][hH][iI][tT][eE][sS][pP][aA][cC][eE]/)),
@@ -4751,7 +4805,7 @@ module.exports = grammar({
4751
4805
  // ── String literals ──────────────────────────────────────────────────────────
4752
4806
 
4753
4807
  // Standard SQL string: 'hello' — doubled single-quote is the escape: 'it''s'
4754
- string_literal: _ => token(/'([^']|'')*'/),
4808
+ string_literal: _ => token(/'([^']|'')*'(([ \t\f\v]|--[^\n\r]*)*[\n\r]([ \t\n\r\f\v]+|--[^\n\r]*[\n\r])*'([^']|'')*')*/),
4755
4809
 
4756
4810
  // Escape string: E'...' (or e'...') — backslash escapes apply, so \' is an
4757
4811
  // escaped quote and does not terminate the string (unlike a standard
@@ -4759,7 +4813,7 @@ module.exports = grammar({
4759
4813
  // lexer prefers this over the bare E identifier by longest match. Content
4760
4814
  // is any non-quote/non-backslash char, a doubled quote, or a backslash
4761
4815
  // escape. ruleutils emits E'...' for any string containing backslashes.
4762
- escape_string_literal: _ => token(/[eE]'([^'\\]|''|\\.)*'/),
4816
+ escape_string_literal: _ => token(/[eE]'([^'\\]|''|\\.)*'(([ \t\f\v]|--[^\n\r]*)*[\n\r]([ \t\n\r\f\v]+|--[^\n\r]*[\n\r])*'([^'\\]|''|\\.)*')*/),
4763
4817
 
4764
4818
  // NOTE: N'...' and U&'...' prefix strings are still parsed as
4765
4819
  // function-call-like forms (identifier + string_literal).
@@ -4772,17 +4826,25 @@ module.exports = grammar({
4772
4826
  // strings in a single file.
4773
4827
 
4774
4828
  // Bit string: B'0101'
4775
- bit_string_literal: _ => token(/[bB]'[01]*'/),
4829
+ bit_string_literal: _ => token(/[bB]'[01]*'(([ \t\f\v]|--[^\n\r]*)*[\n\r]([ \t\n\r\f\v]+|--[^\n\r]*[\n\r])*'[01]*')*/),
4776
4830
 
4777
4831
  // Hex string: X'deadbeef'
4778
- hex_string_literal: _ => token(/[xX]'[0-9a-fA-F]*'/),
4832
+ hex_string_literal: _ => token(/[xX]'[0-9a-fA-F]*'(([ \t\f\v]|--[^\n\r]*)*[\n\r]([ \t\n\r\f\v]+|--[^\n\r]*[\n\r])*'[0-9a-fA-F]*')*/),
4779
4833
 
4780
4834
  // ── Operators ────────────────────────────────────────────────────────────────
4781
4835
 
4782
4836
  // Custom and built-in multi-character operators.
4783
- // The specific compound operators (::, .., :=, =>, <=, >=, <>) are matched
4784
- // as string literals in the grammar rules and take priority.
4785
- operator: _ => token(/[~!@#^&|?+\-*/%<>=]+/),
4837
+ // The specific compound operators (::, .., :=, =>, <=, >=, <>) are
4838
+ // matched as string literals in the grammar rules and take priority.
4839
+ // Implements scan.l's trailing +/- rule: an operator may only end in
4840
+ // + or - if it also contains one of ~ ! @ # ^ & | ? — otherwise the
4841
+ // trailing +/- lexes as a separate token, so "a<-1" is "a < -1". Bare
4842
+ // + and - are intentionally not matched; the grammar uses them as
4843
+ // literals.
4844
+ operator: _ => token(choice(
4845
+ /[~!@#^&|?+\-*/%<>=]*[~!@#^&|?][~!@#^&|?+\-*/%<>=]*/,
4846
+ /[+\-*/%<>=]*[*/%<>=]/
4847
+ )),
4786
4848
 
4787
4849
  // ── Comments ─────────────────────────────────────────────────────────────────
4788
4850