1use itertools::Itertools;
2use sqruff_lib_core::dialects::Dialect;
3use sqruff_lib_core::dialects::init::DialectKind;
4use sqruff_lib_core::dialects::syntax::SyntaxKind;
5use sqruff_lib_core::helpers::{Config, ToMatchable};
6use sqruff_lib_core::parser::grammar::anyof::{
7 AnyNumberOf, any_set_of, one_of, optionally_bracketed,
8};
9use sqruff_lib_core::parser::grammar::delimited::Delimited;
10use sqruff_lib_core::parser::grammar::sequence::{Bracketed, Sequence};
11use sqruff_lib_core::parser::grammar::{Anything, Ref};
12use sqruff_lib_core::parser::lexer::Matcher;
13use sqruff_lib_core::parser::matchable::{Matchable, MatchableTrait};
14use sqruff_lib_core::parser::node_matcher::NodeMatcher;
15use sqruff_lib_core::parser::parsers::{RegexParser, StringParser, TypedParser};
16use sqruff_lib_core::parser::segments::generator::SegmentGenerator;
17use sqruff_lib_core::parser::segments::meta::MetaSegment;
18use sqruff_lib_core::parser::types::ParseMode;
19
20use super::ansi;
21use super::postgres_keywords::POSTGRES_POSTGIS_DATATYPE_KEYWORDS;
22use crate::postgres_keywords::{get_keywords, postgres_keywords};
23
24pub fn dialect() -> Dialect {
25 raw_dialect().config(|dialect| dialect.expand())
26}
27
28pub fn raw_dialect() -> Dialect {
29 let mut postgres = ansi::raw_dialect();
30 postgres.name = DialectKind::Postgres;
31
32 postgres.insert_lexer_matchers(
33 vec![Matcher::string("right_arrow", "=>", SyntaxKind::RightArrow)],
34 "equals",
35 );
36
37 postgres.insert_lexer_matchers(vec![
38 Matcher::legacy(
39 "unicode_single_quote",
40 |s| s.starts_with("U&'"),
41 r"(?s)U&(('')+?(?!')|('.*?(?<!')(?:'')*'(?!')))(\s*UESCAPE\s*'[^0-9A-Fa-f'+\-\s)]')?",
42 SyntaxKind::UnicodeSingleQuote
43 ),
44 Matcher::legacy(
45 "escaped_single_quote",
46 |s| s.starts_with("E'"),
47 r"(?s)E(('')+?(?!')|'.*?((?<!\\)(?:\\\\)*(?<!')(?:'')*|(?<!\\)(?:\\\\)*\\(?<!')(?:'')*')'(?!'))",
48 SyntaxKind::EscapedSingleQuote
49 ),
50 Matcher::regex(
51 "unicode_double_quote",
52 r#"(?s)U&".+?"(\s*UESCAPE\s*\'[^0-9A-Fa-f\'+\-\s)]\')?"#,
53 SyntaxKind::UnicodeDoubleQuote
54 ),
55 Matcher::regex(
56 "json_operator",
57 r#"->>|#>>|->|#>|@>|<@|\?\|_|\?|\?&|#-"#,
58 SyntaxKind::JsonOperator
59 ),
60 Matcher::string(
61 "at",
62 "@",
63 SyntaxKind::At
64 ),
65 Matcher::regex(
66 "bit_string_literal",
67 r#"[bBxX]'[0-9a-fA-F]*'"#,
68 SyntaxKind::BitStringLiteral
69 ),
70 ], "like_operator");
71
72 postgres.insert_lexer_matchers(
73 vec![
74 Matcher::legacy(
75 "meta_command",
76 |s| s.starts_with("\\"),
77 r"\\([^\\\r\n])+((\\\\)|(?=\n)|(?=\r\n))?",
78 SyntaxKind::Comment,
79 ),
80 Matcher::regex(
81 "dollar_numeric_literal",
82 r"\$\d+",
83 SyntaxKind::DollarNumericLiteral,
84 ),
85 ],
86 "word",
87 );
88
89 postgres.patch_lexer_matchers(vec![
90 Matcher::regex("inline_comment", r"(--)[^\n]*", SyntaxKind::InlineComment),
91 Matcher::legacy(
92 "single_quote",
93 |s| s.starts_with("'"),
94 r"(?s)('')+?(?!')|('.*?(?<!')(?:'')*'(?!'))",
95 SyntaxKind::SingleQuote,
96 ),
97 Matcher::regex("double_quote", r#"(?s)".+?""#, SyntaxKind::DoubleQuote),
98 Matcher::regex("word", r"[a-zA-Z_][0-9a-zA-Z_$]*", SyntaxKind::Word),
99 ]);
100
101 let keywords = postgres_keywords();
102 let not_keywords = get_keywords(&keywords, "not-keyword");
103
104 postgres
105 .sets_mut("reserved_keywords")
106 .extend(get_keywords(&keywords, "reserved"));
107 postgres
108 .sets_mut("unreserved_keywords")
109 .extend(get_keywords(&keywords, "non-reserved"));
110
111 postgres
112 .sets_mut("reserved_keywords")
113 .retain(|keyword| !not_keywords.contains(keyword));
114 postgres
115 .sets_mut("unreserved_keywords")
116 .retain(|keyword| !not_keywords.contains(keyword));
117
118 postgres.sets_mut("datetime_units").extend([
120 "CENTURY",
121 "DECADE",
122 "DOW",
123 "DOY",
124 "EPOCH",
125 "ISODOW",
126 "ISOYEAR",
127 "MICROSECONDS",
128 "MILLENNIUM",
129 "MILLISECONDS",
130 "TIMEZONE",
131 "TIMEZONE_HOUR",
132 "TIMEZONE_MINUTE",
133 ]);
134
135 postgres.sets_mut("bare_functions").extend([
137 "CURRENT_TIMESTAMP",
138 "CURRENT_TIME",
139 "CURRENT_DATE",
140 "LOCALTIME",
141 "LOCALTIMESTAMP",
142 ]);
143
144 postgres.sets_mut("date_part_function_name").clear();
148
149 postgres
151 .sets_mut("value_table_functions")
152 .extend(["UNNEST", "GENERATE_SERIES"]);
153
154 postgres.add([
155 (
156 "JsonOperatorSegment".into(),
157 TypedParser::new(SyntaxKind::JsonOperator, SyntaxKind::BinaryOperator)
158 .to_matchable()
159 .into(),
160 ),
161 (
162 "SimpleGeometryGrammar".into(),
163 AnyNumberOf::new(vec![Ref::new("NumericLiteralSegment").to_matchable()])
164 .to_matchable()
165 .into(),
166 ),
167 (
168 "MultilineConcatenateNewline".into(),
169 TypedParser::new(SyntaxKind::Newline, SyntaxKind::Newline)
170 .to_matchable()
171 .into(),
172 ),
173 (
174 "MultilineConcatenateDelimiterGrammar".into(),
175 AnyNumberOf::new(vec![Ref::new("MultilineConcatenateNewline").to_matchable()])
176 .config(|this| {
177 this.min_times(1);
178 this.disallow_gaps();
179 })
180 .to_matchable()
181 .into(),
182 ),
183 (
184 "NakedIdentifierFullSegment".into(),
185 TypedParser::new(SyntaxKind::Word, SyntaxKind::NakedIdentifier)
186 .to_matchable()
187 .into(),
188 ),
189 (
190 "PropertiesNakedIdentifierSegment".into(),
191 TypedParser::new(SyntaxKind::Word, SyntaxKind::PropertiesNakedIdentifier)
192 .to_matchable()
193 .into(),
194 ),
195 (
196 "SingleIdentifierFullGrammar".into(),
197 one_of(vec![
198 Ref::new("NakedIdentifierSegment").to_matchable(),
199 Ref::new("QuotedIdentifierSegment").to_matchable(),
200 Ref::new("NakedIdentifierFullSegment").to_matchable(),
201 ])
202 .to_matchable()
203 .into(),
204 ),
205 (
206 "DefinitionArgumentValueGrammar".into(),
207 one_of(vec![
208 Ref::new("LiteralGrammar").to_matchable(),
209 Ref::new("PropertiesNakedIdentifierSegment").to_matchable(),
210 ])
211 .to_matchable()
212 .into(),
213 ),
214 (
215 "CascadeRestrictGrammar".into(),
216 one_of(vec![
217 Ref::keyword("CASCADE").to_matchable(),
218 Ref::keyword("RESTRICT").to_matchable(),
219 ])
220 .to_matchable()
221 .into(),
222 ),
223 (
224 "ExtendedTableReferenceGrammar".into(),
225 one_of(vec![
226 Ref::new("TableReferenceSegment").to_matchable(),
227 Sequence::new(vec![
228 Ref::keyword("ONLY").to_matchable(),
229 optionally_bracketed(vec![Ref::new("TableReferenceSegment").to_matchable()])
230 .to_matchable(),
231 ])
232 .to_matchable(),
233 Sequence::new(vec![
234 Ref::new("TableReferenceSegment").to_matchable(),
235 Ref::new("StarSegment").to_matchable(),
236 ])
237 .to_matchable(),
238 ])
239 .to_matchable()
240 .into(),
241 ),
242 (
243 "RightArrowSegment".into(),
244 StringParser::new("=>", SyntaxKind::RightArrow)
245 .to_matchable()
246 .into(),
247 ),
248 (
249 "OnKeywordAsIdentifierSegment".into(),
250 StringParser::new("ON", SyntaxKind::NakedIdentifier)
251 .to_matchable()
252 .into(),
253 ),
254 (
255 "DollarNumericLiteralSegment".into(),
256 TypedParser::new(
257 SyntaxKind::DollarNumericLiteral,
258 SyntaxKind::DollarNumericLiteral,
259 )
260 .to_matchable()
261 .into(),
262 ),
263 (
264 "ForeignDataWrapperGrammar".into(),
265 Sequence::new(vec![
266 Ref::keyword("FOREIGN").to_matchable(),
267 Ref::keyword("DATA").to_matchable(),
268 Ref::keyword("WRAPPER").to_matchable(),
269 ])
270 .to_matchable()
271 .into(),
272 ),
273 (
274 "OptionsListGrammar".into(),
275 Sequence::new(vec![
276 Delimited::new(vec![
277 Ref::new("NakedIdentifierFullSegment").to_matchable(),
278 Ref::new("QuotedLiteralSegment").to_matchable(),
279 ])
280 .to_matchable(),
281 ])
282 .to_matchable()
283 .into(),
284 ),
285 (
286 "OptionsGrammar".into(),
287 Sequence::new(vec![
288 Ref::keyword("OPTIONS").to_matchable(),
289 Bracketed::new(vec![
290 AnyNumberOf::new(vec![Ref::new("OptionsListGrammar").to_matchable()])
291 .to_matchable(),
292 ])
293 .to_matchable(),
294 ])
295 .to_matchable()
296 .into(),
297 ),
298 (
299 "CreateUserMappingGrammar".into(),
300 Sequence::new(vec![
301 Ref::keyword("CREATE").to_matchable(),
302 Ref::keyword("USER").to_matchable(),
303 Ref::keyword("MAPPING").to_matchable(),
304 ])
305 .to_matchable()
306 .into(),
307 ),
308 (
309 "SessionInformationUserFunctionsGrammar".into(),
310 one_of(vec![
311 Ref::keyword("USER").to_matchable(),
312 Ref::keyword("CURRENT_ROLE").to_matchable(),
313 Ref::keyword("CURRENT_USER").to_matchable(),
314 Ref::keyword("SESSION_USER").to_matchable(),
315 ])
316 .to_matchable()
317 .into(),
318 ),
319 (
320 "ImportForeignSchemaGrammar".into(),
321 Sequence::new(vec![
322 Ref::keyword("IMPORT").to_matchable(),
323 Ref::keyword("FOREIGN").to_matchable(),
324 Ref::keyword("SCHEMA").to_matchable(),
325 ])
326 .to_matchable()
327 .into(),
328 ),
329 ]);
330
331 postgres.add([
332 (
333 "LikeGrammar".into(),
334 one_of(vec![
335 Ref::keyword("LIKE").to_matchable(),
336 Ref::keyword("ILIKE").to_matchable(),
337 Sequence::new(vec![
338 Ref::keyword("SIMILAR").to_matchable(),
339 Ref::keyword("TO").to_matchable(),
340 ])
341 .to_matchable(),
342 ])
343 .to_matchable()
344 .into(),
345 ),
346 (
347 "StringBinaryOperatorGrammar".into(),
348 one_of(vec![
349 Ref::new("ConcatSegment").to_matchable(),
350 Ref::keyword("COLLATE").to_matchable(),
351 ])
352 .to_matchable()
353 .into(),
354 ),
355 (
356 "ComparisonOperatorGrammar".into(),
357 one_of(vec![
358 Ref::new("EqualsSegment").to_matchable(),
359 Ref::new("GreaterThanSegment").to_matchable(),
360 Ref::new("LessThanSegment").to_matchable(),
361 Ref::new("GreaterThanOrEqualToSegment").to_matchable(),
362 Ref::new("LessThanOrEqualToSegment").to_matchable(),
363 Ref::new("NotEqualToSegment").to_matchable(),
364 Ref::new("LikeOperatorSegment").to_matchable(),
365 Sequence::new(vec![
366 Ref::keyword("IS").to_matchable(),
367 Ref::keyword("DISTINCT").to_matchable(),
368 Ref::keyword("FROM").to_matchable(),
369 ])
370 .to_matchable(),
371 Sequence::new(vec![
372 Ref::keyword("IS").to_matchable(),
373 Ref::keyword("NOT").to_matchable(),
374 Ref::keyword("DISTINCT").to_matchable(),
375 Ref::keyword("FROM").to_matchable(),
376 ])
377 .to_matchable(),
378 Ref::new("OverlapSegment").to_matchable(),
379 Ref::new("NotExtendRightSegment").to_matchable(),
380 Ref::new("NotExtendLeftSegment").to_matchable(),
381 Ref::new("AdjacentSegment").to_matchable(),
382 ])
383 .to_matchable()
384 .into(),
385 ),
386 (
387 "NakedIdentifierSegment".into(),
388 SegmentGenerator::new(|dialect| {
389 let reserved_keywords = dialect.sets("reserved_keywords");
391 let pattern = reserved_keywords.iter().join("|");
392 let anti_template = format!("^({pattern})$");
393
394 RegexParser::new(
395 r"([A-Z_]+|[0-9]+[A-Z_$])[A-Z0-9_$]*",
396 SyntaxKind::NakedIdentifier,
397 )
398 .anti_template(&anti_template)
399 .to_matchable()
400 })
401 .into(),
402 ),
403 (
404 "ParameterNameSegment".into(),
405 RegexParser::new(r#"[A-Z_][A-Z0-9_$]*|\"[^\"]*\""#, SyntaxKind::Parameter)
406 .to_matchable()
407 .into(),
408 ),
409 (
410 "FunctionNameIdentifierSegment".into(),
411 RegexParser::new(r"[A-Z_][A-Z0-9_$]*", SyntaxKind::FunctionNameIdentifier)
412 .to_matchable()
413 .into(),
414 ),
415 (
416 "FunctionContentsExpressionGrammar".into(),
417 one_of(vec![
418 Ref::new("ExpressionSegment").to_matchable(),
419 Ref::new("NamedArgumentSegment").to_matchable(),
420 ])
421 .to_matchable()
422 .into(),
423 ),
424 (
425 "QuotedLiteralSegment".into(),
426 one_of(vec![
427 Sequence::new(vec![
428 TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::QuotedLiteral)
429 .to_matchable(),
430 AnyNumberOf::new(vec![
431 Ref::new("MultilineConcatenateDelimiterGrammar").to_matchable(),
432 TypedParser::new(SyntaxKind::SingleQuote, SyntaxKind::QuotedLiteral)
433 .to_matchable(),
434 ])
435 .to_matchable(),
436 ])
437 .to_matchable(),
438 Sequence::new(vec![
439 TypedParser::new(SyntaxKind::BitStringLiteral, SyntaxKind::QuotedLiteral)
440 .to_matchable(),
441 AnyNumberOf::new(vec![
442 Ref::new("MultilineConcatenateDelimiterGrammar").to_matchable(),
443 TypedParser::new(SyntaxKind::BitStringLiteral, SyntaxKind::QuotedLiteral)
444 .to_matchable(),
445 ])
446 .to_matchable(),
447 ])
448 .to_matchable(),
449 Delimited::new(vec![
450 TypedParser::new(SyntaxKind::UnicodeSingleQuote, SyntaxKind::QuotedLiteral)
451 .to_matchable(),
452 AnyNumberOf::new(vec![
453 Ref::new("MultilineConcatenateDelimiterGrammar").to_matchable(),
454 TypedParser::new(SyntaxKind::UnicodeSingleQuote, SyntaxKind::QuotedLiteral)
455 .to_matchable(),
456 ])
457 .to_matchable(),
458 ])
459 .to_matchable(),
460 Delimited::new(vec![
461 TypedParser::new(SyntaxKind::EscapedSingleQuote, SyntaxKind::QuotedLiteral)
462 .to_matchable(),
463 AnyNumberOf::new(vec![
464 Ref::new("MultilineConcatenateDelimiterGrammar").to_matchable(),
465 TypedParser::new(SyntaxKind::EscapedSingleQuote, SyntaxKind::QuotedLiteral)
466 .to_matchable(),
467 ])
468 .to_matchable(),
469 ])
470 .to_matchable(),
471 Delimited::new(vec![
472 TypedParser::new(SyntaxKind::DollarQuote, SyntaxKind::QuotedLiteral)
473 .to_matchable(),
474 AnyNumberOf::new(vec![
475 Ref::new("MultilineConcatenateDelimiterGrammar").to_matchable(),
476 TypedParser::new(SyntaxKind::DollarQuote, SyntaxKind::QuotedLiteral)
477 .to_matchable(),
478 ])
479 .to_matchable(),
480 ])
481 .to_matchable(),
482 ])
483 .to_matchable()
484 .into(),
485 ),
486 (
487 "QuotedIdentifierSegment".into(),
488 one_of(vec![
489 TypedParser::new(SyntaxKind::DoubleQuote, SyntaxKind::QuotedIdentifier)
490 .to_matchable(),
491 TypedParser::new(SyntaxKind::UnicodeDoubleQuote, SyntaxKind::QuotedLiteral)
492 .to_matchable(),
493 ])
494 .to_matchable()
495 .into(),
496 ),
497 (
498 "PostFunctionGrammar".into(),
499 AnyNumberOf::new(vec![
500 Ref::new("WithinGroupClauseSegment").to_matchable(),
501 Ref::new("OverClauseSegment").to_matchable(),
502 Ref::new("FilterClauseGrammar").to_matchable(),
503 ])
504 .to_matchable()
505 .into(),
506 ),
507 (
508 "BinaryOperatorGrammar".into(),
509 one_of(vec![
510 Ref::new("ArithmeticBinaryOperatorGrammar").to_matchable(),
511 Ref::new("StringBinaryOperatorGrammar").to_matchable(),
512 Ref::new("BooleanBinaryOperatorGrammar").to_matchable(),
513 Ref::new("ComparisonOperatorGrammar").to_matchable(),
514 Ref::new("JsonOperatorSegment").to_matchable(),
515 ])
516 .to_matchable()
517 .into(),
518 ),
519 (
520 "FunctionParameterGrammar".into(),
521 Sequence::new(vec![
522 one_of(vec![
523 Ref::keyword("IN").to_matchable(),
524 Ref::keyword("OUT").to_matchable(),
525 Ref::keyword("INOUT").to_matchable(),
526 Ref::keyword("VARIADIC").to_matchable(),
527 ])
528 .config(|this| this.optional())
529 .to_matchable(),
530 one_of(vec![
531 Ref::new("DatatypeSegment").to_matchable(),
532 Sequence::new(vec![
533 Ref::new("ParameterNameSegment").to_matchable(),
534 Ref::new("DatatypeSegment").to_matchable(),
535 ])
536 .to_matchable(),
537 ])
538 .to_matchable(),
539 Sequence::new(vec![
540 one_of(vec![
541 Ref::keyword("DEFAULT").to_matchable(),
542 Ref::new("EqualsSegment").to_matchable(),
543 ])
544 .to_matchable(),
545 Ref::new("ExpressionSegment").to_matchable(),
546 ])
547 .config(|this| this.optional())
548 .to_matchable(),
549 ])
550 .to_matchable()
551 .into(),
552 ),
553 (
554 "FrameClauseUnitGrammar".into(),
555 one_of(vec![
556 Ref::keyword("RANGE").to_matchable(),
557 Ref::keyword("ROWS").to_matchable(),
558 Ref::keyword("GROUPS").to_matchable(),
559 ])
560 .to_matchable()
561 .into(),
562 ),
563 (
564 "IsNullGrammar".into(),
565 Ref::keyword("ISNULL").to_matchable().into(),
566 ),
567 (
568 "NotNullGrammar".into(),
569 Ref::keyword("NOTNULL").to_matchable().into(),
570 ),
571 (
572 "JoinKeywordsGrammar".into(),
573 Sequence::new(vec![
574 Ref::keyword("JOIN").to_matchable(),
575 Sequence::new(vec![Ref::keyword("LATERAL").to_matchable()])
576 .config(|this| this.optional())
577 .to_matchable(),
578 ])
579 .to_matchable()
580 .into(),
581 ),
582 (
583 "SelectClauseTerminatorGrammar".into(),
584 one_of(vec![
585 Ref::keyword("INTO").to_matchable(),
586 Ref::keyword("FROM").to_matchable(),
587 Ref::keyword("WHERE").to_matchable(),
588 Sequence::new(vec![
589 Ref::keyword("ORDER").to_matchable(),
590 Ref::keyword("BY").to_matchable(),
591 ])
592 .to_matchable(),
593 Ref::keyword("LIMIT").to_matchable(),
594 Ref::new("CommaSegment").to_matchable(),
595 Ref::new("SetOperatorSegment").to_matchable(),
596 ])
597 .to_matchable()
598 .into(),
599 ),
600 (
603 "LiteralGrammar".into(),
604 postgres
605 .grammar("LiteralGrammar")
606 .copy(
607 Some(vec![
608 Ref::new("DollarNumericLiteralSegment").to_matchable(),
609 Ref::new("PsqlVariableGrammar").to_matchable(),
610 ]),
611 None,
612 Some(Ref::new("ArrayLiteralSegment").to_matchable()),
613 None,
614 Vec::new(),
615 false,
616 )
617 .into(),
618 ),
619 (
620 "FromClauseTerminatorGrammar".into(),
621 postgres
622 .grammar("FromClauseTerminatorGrammar")
623 .copy(
624 Some(vec![Ref::new("ForClauseSegment").to_matchable()]),
625 None,
626 None,
627 None,
628 Vec::new(),
629 false,
630 )
631 .into(),
632 ),
633 (
634 "WhereClauseTerminatorGrammar".into(),
635 one_of(vec![
636 Ref::keyword("LIMIT").to_matchable(),
637 Sequence::new(vec![
638 Ref::keyword("GROUP").to_matchable(),
639 Ref::keyword("BY").to_matchable(),
640 ])
641 .to_matchable(),
642 Sequence::new(vec![
643 Ref::keyword("ORDER").to_matchable(),
644 Ref::keyword("BY").to_matchable(),
645 ])
646 .to_matchable(),
647 Ref::keyword("HAVING").to_matchable(),
648 Ref::keyword("QUALIFY").to_matchable(),
649 Ref::keyword("WINDOW").to_matchable(),
650 Ref::keyword("OVERLAPS").to_matchable(),
651 Ref::keyword("RETURNING").to_matchable(),
652 Sequence::new(vec![
653 Ref::keyword("ON").to_matchable(),
654 Ref::keyword("CONFLICT").to_matchable(),
655 ])
656 .to_matchable(),
657 Ref::new("ForClauseSegment").to_matchable(),
658 ])
659 .to_matchable()
660 .into(),
661 ),
662 (
663 "OrderByClauseTerminators".into(),
664 one_of(vec![
665 Ref::keyword("LIMIT").to_matchable(),
666 Ref::keyword("HAVING").to_matchable(),
667 Ref::keyword("QUALIFY").to_matchable(),
668 Ref::keyword("WINDOW").to_matchable(),
669 Ref::new("FrameClauseUnitGrammar").to_matchable(),
670 Ref::keyword("SEPARATOR").to_matchable(),
671 Sequence::new(vec![
672 Ref::keyword("WITH").to_matchable(),
673 Ref::keyword("DATA").to_matchable(),
674 ])
675 .to_matchable(),
676 Ref::new("ForClauseSegment").to_matchable(),
677 ])
678 .to_matchable()
679 .into(),
680 ),
681 (
682 "AccessorGrammar".into(),
683 AnyNumberOf::new(vec![
684 Ref::new("ArrayAccessorSegment").to_matchable(),
685 Ref::new("SemiStructuredAccessorSegment").to_matchable(),
686 ])
687 .to_matchable()
688 .into(),
689 ),
690 (
691 "NonWithSelectableGrammar".into(),
692 one_of(vec![
693 Ref::new("SetExpressionSegment").to_matchable(),
694 optionally_bracketed(vec![Ref::new("SelectStatementSegment").to_matchable()])
695 .to_matchable(),
696 Ref::new("NonSetSelectableGrammar").to_matchable(),
697 Ref::new("UpdateStatementSegment").to_matchable(),
698 Ref::new("InsertStatementSegment").to_matchable(),
699 Ref::new("DeleteStatementSegment").to_matchable(),
700 ])
701 .to_matchable()
702 .into(),
703 ),
704 (
705 "NonWithNonSelectableGrammar".into(),
706 one_of(vec![]).to_matchable().into(),
707 ),
708 ]);
709
710 postgres.add([
711 (
712 "OverlapSegment".into(),
713 NodeMatcher::new(SyntaxKind::ComparisonOperator, |_| {
714 Sequence::new(vec![
715 Ref::new("AmpersandSegment").to_matchable(),
716 Ref::new("AmpersandSegment").to_matchable(),
717 ])
718 .to_matchable()
719 })
720 .to_matchable()
721 .into(),
722 ),
723 (
724 "NotExtendRightSegment".into(),
725 NodeMatcher::new(SyntaxKind::ComparisonOperator, |_| {
726 Sequence::new(vec![
727 Ref::new("AmpersandSegment").to_matchable(),
728 Ref::new("RawGreaterThanSegment").to_matchable(),
729 ])
730 .allow_gaps(false)
731 .to_matchable()
732 })
733 .to_matchable()
734 .into(),
735 ),
736 (
737 "NotExtendLeftSegment".into(),
738 NodeMatcher::new(SyntaxKind::ComparisonOperator, |_| {
739 Sequence::new(vec![
740 Ref::new("AmpersandSegment").to_matchable(),
741 Ref::new("RawLessThanSegment").to_matchable(),
742 ])
743 .allow_gaps(false)
744 .to_matchable()
745 })
746 .to_matchable()
747 .into(),
748 ),
749 (
750 "AdjacentSegment".into(),
751 NodeMatcher::new(SyntaxKind::ComparisonOperator, |_| {
752 Sequence::new(vec![
753 Ref::new("MinusSegment").to_matchable(),
754 Ref::new("PipeSegment").to_matchable(),
755 Ref::new("MinusSegment").to_matchable(),
756 ])
757 .allow_gaps(false)
758 .to_matchable()
759 })
760 .to_matchable()
761 .into(),
762 ),
763 ]);
764
765 postgres.add([(
766 "PsqlVariableGrammar".into(),
767 NodeMatcher::new(SyntaxKind::PsqlVariable, |_| {
768 Sequence::new(vec![
769 optionally_bracketed(vec![
770 Ref::new("ColonSegment").to_matchable(),
771 one_of(vec![
772 Ref::new("ParameterNameSegment").to_matchable(),
773 Ref::new("QuotedLiteralSegment").to_matchable(),
774 ])
775 .to_matchable(),
776 ])
777 .to_matchable(),
778 ])
779 .to_matchable()
780 })
781 .to_matchable()
782 .into(),
783 )]);
784
785 postgres.replace_grammar(
786 "ArrayAccessorSegment",
787 Bracketed::new(vec![
788 one_of(vec![
789 Ref::new("QualifiedNumericLiteralSegment").to_matchable(),
791 Ref::new("NumericLiteralSegment").to_matchable(),
792 Ref::new("ExpressionSegment").to_matchable(),
793 Sequence::new(vec![
795 one_of(vec![
796 Ref::new("QualifiedNumericLiteralSegment").to_matchable(),
797 Ref::new("NumericLiteralSegment").to_matchable(),
798 Ref::new("ExpressionSegment").to_matchable(),
799 ])
800 .config(|this| this.optional())
801 .to_matchable(),
802 Ref::new("SliceSegment").to_matchable(),
803 one_of(vec![
804 Ref::new("QualifiedNumericLiteralSegment").to_matchable(),
805 Ref::new("NumericLiteralSegment").to_matchable(),
806 Ref::new("ExpressionSegment").to_matchable(),
807 ])
808 .config(|this| this.optional())
809 .to_matchable(),
810 ])
811 .to_matchable(),
812 ])
813 .to_matchable(),
814 ])
815 .config(|this| {
816 this.bracket_type("square");
817 })
818 .to_matchable(),
819 );
820
821 postgres.add([(
822 "DateTimeTypeIdentifier".into(),
823 NodeMatcher::new(SyntaxKind::DatetimeTypeIdentifier, |_| {
824 one_of(vec![
825 Ref::keyword("DATE").to_matchable(),
826 Sequence::new(vec![
827 one_of(vec![
828 Ref::keyword("TIME").to_matchable(),
829 Ref::keyword("TIMESTAMP").to_matchable(),
830 ])
831 .to_matchable(),
832 Bracketed::new(vec![Ref::new("NumericLiteralSegment").to_matchable()])
833 .config(|this| this.optional())
834 .to_matchable(),
835 Sequence::new(vec![
836 one_of(vec![
837 Ref::keyword("WITH").to_matchable(),
838 Ref::keyword("WITHOUT").to_matchable(),
839 ])
840 .to_matchable(),
841 Ref::keyword("TIME").to_matchable(),
842 Ref::keyword("ZONE").to_matchable(),
843 ])
844 .config(|this| this.optional())
845 .to_matchable(),
846 ])
847 .to_matchable(),
848 Sequence::new(vec![
849 one_of(vec![
850 Ref::keyword("INTERVAL").to_matchable(),
851 Ref::keyword("TIMETZ").to_matchable(),
852 Ref::keyword("TIMESTAMPTZ").to_matchable(),
853 ])
854 .to_matchable(),
855 Bracketed::new(vec![Ref::new("NumericLiteralSegment").to_matchable()])
856 .config(|this| this.optional())
857 .to_matchable(),
858 ])
859 .to_matchable(),
860 ])
861 .to_matchable()
862 })
863 .to_matchable()
864 .into(),
865 )]);
866
867 postgres.add([(
868 "DateTimeLiteralGrammar".into(),
869 NodeMatcher::new(SyntaxKind::DatetimeLiteral, |_| {
870 Sequence::new(vec![
871 Ref::new("DateTimeTypeIdentifier").optional().to_matchable(),
872 Ref::new("QuotedLiteralSegment").to_matchable(),
873 ])
874 .to_matchable()
875 })
876 .to_matchable()
877 .into(),
878 )]);
879
880 postgres.replace_grammar(
881 "DatatypeSegment",
882 Sequence::new(vec![
883 Sequence::new(vec![
884 Ref::new("SingleIdentifierGrammar").to_matchable(),
885 Ref::new("DotSegment").to_matchable(),
886 ])
887 .config(|this| {
888 this.allow_gaps = false;
889 this.optional();
890 })
891 .to_matchable(),
892 one_of(vec![
893 Ref::new("WellKnownTextGeometrySegment").to_matchable(),
894 Ref::new("DateTimeTypeIdentifier").to_matchable(),
895 Sequence::new(vec![
896 one_of(vec![
897 Ref::keyword("SMALLINT").to_matchable(),
898 Ref::keyword("INTEGER").to_matchable(),
899 Ref::keyword("INT").to_matchable(),
900 Ref::keyword("INT2").to_matchable(),
901 Ref::keyword("INT4").to_matchable(),
902 Ref::keyword("INT8").to_matchable(),
903 Ref::keyword("BIGINT").to_matchable(),
904 Ref::keyword("FLOAT4").to_matchable(),
905 Ref::keyword("FLOAT8").to_matchable(),
906 Ref::keyword("REAL").to_matchable(),
907 Sequence::new(vec![
908 Ref::keyword("DOUBLE").to_matchable(),
909 Ref::keyword("PRECISION").to_matchable(),
910 ])
911 .to_matchable(),
912 Ref::keyword("SMALLSERIAL").to_matchable(),
913 Ref::keyword("SERIAL").to_matchable(),
914 Ref::keyword("SERIAL2").to_matchable(),
915 Ref::keyword("SERIAL4").to_matchable(),
916 Ref::keyword("SERIAL8").to_matchable(),
917 Ref::keyword("BIGSERIAL").to_matchable(),
918 Sequence::new(vec![
920 one_of(vec![Ref::keyword("FLOAT").to_matchable()]).to_matchable(),
921 Ref::new("BracketedArguments").optional().to_matchable(),
922 ])
923 .to_matchable(),
924 Sequence::new(vec![
926 one_of(vec![
927 Ref::keyword("DECIMAL").to_matchable(),
928 Ref::keyword("NUMERIC").to_matchable(),
929 ])
930 .to_matchable(),
931 Ref::new("BracketedArguments").optional().to_matchable(),
932 ])
933 .to_matchable(),
934 Ref::keyword("MONEY").to_matchable(),
936 one_of(vec![
938 Sequence::new(vec![
939 one_of(vec![
940 Ref::keyword("BPCHAR").to_matchable(),
941 Ref::keyword("CHAR").to_matchable(),
942 Sequence::new(vec![
943 Ref::keyword("CHAR").to_matchable(),
944 Ref::keyword("VARYING").to_matchable(),
945 ])
946 .to_matchable(),
947 Ref::keyword("CHARACTER").to_matchable(),
948 Sequence::new(vec![
949 Ref::keyword("CHARACTER").to_matchable(),
950 Ref::keyword("VARYING").to_matchable(),
951 ])
952 .to_matchable(),
953 Ref::keyword("VARCHAR").to_matchable(),
954 ])
955 .to_matchable(),
956 Ref::new("BracketedArguments").optional().to_matchable(),
957 ])
958 .to_matchable(),
959 Ref::keyword("TEXT").to_matchable(),
960 ])
961 .to_matchable(),
962 Ref::keyword("BYTEA").to_matchable(),
964 one_of(vec![
966 Ref::keyword("BOOLEAN").to_matchable(),
967 Ref::keyword("BOOL").to_matchable(),
968 ])
969 .to_matchable(),
970 one_of(vec![
972 Ref::keyword("POINT").to_matchable(),
973 Ref::keyword("LINE").to_matchable(),
974 Ref::keyword("LSEG").to_matchable(),
975 Ref::keyword("BOX").to_matchable(),
976 Ref::keyword("PATH").to_matchable(),
977 Ref::keyword("POLYGON").to_matchable(),
978 Ref::keyword("CIRCLE").to_matchable(),
979 ])
980 .to_matchable(),
981 one_of(vec![
983 Ref::keyword("CIDR").to_matchable(),
984 Ref::keyword("INET").to_matchable(),
985 Ref::keyword("MACADDR").to_matchable(),
986 Ref::keyword("MACADDR8").to_matchable(),
987 ])
988 .to_matchable(),
989 one_of(vec![
991 Ref::keyword("TSVECTOR").to_matchable(),
992 Ref::keyword("TSQUERY").to_matchable(),
993 ])
994 .to_matchable(),
995 Sequence::new(vec![
997 Ref::keyword("BIT").to_matchable(),
998 one_of(vec![Ref::keyword("VARYING").to_matchable()])
999 .config(|this| this.optional())
1000 .to_matchable(),
1001 Ref::new("BracketedArguments").optional().to_matchable(),
1002 ])
1003 .to_matchable(),
1004 Ref::keyword("UUID").to_matchable(),
1006 Ref::keyword("XML").to_matchable(),
1008 one_of(vec![
1010 Ref::keyword("JSON").to_matchable(),
1011 Ref::keyword("JSONB").to_matchable(),
1012 ])
1013 .to_matchable(),
1014 Ref::keyword("INT4RANGE").to_matchable(),
1016 Ref::keyword("INT8RANGE").to_matchable(),
1017 Ref::keyword("NUMRANGE").to_matchable(),
1018 Ref::keyword("TSRANGE").to_matchable(),
1019 Ref::keyword("TSTZRANGE").to_matchable(),
1020 Ref::keyword("DATERANGE").to_matchable(),
1021 Ref::keyword("PG_LSN").to_matchable(),
1023 ])
1024 .to_matchable(),
1025 ])
1026 .to_matchable(),
1027 Ref::new("DatatypeIdentifierSegment").to_matchable(),
1028 ])
1029 .to_matchable(),
1030 one_of(vec![
1031 AnyNumberOf::new(vec![
1032 Bracketed::new(vec![
1033 Ref::new("ExpressionSegment").optional().to_matchable(),
1034 ])
1035 .config(|this| this.bracket_type("square"))
1036 .to_matchable(),
1037 ])
1038 .to_matchable(),
1039 Ref::new("ArrayTypeSegment").to_matchable(),
1040 Ref::new("SizedArrayTypeSegment").to_matchable(),
1041 ])
1042 .config(|this| this.optional())
1043 .to_matchable(),
1044 ])
1045 .to_matchable(),
1046 );
1047
1048 postgres.replace_grammar("ArrayTypeSegment", Ref::keyword("ARRAY").to_matchable());
1049
1050 postgres.add([(
1051 "IndexAccessMethodSegment".into(),
1052 NodeMatcher::new(SyntaxKind::IndexAccessMethod, |_| {
1053 Ref::new("SingleIdentifierGrammar").to_matchable()
1054 })
1055 .to_matchable()
1056 .into(),
1057 )]);
1058
1059 postgres.add([(
1060 "OperatorClassReferenceSegment".into(),
1061 NodeMatcher::new(SyntaxKind::OperatorClassReference, |postgres| {
1062 postgres
1063 .grammar("ObjectReferenceSegment")
1064 .match_grammar(postgres)
1065 .unwrap()
1066 })
1067 .to_matchable()
1068 .into(),
1069 )]);
1070
1071 postgres.add([
1072 (
1073 "DefinitionParameterSegment".into(),
1074 NodeMatcher::new(SyntaxKind::DefinitionParameter, |_| {
1075 Sequence::new(vec![
1076 Ref::new("PropertiesNakedIdentifierSegment").to_matchable(),
1077 Sequence::new(vec![
1078 Ref::new("EqualsSegment").to_matchable(),
1079 Ref::new("DefinitionArgumentValueGrammar")
1080 .optional()
1081 .to_matchable(),
1082 ])
1083 .to_matchable(),
1084 ])
1085 .to_matchable()
1086 })
1087 .to_matchable()
1088 .into(),
1089 ),
1090 (
1091 "DefinitionParametersSegment".into(),
1092 NodeMatcher::new(SyntaxKind::DefinitionParameters, |_| {
1093 Bracketed::new(vec![
1094 Delimited::new(vec![Ref::new("DefinitionParameterSegment").to_matchable()])
1095 .to_matchable(),
1096 ])
1097 .to_matchable()
1098 })
1099 .to_matchable()
1100 .into(),
1101 ),
1102 ]);
1103
1104 postgres.replace_grammar(
1105 "CreateCastStatementSegment",
1106 Sequence::new(vec![
1107 Ref::keyword("CREATE").to_matchable(),
1108 Ref::keyword("CAST").to_matchable(),
1109 Bracketed::new(vec![
1110 Sequence::new(vec![
1111 Ref::new("DatatypeSegment").to_matchable(),
1112 Ref::keyword("AS").to_matchable(),
1113 Ref::new("DatatypeSegment").to_matchable(),
1114 ])
1115 .to_matchable(),
1116 ])
1117 .to_matchable(),
1118 one_of(vec![
1119 Sequence::new(vec![
1120 Ref::keyword("WITH").to_matchable(),
1121 Ref::keyword("FUNCTION").to_matchable(),
1122 Ref::new("FunctionNameSegment").to_matchable(),
1123 Ref::new("FunctionParameterListGrammar")
1124 .optional()
1125 .to_matchable(),
1126 ])
1127 .to_matchable(),
1128 Sequence::new(vec![
1129 Ref::keyword("WITHOUT").to_matchable(),
1130 Ref::keyword("FUNCTION").to_matchable(),
1131 ])
1132 .to_matchable(),
1133 Sequence::new(vec![
1134 Ref::keyword("WITH").to_matchable(),
1135 Ref::keyword("INOUT").to_matchable(),
1136 ])
1137 .to_matchable(),
1138 ])
1139 .to_matchable(),
1140 one_of(vec![
1141 Sequence::new(vec![
1142 Ref::keyword("AS").to_matchable(),
1143 Ref::keyword("ASSIGNMENT").to_matchable(),
1144 ])
1145 .config(|this| this.optional())
1146 .to_matchable(),
1147 Sequence::new(vec![
1148 Ref::keyword("AS").to_matchable(),
1149 Ref::keyword("IMPLICIT").to_matchable(),
1150 ])
1151 .config(|this| this.optional())
1152 .to_matchable(),
1153 ])
1154 .config(|this| this.optional())
1155 .to_matchable(),
1156 ])
1157 .to_matchable(),
1158 );
1159
1160 postgres.replace_grammar(
1161 "DropCastStatementSegment",
1162 Sequence::new(vec![
1163 Ref::keyword("DROP").to_matchable(),
1164 Ref::keyword("CAST").to_matchable(),
1165 Sequence::new(vec![
1166 Ref::keyword("IF").to_matchable(),
1167 Ref::keyword("EXISTS").to_matchable(),
1168 ])
1169 .config(|this| this.optional())
1170 .to_matchable(),
1171 Bracketed::new(vec![
1172 Sequence::new(vec![
1173 Ref::new("DatatypeSegment").to_matchable(),
1174 Ref::keyword("AS").to_matchable(),
1175 Ref::new("DatatypeSegment").to_matchable(),
1176 ])
1177 .to_matchable(),
1178 ])
1179 .to_matchable(),
1180 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
1181 ])
1182 .to_matchable(),
1183 );
1184
1185 postgres.add([
1186 (
1187 "RelationOptionSegment".into(),
1188 NodeMatcher::new(SyntaxKind::RelationOption, |_| {
1189 Sequence::new(vec![
1190 Ref::new("PropertiesNakedIdentifierSegment").to_matchable(),
1191 Sequence::new(vec![
1192 Ref::new("DotSegment").to_matchable(),
1193 Ref::new("PropertiesNakedIdentifierSegment").to_matchable(),
1194 ])
1195 .config(|this| this.optional())
1196 .to_matchable(),
1197 Sequence::new(vec![
1198 Ref::new("EqualsSegment").to_matchable(),
1199 Ref::new("DefinitionArgumentValueGrammar")
1200 .optional()
1201 .to_matchable(),
1202 ])
1203 .config(|this| this.optional())
1204 .to_matchable(),
1205 ])
1206 .to_matchable()
1207 })
1208 .to_matchable()
1209 .into(),
1210 ),
1211 (
1212 "RelationOptionsSegment".into(),
1213 NodeMatcher::new(SyntaxKind::RelationOptions, |_| {
1214 Bracketed::new(vec![
1215 Delimited::new(vec![Ref::new("RelationOptionSegment").to_matchable()])
1216 .to_matchable(),
1217 ])
1218 .to_matchable()
1219 })
1220 .to_matchable()
1221 .into(),
1222 ),
1223 ]);
1224
1225 postgres.replace_grammar(
1226 "CreateFunctionStatementSegment",
1227 Sequence::new(vec![
1228 Ref::keyword("CREATE").to_matchable(),
1229 Sequence::new(vec![
1230 Ref::keyword("OR").to_matchable(),
1231 Ref::keyword("REPLACE").to_matchable(),
1232 ])
1233 .config(|this| this.optional())
1234 .to_matchable(),
1235 Ref::new("TemporaryGrammar").optional().to_matchable(),
1236 Ref::keyword("FUNCTION").to_matchable(),
1237 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
1238 Ref::new("FunctionNameSegment").to_matchable(),
1239 Ref::new("FunctionParameterListGrammar").to_matchable(),
1240 Sequence::new(vec![
1241 Ref::keyword("RETURNS").to_matchable(),
1242 one_of(vec![
1243 Sequence::new(vec![
1244 Ref::keyword("TABLE").to_matchable(),
1245 Bracketed::new(vec![
1246 Delimited::new(vec![
1247 one_of(vec![
1248 Ref::new("DatatypeSegment").to_matchable(),
1249 Sequence::new(vec![
1250 Ref::new("ColumnReferenceSegment").to_matchable(),
1251 Ref::new("DatatypeSegment").to_matchable(),
1252 ])
1253 .to_matchable(),
1254 ])
1255 .to_matchable(),
1256 ])
1257 .to_matchable(),
1258 ])
1259 .config(|this| this.optional())
1260 .to_matchable(),
1261 ])
1262 .to_matchable(),
1263 Sequence::new(vec![
1264 Ref::keyword("SETOF").to_matchable(),
1265 Ref::new("DatatypeSegment").to_matchable(),
1266 ])
1267 .to_matchable(),
1268 Ref::new("DatatypeSegment").to_matchable(),
1269 ])
1270 .config(|this| this.optional())
1271 .to_matchable(),
1272 ])
1273 .config(|this| this.optional())
1274 .to_matchable(),
1275 Ref::new("FunctionDefinitionGrammar").to_matchable(),
1276 ])
1277 .to_matchable(),
1278 );
1279
1280 postgres.add([
1281 (
1282 "DropFunctionStatementSegment".into(),
1283 NodeMatcher::new(SyntaxKind::DropFunctionStatement, |_| {
1284 Sequence::new(vec![
1285 Ref::keyword("DROP").to_matchable(),
1286 Ref::keyword("FUNCTION").to_matchable(),
1287 Ref::new("IfExistsGrammar").optional().to_matchable(),
1288 Delimited::new(vec![
1289 Sequence::new(vec![
1290 Ref::new("FunctionNameSegment").to_matchable(),
1291 Ref::new("FunctionParameterListGrammar")
1292 .optional()
1293 .to_matchable(),
1294 ])
1295 .to_matchable(),
1296 ])
1297 .to_matchable(),
1298 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
1299 ])
1300 .to_matchable()
1301 })
1302 .to_matchable()
1303 .into(),
1304 ),
1305 (
1306 "AlterFunctionStatementSegment".into(),
1307 NodeMatcher::new(SyntaxKind::AlterFunctionStatement, |_| {
1308 Sequence::new(vec![
1309 Ref::keyword("ALTER").to_matchable(),
1310 Ref::keyword("FUNCTION").to_matchable(),
1311 Delimited::new(vec![
1312 Sequence::new(vec![
1313 Ref::new("FunctionNameSegment").to_matchable(),
1314 Ref::new("FunctionParameterListGrammar")
1315 .optional()
1316 .to_matchable(),
1317 ])
1318 .to_matchable(),
1319 ])
1320 .to_matchable(),
1321 one_of(vec![
1322 Ref::new("AlterFunctionActionSegment")
1323 .optional()
1324 .to_matchable(),
1325 Sequence::new(vec![
1326 Ref::keyword("RENAME").to_matchable(),
1327 Ref::keyword("TO").to_matchable(),
1328 Ref::new("FunctionNameSegment").to_matchable(),
1329 ])
1330 .to_matchable(),
1331 Sequence::new(vec![
1332 Ref::keyword("SET").to_matchable(),
1333 Ref::keyword("SCHEMA").to_matchable(),
1334 Ref::new("SchemaReferenceSegment").to_matchable(),
1335 ])
1336 .to_matchable(),
1337 Sequence::new(vec![
1338 Ref::keyword("OWNER").to_matchable(),
1339 Ref::keyword("TO").to_matchable(),
1340 one_of(vec![
1341 one_of(vec![
1342 Ref::new("ParameterNameSegment").to_matchable(),
1343 Ref::new("QuotedIdentifierSegment").to_matchable(),
1344 ])
1345 .to_matchable(),
1346 Ref::keyword("CURRENT_ROLE").to_matchable(),
1347 Ref::keyword("CURRENT_USER").to_matchable(),
1348 Ref::keyword("SESSION_USER").to_matchable(),
1349 ])
1350 .to_matchable(),
1351 ])
1352 .to_matchable(),
1353 Sequence::new(vec![
1354 Ref::keyword("NO").optional().to_matchable(),
1355 Ref::keyword("DEPENDS").to_matchable(),
1356 Ref::keyword("ON").to_matchable(),
1357 Ref::keyword("EXTENSION").to_matchable(),
1358 Ref::new("ExtensionReferenceSegment").to_matchable(),
1359 ])
1360 .to_matchable(),
1361 ])
1362 .to_matchable(),
1363 ])
1364 .to_matchable()
1365 })
1366 .to_matchable()
1367 .into(),
1368 ),
1369 (
1370 "AlterFunctionActionSegment".into(),
1371 NodeMatcher::new(SyntaxKind::AlterFunctionActionSegment, |_| {
1372 Sequence::new(vec![
1373 one_of(vec![
1374 one_of(vec![
1375 Sequence::new(vec![
1376 Ref::keyword("CALLED").to_matchable(),
1377 Ref::keyword("ON").to_matchable(),
1378 Ref::keyword("NULL").to_matchable(),
1379 Ref::keyword("INPUT").to_matchable(),
1380 ])
1381 .to_matchable(),
1382 Sequence::new(vec![
1383 Ref::keyword("RETURNS").to_matchable(),
1384 Ref::keyword("NULL").to_matchable(),
1385 Ref::keyword("ON").to_matchable(),
1386 Ref::keyword("NULL").to_matchable(),
1387 Ref::keyword("INPUT").to_matchable(),
1388 ])
1389 .to_matchable(),
1390 Ref::keyword("STRICT").to_matchable(),
1391 ])
1392 .to_matchable(),
1393 one_of(vec![
1394 Ref::keyword("IMMUTABLE").to_matchable(),
1395 Ref::keyword("STABLE").to_matchable(),
1396 Ref::keyword("VOLATILE").to_matchable(),
1397 ])
1398 .to_matchable(),
1399 Sequence::new(vec![
1400 Ref::keyword("NOT").optional().to_matchable(),
1401 Ref::keyword("LEAKPROOF").to_matchable(),
1402 ])
1403 .to_matchable(),
1404 Sequence::new(vec![
1405 Ref::keyword("EXTERNAL").optional().to_matchable(),
1406 Ref::keyword("SECURITY").to_matchable(),
1407 one_of(vec![
1408 Ref::keyword("DEFINER").to_matchable(),
1409 Ref::keyword("INVOKER").to_matchable(),
1410 ])
1411 .to_matchable(),
1412 ])
1413 .to_matchable(),
1414 Sequence::new(vec![
1415 Ref::keyword("PARALLEL").to_matchable(),
1416 one_of(vec![
1417 Ref::keyword("UNSAFE").to_matchable(),
1418 Ref::keyword("RESTRICTED").to_matchable(),
1419 Ref::keyword("SAFE").to_matchable(),
1420 ])
1421 .to_matchable(),
1422 ])
1423 .to_matchable(),
1424 Sequence::new(vec![
1425 Ref::keyword("COST").to_matchable(),
1426 Ref::new("NumericLiteralSegment").to_matchable(),
1427 ])
1428 .to_matchable(),
1429 Sequence::new(vec![
1430 Ref::keyword("ROWS").to_matchable(),
1431 Ref::new("NumericLiteralSegment").to_matchable(),
1432 ])
1433 .to_matchable(),
1434 Sequence::new(vec![
1435 Ref::keyword("SUPPORT").to_matchable(),
1436 Ref::new("ParameterNameSegment").to_matchable(),
1437 ])
1438 .to_matchable(),
1439 Sequence::new(vec![
1440 Ref::keyword("SET").to_matchable(),
1441 Ref::new("ParameterNameSegment").to_matchable(),
1442 one_of(vec![
1443 Sequence::new(vec![
1444 one_of(vec![
1445 Ref::keyword("TO").to_matchable(),
1446 Ref::new("EqualsSegment").to_matchable(),
1447 ])
1448 .to_matchable(),
1449 one_of(vec![
1450 Ref::new("LiteralGrammar").to_matchable(),
1451 Ref::new("NakedIdentifierSegment").to_matchable(),
1452 Ref::keyword("DEFAULT").to_matchable(),
1453 ])
1454 .to_matchable(),
1455 ])
1456 .to_matchable(),
1457 Sequence::new(vec![
1458 Ref::keyword("FROM").to_matchable(),
1459 Ref::keyword("CURRENT").to_matchable(),
1460 ])
1461 .to_matchable(),
1462 ])
1463 .to_matchable(),
1464 ])
1465 .to_matchable(),
1466 Sequence::new(vec![
1467 Ref::keyword("RESET").to_matchable(),
1468 one_of(vec![
1469 Ref::keyword("ALL").to_matchable(),
1470 Ref::new("ParameterNameSegment").to_matchable(),
1471 ])
1472 .to_matchable(),
1473 ])
1474 .to_matchable(),
1475 ])
1476 .to_matchable(),
1477 Ref::keyword("RESTRICT").optional().to_matchable(),
1478 ])
1479 .to_matchable()
1480 })
1481 .to_matchable()
1482 .into(),
1483 ),
1484 (
1485 "AlterProcedureActionSegment".into(),
1486 NodeMatcher::new(SyntaxKind::AlterProcedureActionSegment, |_| {
1487 Sequence::new(vec![
1488 one_of(vec![
1489 Sequence::new(vec![
1490 Ref::keyword("EXTERNAL").optional().to_matchable(),
1491 Ref::keyword("SECURITY").to_matchable(),
1492 one_of(vec![
1493 Ref::keyword("DEFINER").to_matchable(),
1494 Ref::keyword("INVOKER").to_matchable(),
1495 ])
1496 .to_matchable(),
1497 ])
1498 .to_matchable(),
1499 Sequence::new(vec![
1500 Ref::keyword("SET").to_matchable(),
1501 Ref::new("ParameterNameSegment").to_matchable(),
1502 one_of(vec![
1503 Sequence::new(vec![
1504 one_of(vec![
1505 Ref::keyword("TO").to_matchable(),
1506 Ref::new("EqualsSegment").to_matchable(),
1507 ])
1508 .to_matchable(),
1509 one_of(vec![
1510 Ref::new("LiteralGrammar").to_matchable(),
1511 Ref::new("NakedIdentifierSegment").to_matchable(),
1512 Ref::keyword("DEFAULT").to_matchable(),
1513 ])
1514 .to_matchable(),
1515 ])
1516 .to_matchable(),
1517 Sequence::new(vec![
1518 Ref::keyword("FROM").to_matchable(),
1519 Ref::keyword("CURRENT").to_matchable(),
1520 ])
1521 .to_matchable(),
1522 ])
1523 .to_matchable(),
1524 ])
1525 .to_matchable(),
1526 Sequence::new(vec![
1527 Ref::keyword("RESET").to_matchable(),
1528 one_of(vec![
1529 Ref::keyword("ALL").to_matchable(),
1530 Ref::new("ParameterNameSegment").to_matchable(),
1531 ])
1532 .to_matchable(),
1533 ])
1534 .to_matchable(),
1535 ])
1536 .to_matchable(),
1537 Ref::keyword("RESTRICT").optional().to_matchable(),
1538 ])
1539 .to_matchable()
1540 })
1541 .to_matchable()
1542 .into(),
1543 ),
1544 (
1545 "AlterProcedureStatementSegment".into(),
1546 NodeMatcher::new(SyntaxKind::AlterProcedureStatement, |_| {
1547 Sequence::new(vec![
1548 Ref::keyword("ALTER").to_matchable(),
1549 Ref::keyword("PROCEDURE").to_matchable(),
1550 Delimited::new(vec![
1551 Sequence::new(vec![
1552 Ref::new("FunctionNameSegment").to_matchable(),
1553 Ref::new("FunctionParameterListGrammar")
1554 .optional()
1555 .to_matchable(),
1556 ])
1557 .to_matchable(),
1558 ])
1559 .to_matchable(),
1560 one_of(vec![
1561 Ref::new("AlterProcedureActionSegment")
1562 .optional()
1563 .to_matchable(),
1564 Sequence::new(vec![
1565 Ref::keyword("RENAME").to_matchable(),
1566 Ref::keyword("TO").to_matchable(),
1567 Ref::new("FunctionNameSegment").to_matchable(),
1568 ])
1569 .to_matchable(),
1570 Sequence::new(vec![
1571 Ref::keyword("SET").to_matchable(),
1572 Ref::keyword("SCHEMA").to_matchable(),
1573 Ref::new("SchemaReferenceSegment").to_matchable(),
1574 ])
1575 .to_matchable(),
1576 Sequence::new(vec![
1577 Ref::keyword("SET").to_matchable(),
1578 Ref::new("ParameterNameSegment").to_matchable(),
1579 one_of(vec![
1580 Sequence::new(vec![
1581 one_of(vec![
1582 Ref::keyword("TO").to_matchable(),
1583 Ref::new("EqualsSegment").to_matchable(),
1584 ])
1585 .to_matchable(),
1586 Delimited::new(vec![
1587 one_of(vec![
1588 Ref::new("ParameterNameSegment").to_matchable(),
1589 Ref::new("LiteralGrammar").to_matchable(),
1590 ])
1591 .to_matchable(),
1592 ])
1593 .to_matchable(),
1594 ])
1595 .to_matchable(),
1596 Sequence::new(vec![
1597 Ref::keyword("FROM").to_matchable(),
1598 Ref::keyword("CURRENT").to_matchable(),
1599 ])
1600 .to_matchable(),
1601 ])
1602 .to_matchable(),
1603 ])
1604 .to_matchable(),
1605 Sequence::new(vec![
1606 Ref::keyword("OWNER").to_matchable(),
1607 Ref::keyword("TO").to_matchable(),
1608 one_of(vec![
1609 one_of(vec![
1610 Ref::new("ParameterNameSegment").to_matchable(),
1611 Ref::new("QuotedIdentifierSegment").to_matchable(),
1612 ])
1613 .to_matchable(),
1614 Ref::keyword("CURRENT_ROLE").to_matchable(),
1615 Ref::keyword("CURRENT_USER").to_matchable(),
1616 Ref::keyword("SESSION_USER").to_matchable(),
1617 ])
1618 .to_matchable(),
1619 ])
1620 .to_matchable(),
1621 Sequence::new(vec![
1622 Ref::keyword("NO").optional().to_matchable(),
1623 Ref::keyword("DEPENDS").to_matchable(),
1624 Ref::keyword("ON").to_matchable(),
1625 Ref::keyword("EXTENSION").to_matchable(),
1626 Ref::new("ExtensionReferenceSegment").to_matchable(),
1627 ])
1628 .to_matchable(),
1629 ])
1630 .to_matchable(),
1631 ])
1632 .to_matchable()
1633 })
1634 .to_matchable()
1635 .into(),
1636 ),
1637 (
1638 "CreateProcedureStatementSegment".into(),
1639 NodeMatcher::new(SyntaxKind::CreateProcedureStatement, |_| {
1640 Sequence::new(vec![
1641 Ref::keyword("CREATE").to_matchable(),
1642 Sequence::new(vec![
1643 Ref::keyword("OR").to_matchable(),
1644 Ref::keyword("REPLACE").to_matchable(),
1645 ])
1646 .config(|this| this.optional())
1647 .to_matchable(),
1648 Ref::keyword("PROCEDURE").to_matchable(),
1649 Ref::new("FunctionNameSegment").to_matchable(),
1650 Ref::new("FunctionParameterListGrammar").to_matchable(),
1651 Ref::new("FunctionDefinitionGrammar").to_matchable(),
1652 ])
1653 .to_matchable()
1654 })
1655 .to_matchable()
1656 .into(),
1657 ),
1658 (
1659 "DropProcedureStatementSegment".into(),
1660 NodeMatcher::new(SyntaxKind::DropProcedureStatement, |_| {
1661 Sequence::new(vec![
1662 Ref::keyword("DROP").to_matchable(),
1663 Ref::keyword("PROCEDURE").to_matchable(),
1664 Ref::new("IfExistsGrammar").optional().to_matchable(),
1665 Delimited::new(vec![
1666 Sequence::new(vec![
1667 Ref::new("FunctionNameSegment").to_matchable(),
1668 Ref::new("FunctionParameterListGrammar")
1669 .optional()
1670 .to_matchable(),
1671 ])
1672 .to_matchable(),
1673 ])
1674 .to_matchable(),
1675 one_of(vec![
1676 Ref::keyword("CASCADE").to_matchable(),
1677 Ref::keyword("RESTRICT").to_matchable(),
1678 ])
1679 .config(|this| this.optional())
1680 .to_matchable(),
1681 ])
1682 .to_matchable()
1683 })
1684 .to_matchable()
1685 .into(),
1686 ),
1687 (
1688 "WellKnownTextGeometrySegment".into(),
1689 NodeMatcher::new(SyntaxKind::WktGeometryType, |_| {
1690 let geometry_type_keywords = POSTGRES_POSTGIS_DATATYPE_KEYWORDS
1691 .iter()
1692 .map(|(kw, _)| Ref::keyword(*kw).to_matchable())
1693 .collect_vec();
1694
1695 let mut geometry_type_keywords0 = geometry_type_keywords.clone();
1696 geometry_type_keywords0.extend(
1697 ["GEOMETRY", "GEOGRAPHY"]
1698 .into_iter()
1699 .map(|it| Ref::keyword(it).to_matchable()),
1700 );
1701
1702 one_of(vec![
1703 Sequence::new(vec![
1704 one_of(geometry_type_keywords.clone()).to_matchable(),
1705 Bracketed::new(vec![
1706 Delimited::new(vec![
1707 optionally_bracketed(vec![
1708 Delimited::new(vec![
1709 Ref::new("SimpleGeometryGrammar").to_matchable(),
1710 ])
1711 .to_matchable(),
1712 ])
1713 .to_matchable(),
1714 Bracketed::new(vec![
1715 Delimited::new(vec![
1716 Bracketed::new(vec![
1717 Delimited::new(vec![
1718 Ref::new("SimpleGeometryGrammar").to_matchable(),
1719 ])
1720 .to_matchable(),
1721 ])
1722 .to_matchable(),
1723 ])
1724 .to_matchable(),
1725 ])
1726 .to_matchable(),
1727 Ref::new("WellKnownTextGeometrySegment").to_matchable(),
1728 ])
1729 .to_matchable(),
1730 ])
1731 .to_matchable(),
1732 ])
1733 .to_matchable(),
1734 Sequence::new(vec![
1735 one_of(vec![
1736 Ref::keyword("GEOMETRY").to_matchable(),
1737 Ref::keyword("GEOGRAPHY").to_matchable(),
1738 ])
1739 .to_matchable(),
1740 Bracketed::new(vec![
1741 Sequence::new(vec![
1742 one_of(geometry_type_keywords0).to_matchable(),
1743 Ref::new("CommaSegment").to_matchable(),
1744 Ref::new("NumericLiteralSegment").to_matchable(),
1745 ])
1746 .to_matchable(),
1747 ])
1748 .to_matchable(),
1749 ])
1750 .to_matchable(),
1751 ])
1752 .to_matchable()
1753 })
1754 .to_matchable()
1755 .into(),
1756 ),
1757 (
1758 "SemiStructuredAccessorSegment".into(),
1759 NodeMatcher::new(SyntaxKind::SemiStructuredExpression, |_| {
1760 Sequence::new(vec![
1761 Ref::new("DotSegment").to_matchable(),
1762 Ref::new("SingleIdentifierGrammar").to_matchable(),
1763 Ref::new("ArrayAccessorSegment").optional().to_matchable(),
1764 AnyNumberOf::new(vec![
1765 Sequence::new(vec![
1766 Ref::new("DotSegment").to_matchable(),
1767 Ref::new("SingleIdentifierGrammar").to_matchable(),
1768 ])
1769 .to_matchable(),
1770 Ref::new("ArrayAccessorSegment").optional().to_matchable(),
1771 ])
1772 .to_matchable(),
1773 ])
1774 .to_matchable()
1775 })
1776 .to_matchable()
1777 .into(),
1778 ),
1779 ]);
1780
1781 postgres.replace_grammar(
1782 "FunctionDefinitionGrammar",
1783 Sequence::new(vec![
1784 AnyNumberOf::new(vec![
1785 Ref::new("LanguageClauseSegment").to_matchable(),
1786 Sequence::new(vec![
1787 Ref::keyword("TRANSFORM").to_matchable(),
1788 Ref::keyword("FOR").to_matchable(),
1789 Ref::keyword("TYPE").to_matchable(),
1790 Ref::new("ParameterNameSegment").to_matchable(),
1791 ])
1792 .to_matchable(),
1793 Ref::keyword("WINDOW").to_matchable(),
1794 one_of(vec![
1795 Ref::keyword("IMMUTABLE").to_matchable(),
1796 Ref::keyword("STABLE").to_matchable(),
1797 Ref::keyword("VOLATILE").to_matchable(),
1798 ])
1799 .to_matchable(),
1800 Sequence::new(vec![
1801 Ref::keyword("NOT").optional().to_matchable(),
1802 Ref::keyword("LEAKPROOF").to_matchable(),
1803 ])
1804 .to_matchable(),
1805 one_of(vec![
1806 Sequence::new(vec![
1807 Ref::keyword("CALLED").to_matchable(),
1808 Ref::keyword("ON").to_matchable(),
1809 Ref::keyword("NULL").to_matchable(),
1810 Ref::keyword("INPUT").to_matchable(),
1811 ])
1812 .to_matchable(),
1813 Sequence::new(vec![
1814 Ref::keyword("RETURNS").to_matchable(),
1815 Ref::keyword("NULL").to_matchable(),
1816 Ref::keyword("ON").to_matchable(),
1817 Ref::keyword("NULL").to_matchable(),
1818 Ref::keyword("INPUT").to_matchable(),
1819 ])
1820 .to_matchable(),
1821 Ref::keyword("STRICT").to_matchable(),
1822 ])
1823 .to_matchable(),
1824 Sequence::new(vec![
1825 Ref::keyword("EXTERNAL").optional().to_matchable(),
1826 Ref::keyword("SECURITY").to_matchable(),
1827 one_of(vec![
1828 Ref::keyword("INVOKER").to_matchable(),
1829 Ref::keyword("DEFINER").to_matchable(),
1830 ])
1831 .to_matchable(),
1832 ])
1833 .to_matchable(),
1834 Sequence::new(vec![
1835 Ref::keyword("PARALLEL").to_matchable(),
1836 one_of(vec![
1837 Ref::keyword("UNSAFE").to_matchable(),
1838 Ref::keyword("RESTRICTED").to_matchable(),
1839 Ref::keyword("SAFE").to_matchable(),
1840 ])
1841 .to_matchable(),
1842 ])
1843 .to_matchable(),
1844 Sequence::new(vec![
1845 Ref::keyword("COST").to_matchable(),
1846 Ref::new("NumericLiteralSegment").to_matchable(),
1847 ])
1848 .to_matchable(),
1849 Sequence::new(vec![
1850 Ref::keyword("ROWS").to_matchable(),
1851 Ref::new("NumericLiteralSegment").to_matchable(),
1852 ])
1853 .to_matchable(),
1854 Sequence::new(vec![
1855 Ref::keyword("SUPPORT").to_matchable(),
1856 Ref::new("ParameterNameSegment").to_matchable(),
1857 ])
1858 .to_matchable(),
1859 Sequence::new(vec![
1860 Ref::keyword("SET").to_matchable(),
1861 Ref::new("ParameterNameSegment").to_matchable(),
1862 one_of(vec![
1863 Sequence::new(vec![
1864 one_of(vec![
1865 Ref::keyword("TO").to_matchable(),
1866 Ref::new("EqualsSegment").to_matchable(),
1867 ])
1868 .to_matchable(),
1869 Delimited::new(vec![
1870 one_of(vec![
1871 Ref::new("ParameterNameSegment").to_matchable(),
1872 Ref::new("LiteralGrammar").to_matchable(),
1873 ])
1874 .to_matchable(),
1875 ])
1876 .to_matchable(),
1877 ])
1878 .to_matchable(),
1879 Sequence::new(vec![
1880 Ref::keyword("FROM").to_matchable(),
1881 Ref::keyword("CURRENT").to_matchable(),
1882 ])
1883 .to_matchable(),
1884 ])
1885 .to_matchable(),
1886 ])
1887 .to_matchable(),
1888 Sequence::new(vec![
1889 Ref::keyword("AS").to_matchable(),
1890 one_of(vec![
1891 Ref::new("QuotedLiteralSegment").to_matchable(),
1892 Sequence::new(vec![
1893 Ref::new("QuotedLiteralSegment").to_matchable(),
1894 Ref::new("CommaSegment").to_matchable(),
1895 Ref::new("QuotedLiteralSegment").to_matchable(),
1896 ])
1897 .to_matchable(),
1898 ])
1899 .to_matchable(),
1900 ])
1901 .to_matchable(),
1902 ])
1903 .to_matchable(),
1904 Sequence::new(vec![
1905 Ref::keyword("WITH").to_matchable(),
1906 Bracketed::new(vec![
1907 Delimited::new(vec![Ref::new("ParameterNameSegment").to_matchable()])
1908 .to_matchable(),
1909 ])
1910 .to_matchable(),
1911 ])
1912 .config(|this| this.optional())
1913 .to_matchable(),
1914 ])
1915 .to_matchable(),
1916 );
1917
1918 postgres.add([
1919 (
1920 "IntoClauseSegment".into(),
1921 NodeMatcher::new(SyntaxKind::IntoClause, |_| {
1922 Sequence::new(vec![
1923 Ref::keyword("INTO").to_matchable(),
1924 one_of(vec![
1925 Ref::keyword("TEMPORARY").to_matchable(),
1926 Ref::keyword("TEMP").to_matchable(),
1927 Ref::keyword("UNLOGGED").to_matchable(),
1928 ])
1929 .config(|this| this.optional())
1930 .to_matchable(),
1931 Ref::keyword("TABLE").optional().to_matchable(),
1932 Ref::new("TableReferenceSegment").to_matchable(),
1933 ])
1934 .to_matchable()
1935 })
1936 .to_matchable()
1937 .into(),
1938 ),
1939 (
1940 "ForClauseSegment".into(),
1941 NodeMatcher::new(SyntaxKind::ForClause, |_| {
1942 Sequence::new(vec![
1943 Ref::keyword("FOR").to_matchable(),
1944 one_of(vec![
1945 Ref::keyword("UPDATE").to_matchable(),
1946 Sequence::new(vec![
1947 Ref::keyword("NO").to_matchable(),
1948 Ref::keyword("KEY").to_matchable(),
1949 Ref::keyword("UPDATE").to_matchable(),
1950 ])
1951 .to_matchable(),
1952 Ref::keyword("SHARE").to_matchable(),
1953 Sequence::new(vec![
1954 Ref::keyword("KEY").to_matchable(),
1955 Ref::keyword("SHARE").to_matchable(),
1956 ])
1957 .to_matchable(),
1958 ])
1959 .to_matchable(),
1960 Sequence::new(vec![
1961 Ref::keyword("OF").to_matchable(),
1962 Delimited::new(vec![Ref::new("TableReferenceSegment").to_matchable()])
1963 .to_matchable(),
1964 ])
1965 .config(|this| this.optional())
1966 .to_matchable(),
1967 one_of(vec![
1968 Ref::keyword("NOWAIT").to_matchable(),
1969 Sequence::new(vec![
1970 Ref::keyword("SKIP").to_matchable(),
1971 Ref::keyword("LOCKED").to_matchable(),
1972 ])
1973 .to_matchable(),
1974 ])
1975 .config(|this| this.optional())
1976 .to_matchable(),
1977 ])
1978 .to_matchable()
1979 })
1980 .to_matchable()
1981 .into(),
1982 ),
1983 ]);
1984
1985 postgres.replace_grammar(
1986 "UnorderedSelectStatementSegment",
1987 ansi::get_unordered_select_statement_segment_grammar().copy(
1988 Some(vec![
1989 Ref::new("IntoClauseSegment").optional().to_matchable(),
1990 ]),
1991 None,
1992 Some(Ref::new("FromClauseSegment").optional().to_matchable()),
1993 None,
1994 vec![
1995 Sequence::new(vec![
1996 Ref::keyword("WITH").to_matchable(),
1997 Ref::keyword("NO").optional().to_matchable(),
1998 Ref::keyword("DATA").to_matchable(),
1999 ])
2000 .to_matchable(),
2001 Sequence::new(vec![
2002 Ref::keyword("ON").to_matchable(),
2003 Ref::keyword("CONFLICT").to_matchable(),
2004 ])
2005 .to_matchable(),
2006 Ref::keyword("RETURNING").to_matchable(),
2007 Ref::new("WithCheckOptionSegment").to_matchable(),
2008 ],
2009 false,
2010 ),
2011 );
2012
2013 postgres.replace_grammar(
2014 "SelectStatementSegment",
2015 postgres
2016 .grammar("UnorderedSelectStatementSegment")
2017 .match_grammar(&postgres)
2018 .unwrap()
2019 .copy(
2020 Some(vec![
2021 Ref::new("OrderByClauseSegment").optional().to_matchable(),
2022 Ref::new("LimitClauseSegment").optional().to_matchable(),
2023 Ref::new("NamedWindowSegment").optional().to_matchable(),
2024 ]),
2025 None,
2026 None,
2027 None,
2028 vec![],
2029 false,
2030 )
2031 .copy(
2032 Some(vec![Ref::new("ForClauseSegment").optional().to_matchable()]),
2033 None,
2034 Some(Ref::new("LimitClauseSegment").optional().to_matchable()),
2035 None,
2036 vec![
2037 Ref::new("SetOperatorSegment").to_matchable(),
2038 Ref::new("WithNoSchemaBindingClauseSegment").to_matchable(),
2039 Ref::new("WithDataClauseSegment").to_matchable(),
2040 Sequence::new(vec![
2041 Ref::keyword("ON").to_matchable(),
2042 Ref::keyword("CONFLICT").to_matchable(),
2043 ])
2044 .to_matchable(),
2045 Ref::keyword("RETURNING").to_matchable(),
2046 Ref::new("WithCheckOptionSegment").to_matchable(),
2047 ],
2048 true,
2049 ),
2050 );
2051
2052 postgres.replace_grammar(
2053 "SelectClauseSegment",
2054 Sequence::new(vec![
2055 Ref::keyword("SELECT").to_matchable(),
2056 Ref::new("SelectClauseModifierSegment")
2057 .optional()
2058 .to_matchable(),
2059 MetaSegment::indent().to_matchable(),
2060 Delimited::new(vec![Ref::new("SelectClauseElementSegment").to_matchable()])
2061 .config(|this| {
2062 this.optional();
2063 this.allow_trailing = true;
2064 })
2065 .to_matchable(),
2066 ])
2067 .config(|this| {
2068 this.terminators = vec![
2069 Ref::keyword("INTO").to_matchable(),
2070 Ref::keyword("FROM").to_matchable(),
2071 Ref::keyword("WHERE").to_matchable(),
2072 Sequence::new(vec![
2073 Ref::keyword("ORDER").to_matchable(),
2074 Ref::keyword("BY").to_matchable(),
2075 ])
2076 .to_matchable(),
2077 Ref::keyword("LIMIT").to_matchable(),
2078 Ref::keyword("OVERLAPS").to_matchable(),
2079 Ref::new("SetOperatorSegment").to_matchable(),
2080 Sequence::new(vec![
2081 Ref::keyword("WITH").to_matchable(),
2082 Ref::keyword("NO").optional().to_matchable(),
2083 Ref::keyword("DATA").to_matchable(),
2084 ])
2085 .to_matchable(),
2086 Ref::new("WithCheckOptionSegment").to_matchable(),
2087 ];
2088 this.parse_mode(ParseMode::GreedyOnceStarted);
2089 })
2090 .to_matchable(),
2091 );
2092
2093 postgres.replace_grammar(
2094 "SelectClauseModifierSegment",
2095 one_of(vec![
2096 Sequence::new(vec![
2097 Ref::keyword("DISTINCT").to_matchable(),
2098 Sequence::new(vec![
2099 Ref::keyword("ON").to_matchable(),
2100 Bracketed::new(vec![
2101 Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
2102 .to_matchable(),
2103 ])
2104 .config(|this| this.optional())
2105 .to_matchable(),
2106 ])
2107 .to_matchable(),
2108 ])
2109 .to_matchable(),
2110 Ref::keyword("ALL").to_matchable(),
2111 ])
2112 .to_matchable(),
2113 );
2114
2115 postgres.add([
2116 (
2117 "WithinGroupClauseSegment".into(),
2118 NodeMatcher::new(SyntaxKind::WithingroupClause, |_| {
2119 Sequence::new(vec![
2120 Ref::keyword("WITHIN").to_matchable(),
2121 Ref::keyword("GROUP").to_matchable(),
2122 Bracketed::new(vec![
2123 Ref::new("OrderByClauseSegment").optional().to_matchable(),
2124 ])
2125 .to_matchable(),
2126 ])
2127 .to_matchable()
2128 })
2129 .to_matchable()
2130 .into(),
2131 ),
2132 (
2133 "GroupByClauseSegment".into(),
2134 NodeMatcher::new(SyntaxKind::GroupbyClause, |_| {
2135 Sequence::new(vec![
2136 Ref::keyword("GROUP").to_matchable(),
2137 Ref::keyword("BY").to_matchable(),
2138 MetaSegment::indent().to_matchable(),
2139 Delimited::new(vec![
2140 one_of(vec![
2141 Ref::new("ColumnReferenceSegment").to_matchable(),
2142 Ref::new("NumericLiteralSegment").to_matchable(),
2143 Ref::new("CubeRollupClauseSegment").to_matchable(),
2144 Ref::new("GroupingSetsClauseSegment").to_matchable(),
2145 Ref::new("ExpressionSegment").to_matchable(),
2146 Bracketed::new(vec![]).to_matchable(),
2147 ])
2148 .to_matchable(),
2149 ])
2150 .config(|this| {
2151 this.terminators = vec![
2152 Sequence::new(vec![
2153 Ref::keyword("ORDER").to_matchable(),
2154 Ref::keyword("BY").to_matchable(),
2155 ])
2156 .to_matchable(),
2157 Ref::keyword("LIMIT").to_matchable(),
2158 Ref::keyword("HAVING").to_matchable(),
2159 Ref::keyword("QUALIFY").to_matchable(),
2160 Ref::keyword("WINDOW").to_matchable(),
2161 Ref::new("SetOperatorSegment").to_matchable(),
2162 ];
2163 })
2164 .to_matchable(),
2165 MetaSegment::dedent().to_matchable(),
2166 ])
2167 .to_matchable()
2168 })
2169 .to_matchable()
2170 .into(),
2171 ),
2172 ]);
2173
2174 postgres.replace_grammar(
2175 "CreateRoleStatementSegment",
2176 Sequence::new(vec![
2177 Ref::keyword("CREATE").to_matchable(),
2178 one_of(vec![
2179 Ref::keyword("ROLE").to_matchable(),
2180 Ref::keyword("USER").to_matchable(),
2181 ])
2182 .to_matchable(),
2183 Ref::new("RoleReferenceSegment").to_matchable(),
2184 Sequence::new(vec![
2185 Ref::keyword("WITH").optional().to_matchable(),
2186 any_set_of(vec![
2187 one_of(vec![
2188 Ref::keyword("SUPERUSER").to_matchable(),
2189 Ref::keyword("NOSUPERUSER").to_matchable(),
2190 ])
2191 .to_matchable(),
2192 one_of(vec![
2193 Ref::keyword("CREATEDB").to_matchable(),
2194 Ref::keyword("NOCREATEDB").to_matchable(),
2195 ])
2196 .to_matchable(),
2197 one_of(vec![
2198 Ref::keyword("CREATEROLE").to_matchable(),
2199 Ref::keyword("NOCREATEROLE").to_matchable(),
2200 ])
2201 .to_matchable(),
2202 one_of(vec![
2203 Ref::keyword("INHERIT").to_matchable(),
2204 Ref::keyword("NOINHERIT").to_matchable(),
2205 ])
2206 .to_matchable(),
2207 one_of(vec![
2208 Ref::keyword("LOGIN").to_matchable(),
2209 Ref::keyword("NOLOGIN").to_matchable(),
2210 ])
2211 .to_matchable(),
2212 one_of(vec![
2213 Ref::keyword("REPLICATION").to_matchable(),
2214 Ref::keyword("NOREPLICATION").to_matchable(),
2215 ])
2216 .to_matchable(),
2217 one_of(vec![
2218 Ref::keyword("BYPASSRLS").to_matchable(),
2219 Ref::keyword("NOBYPASSRLS").to_matchable(),
2220 ])
2221 .to_matchable(),
2222 Sequence::new(vec![
2223 Ref::keyword("CONNECTION").to_matchable(),
2224 Ref::keyword("LIMIT").to_matchable(),
2225 Ref::new("NumericLiteralSegment").to_matchable(),
2226 ])
2227 .to_matchable(),
2228 Sequence::new(vec![
2229 Ref::keyword("PASSWORD").to_matchable(),
2230 one_of(vec![
2231 Ref::new("QuotedLiteralSegment").to_matchable(),
2232 Ref::keyword("NULL").to_matchable(),
2233 ])
2234 .to_matchable(),
2235 ])
2236 .to_matchable(),
2237 Sequence::new(vec![
2238 Ref::keyword("VALID").to_matchable(),
2239 Ref::keyword("UNTIL").to_matchable(),
2240 Ref::new("QuotedLiteralSegment").to_matchable(),
2241 ])
2242 .to_matchable(),
2243 Sequence::new(vec![
2244 Ref::keyword("IN").to_matchable(),
2245 Ref::keyword("ROLE").to_matchable(),
2246 Ref::new("RoleReferenceSegment").to_matchable(),
2247 ])
2248 .to_matchable(),
2249 Sequence::new(vec![
2250 Ref::keyword("IN").to_matchable(),
2251 Ref::keyword("GROUP").to_matchable(),
2252 Ref::new("RoleReferenceSegment").to_matchable(),
2253 ])
2254 .to_matchable(),
2255 Sequence::new(vec![
2256 Ref::keyword("ROLE").to_matchable(),
2257 Ref::new("RoleReferenceSegment").to_matchable(),
2258 ])
2259 .to_matchable(),
2260 Sequence::new(vec![
2261 Ref::keyword("ADMIN").to_matchable(),
2262 Ref::new("RoleReferenceSegment").to_matchable(),
2263 ])
2264 .to_matchable(),
2265 Sequence::new(vec![
2266 Ref::keyword("USER").to_matchable(),
2267 Ref::new("RoleReferenceSegment").to_matchable(),
2268 ])
2269 .to_matchable(),
2270 Sequence::new(vec![
2271 Ref::keyword("SYSID").to_matchable(),
2272 Ref::new("NumericLiteralSegment").to_matchable(),
2273 ])
2274 .to_matchable(),
2275 ])
2276 .config(|this| this.optional())
2277 .to_matchable(),
2278 ])
2279 .config(|this| this.optional())
2280 .to_matchable(),
2281 ])
2282 .to_matchable(),
2283 );
2284
2285 postgres.add([(
2286 "AlterRoleStatementSegment".into(),
2287 NodeMatcher::new(SyntaxKind::AlterRoleStatement, |_| {
2288 Sequence::new(vec![
2289 Ref::keyword("ALTER").to_matchable(),
2290 one_of(vec![
2291 Ref::keyword("ROLE").to_matchable(),
2292 Ref::keyword("USER").to_matchable(),
2293 ])
2294 .to_matchable(),
2295 one_of(vec![
2296 Sequence::new(vec![
2298 one_of(vec![
2299 Ref::keyword("CURRENT_ROLE").to_matchable(),
2300 Ref::keyword("CURRENT_USER").to_matchable(),
2301 Ref::keyword("SESSION_USER").to_matchable(),
2302 Ref::new("RoleReferenceSegment").to_matchable(),
2303 ])
2304 .to_matchable(),
2305 Ref::keyword("WITH").optional().to_matchable(),
2306 any_set_of(vec![
2307 one_of(vec![
2308 Ref::keyword("SUPERUSER").to_matchable(),
2309 Ref::keyword("NOSUPERUSER").to_matchable(),
2310 ])
2311 .to_matchable(),
2312 one_of(vec![
2313 Ref::keyword("CREATEDB").to_matchable(),
2314 Ref::keyword("NOCREATEDB").to_matchable(),
2315 ])
2316 .to_matchable(),
2317 one_of(vec![
2318 Ref::keyword("CREATEROLE").to_matchable(),
2319 Ref::keyword("NOCREATEROLE").to_matchable(),
2320 ])
2321 .to_matchable(),
2322 one_of(vec![
2323 Ref::keyword("INHERIT").to_matchable(),
2324 Ref::keyword("NOINHERIT").to_matchable(),
2325 ])
2326 .to_matchable(),
2327 one_of(vec![
2328 Ref::keyword("LOGIN").to_matchable(),
2329 Ref::keyword("NOLOGIN").to_matchable(),
2330 ])
2331 .to_matchable(),
2332 one_of(vec![
2333 Ref::keyword("REPLICATION").to_matchable(),
2334 Ref::keyword("NOREPLICATION").to_matchable(),
2335 ])
2336 .to_matchable(),
2337 one_of(vec![
2338 Ref::keyword("BYPASSRLS").to_matchable(),
2339 Ref::keyword("NOBYPASSRLS").to_matchable(),
2340 ])
2341 .to_matchable(),
2342 Sequence::new(vec![
2343 Ref::keyword("CONNECTION").to_matchable(),
2344 Ref::keyword("LIMIT").to_matchable(),
2345 Ref::new("NumericLiteralSegment").to_matchable(),
2346 ])
2347 .to_matchable(),
2348 Sequence::new(vec![
2349 Ref::keyword("ENCRYPTED").optional().to_matchable(),
2350 Ref::keyword("PASSWORD").to_matchable(),
2351 one_of(vec![
2352 Ref::new("QuotedLiteralSegment").to_matchable(),
2353 Ref::keyword("NULL").to_matchable(),
2354 ])
2355 .to_matchable(),
2356 ])
2357 .to_matchable(),
2358 Sequence::new(vec![
2359 Ref::keyword("VALID").to_matchable(),
2360 Ref::keyword("UNTIL").to_matchable(),
2361 Ref::new("QuotedLiteralSegment").to_matchable(),
2362 ])
2363 .to_matchable(),
2364 ])
2365 .to_matchable(),
2366 ])
2367 .to_matchable(),
2368 Sequence::new(vec![
2370 Ref::new("RoleReferenceSegment").to_matchable(),
2371 Sequence::new(vec![
2372 Ref::keyword("RENAME").to_matchable(),
2373 Ref::keyword("TO").to_matchable(),
2374 Ref::new("RoleReferenceSegment").to_matchable(),
2375 ])
2376 .to_matchable(),
2377 ])
2378 .to_matchable(),
2379 Sequence::new(vec![
2381 one_of(vec![
2382 Ref::keyword("CURRENT_ROLE").to_matchable(),
2383 Ref::keyword("CURRENT_USER").to_matchable(),
2384 Ref::keyword("SESSION_USER").to_matchable(),
2385 Ref::keyword("ALL").to_matchable(),
2386 Ref::new("RoleReferenceSegment").to_matchable(),
2387 ])
2388 .to_matchable(),
2389 Sequence::new(vec![
2390 Ref::keyword("IN").to_matchable(),
2391 Ref::keyword("DATABASE").to_matchable(),
2392 Ref::new("DatabaseReferenceSegment").to_matchable(),
2393 ])
2394 .config(|this| this.optional())
2395 .to_matchable(),
2396 one_of(vec![
2397 Sequence::new(vec![
2398 Ref::keyword("SET").to_matchable(),
2399 Ref::new("ParameterNameSegment").to_matchable(),
2400 one_of(vec![
2401 Sequence::new(vec![
2402 one_of(vec![
2403 Ref::keyword("TO").to_matchable(),
2404 Ref::new("EqualsSegment").to_matchable(),
2405 ])
2406 .to_matchable(),
2407 one_of(vec![
2408 Ref::keyword("DEFAULT").to_matchable(),
2409 Delimited::new(vec![
2410 Ref::new("LiteralGrammar").to_matchable(),
2411 Ref::new("NakedIdentifierSegment").to_matchable(),
2412 Ref::new("OnKeywordAsIdentifierSegment")
2413 .to_matchable(),
2414 ])
2415 .to_matchable(),
2416 ])
2417 .to_matchable(),
2418 ])
2419 .to_matchable(),
2420 Sequence::new(vec![
2421 Ref::keyword("FROM").to_matchable(),
2422 Ref::keyword("CURRENT").to_matchable(),
2423 ])
2424 .to_matchable(),
2425 ])
2426 .to_matchable(),
2427 ])
2428 .to_matchable(),
2429 Sequence::new(vec![
2430 Ref::keyword("RESET").to_matchable(),
2431 one_of(vec![
2432 Ref::new("ParameterNameSegment").to_matchable(),
2433 Ref::keyword("ALL").to_matchable(),
2434 ])
2435 .to_matchable(),
2436 ])
2437 .to_matchable(),
2438 ])
2439 .to_matchable(),
2440 ])
2441 .to_matchable(),
2442 ])
2443 .to_matchable(),
2444 ])
2445 .to_matchable()
2446 })
2447 .to_matchable()
2448 .into(),
2449 )]);
2450
2451 postgres.replace_grammar(
2452 "ExplainStatementSegment",
2453 Sequence::new(vec![
2454 Ref::keyword("EXPLAIN").to_matchable(),
2455 one_of(vec![
2456 Sequence::new(vec![
2457 one_of(vec![
2458 Ref::keyword("ANALYZE").optional().to_matchable(),
2459 Ref::keyword("ANALYSE").optional().to_matchable(),
2460 ])
2461 .to_matchable(),
2462 Ref::keyword("VERBOSE").optional().to_matchable(),
2463 ])
2464 .to_matchable(),
2465 Bracketed::new(vec![
2466 Delimited::new(vec![Ref::new("ExplainOptionSegment").to_matchable()])
2467 .to_matchable(),
2468 ])
2469 .to_matchable(),
2470 ])
2471 .config(|this| this.optional())
2472 .to_matchable(),
2473 ansi::explainable_stmt().to_matchable(),
2474 ])
2475 .to_matchable(),
2476 );
2477
2478 postgres.add([(
2479 "ExplainOptionSegment".into(),
2480 NodeMatcher::new(SyntaxKind::ExplainOption, |_| {
2481 one_of(vec![
2482 Sequence::new(vec![
2483 one_of(vec![
2484 Ref::keyword("ANALYZE").to_matchable(),
2485 Ref::keyword("ANALYSE").to_matchable(),
2486 Ref::keyword("VERBOSE").to_matchable(),
2487 Ref::keyword("COSTS").to_matchable(),
2488 Ref::keyword("SETTINGS").to_matchable(),
2489 Ref::keyword("BUFFERS").to_matchable(),
2490 Ref::keyword("WAL").to_matchable(),
2491 Ref::keyword("TIMING").to_matchable(),
2492 Ref::keyword("SUMMARY").to_matchable(),
2493 ])
2494 .to_matchable(),
2495 Ref::new("BooleanLiteralGrammar").optional().to_matchable(),
2496 ])
2497 .to_matchable(),
2498 Sequence::new(vec![
2499 Ref::keyword("FORMAT").to_matchable(),
2500 one_of(vec![
2501 Ref::keyword("TEXT").to_matchable(),
2502 Ref::keyword("XML").to_matchable(),
2503 Ref::keyword("JSON").to_matchable(),
2504 Ref::keyword("YAML").to_matchable(),
2505 ])
2506 .to_matchable(),
2507 ])
2508 .to_matchable(),
2509 ])
2510 .to_matchable()
2511 })
2512 .to_matchable()
2513 .into(),
2514 )]);
2515
2516 postgres.replace_grammar(
2517 "CreateSchemaStatementSegment",
2518 Sequence::new(vec![
2519 Ref::keyword("CREATE").to_matchable(),
2520 Ref::keyword("SCHEMA").to_matchable(),
2521 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
2522 one_of(vec![
2523 Sequence::new(vec![
2524 Ref::new("SchemaReferenceSegment").optional().to_matchable(),
2525 Ref::keyword("AUTHORIZATION").to_matchable(),
2526 Ref::new("RoleReferenceSegment").to_matchable(),
2527 ])
2528 .to_matchable(),
2529 Ref::new("SchemaReferenceSegment").to_matchable(),
2530 ])
2531 .to_matchable(),
2532 ])
2533 .to_matchable(),
2534 );
2535
2536 postgres.replace_grammar(
2537 "CreateTableStatementSegment",
2538 Sequence::new(vec![
2539 Ref::keyword("CREATE").to_matchable(),
2540 one_of(vec![
2541 Sequence::new(vec![
2542 one_of(vec![
2543 Ref::keyword("GLOBAL").to_matchable(),
2544 Ref::keyword("LOCAL").to_matchable(),
2545 ])
2546 .config(|this| this.optional())
2547 .to_matchable(),
2548 Ref::new("TemporaryGrammar").optional().to_matchable(),
2549 ])
2550 .to_matchable(),
2551 Ref::keyword("UNLOGGED").to_matchable(),
2552 ])
2553 .config(|this| this.optional())
2554 .to_matchable(),
2555 Ref::keyword("TABLE").to_matchable(),
2556 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
2557 Ref::new("TableReferenceSegment").to_matchable(),
2558 one_of(vec![
2559 Sequence::new(vec![
2560 Bracketed::new(vec![
2561 Delimited::new(vec![
2562 one_of(vec![
2563 Sequence::new(vec![
2564 Ref::new("ColumnReferenceSegment").to_matchable(),
2565 Ref::new("DatatypeSegment").to_matchable(),
2566 AnyNumberOf::new(vec![
2567 one_of(vec![
2568 Ref::new("ColumnConstraintSegment").to_matchable(),
2569 Sequence::new(vec![
2570 Ref::keyword("COLLATE").to_matchable(),
2571 Ref::new("CollationReferenceSegment")
2572 .to_matchable(),
2573 ])
2574 .to_matchable(),
2575 ])
2576 .to_matchable(),
2577 ])
2578 .to_matchable(),
2579 ])
2580 .to_matchable(),
2581 Ref::new("TableConstraintSegment").to_matchable(),
2582 Sequence::new(vec![
2583 Ref::keyword("LIKE").to_matchable(),
2584 Ref::new("TableReferenceSegment").to_matchable(),
2585 AnyNumberOf::new(vec![
2586 Ref::new("LikeOptionSegment").to_matchable(),
2587 ])
2588 .config(|this| this.optional())
2589 .to_matchable(),
2590 ])
2591 .to_matchable(),
2592 ])
2593 .to_matchable(),
2594 ])
2595 .config(|this| this.optional())
2596 .to_matchable(),
2597 ])
2598 .to_matchable(),
2599 Sequence::new(vec![
2600 Ref::keyword("INHERITS").to_matchable(),
2601 Bracketed::new(vec![
2602 Delimited::new(vec![Ref::new("TableReferenceSegment").to_matchable()])
2603 .to_matchable(),
2604 ])
2605 .to_matchable(),
2606 ])
2607 .config(|this| this.optional())
2608 .to_matchable(),
2609 ])
2610 .to_matchable(),
2611 Sequence::new(vec![
2612 Ref::keyword("OF").to_matchable(),
2613 Ref::new("ParameterNameSegment").to_matchable(),
2614 Bracketed::new(vec![
2615 Delimited::new(vec![
2616 Sequence::new(vec![
2617 Ref::new("ColumnReferenceSegment").to_matchable(),
2618 Sequence::new(vec![
2619 Ref::keyword("WITH").to_matchable(),
2620 Ref::keyword("OPTIONS").to_matchable(),
2621 ])
2622 .config(|this| this.optional())
2623 .to_matchable(),
2624 AnyNumberOf::new(vec![
2625 Ref::new("ColumnConstraintSegment").to_matchable(),
2626 ])
2627 .to_matchable(),
2628 ])
2629 .to_matchable(),
2630 Ref::new("TableConstraintSegment").to_matchable(),
2631 ])
2632 .config(|this| this.optional())
2633 .to_matchable(),
2634 ])
2635 .to_matchable(),
2636 ])
2637 .to_matchable(),
2638 Sequence::new(vec![
2639 Ref::keyword("PARTITION").to_matchable(),
2640 Ref::keyword("OF").to_matchable(),
2641 Ref::new("TableReferenceSegment").to_matchable(),
2642 Bracketed::new(vec![
2643 Delimited::new(vec![
2644 Sequence::new(vec![
2645 Ref::new("ColumnReferenceSegment").to_matchable(),
2646 Sequence::new(vec![
2647 Ref::keyword("WITH").to_matchable(),
2648 Ref::keyword("OPTIONS").to_matchable(),
2649 ])
2650 .config(|this| this.optional())
2651 .to_matchable(),
2652 AnyNumberOf::new(vec![
2653 Ref::new("ColumnConstraintSegment").to_matchable(),
2654 ])
2655 .to_matchable(),
2656 ])
2657 .to_matchable(),
2658 Ref::new("TableConstraintSegment").to_matchable(),
2659 ])
2660 .to_matchable(),
2661 ])
2662 .config(|this| this.optional())
2663 .to_matchable(),
2664 one_of(vec![
2665 Sequence::new(vec![
2666 Ref::keyword("FOR").to_matchable(),
2667 Ref::keyword("VALUES").to_matchable(),
2668 Ref::new("PartitionBoundSpecSegment").to_matchable(),
2669 ])
2670 .to_matchable(),
2671 Ref::keyword("DEFAULT").to_matchable(),
2672 ])
2673 .to_matchable(),
2674 ])
2675 .to_matchable(),
2676 ])
2677 .to_matchable(),
2678 AnyNumberOf::new(vec![
2679 Sequence::new(vec![
2680 Ref::keyword("PARTITION").to_matchable(),
2681 Ref::keyword("BY").to_matchable(),
2682 one_of(vec![
2683 Ref::keyword("RANGE").to_matchable(),
2684 Ref::keyword("LIST").to_matchable(),
2685 Ref::keyword("HASH").to_matchable(),
2686 ])
2687 .to_matchable(),
2688 Bracketed::new(vec![
2689 AnyNumberOf::new(vec![
2690 Delimited::new(vec![
2691 Sequence::new(vec![
2692 one_of(vec![
2693 Ref::new("ColumnReferenceSegment").to_matchable(),
2694 Ref::new("FunctionSegment").to_matchable(),
2695 ])
2696 .to_matchable(),
2697 AnyNumberOf::new(vec![
2698 Sequence::new(vec![
2699 Ref::keyword("COLLATE").to_matchable(),
2700 Ref::new("CollationReferenceSegment").to_matchable(),
2701 ])
2702 .config(|this| this.optional())
2703 .to_matchable(),
2704 Ref::new("ParameterNameSegment").optional().to_matchable(),
2705 ])
2706 .to_matchable(),
2707 ])
2708 .to_matchable(),
2709 ])
2710 .to_matchable(),
2711 ])
2712 .to_matchable(),
2713 ])
2714 .to_matchable(),
2715 ])
2716 .to_matchable(),
2717 Sequence::new(vec![
2718 Ref::keyword("USING").to_matchable(),
2719 Ref::new("ParameterNameSegment").to_matchable(),
2720 ])
2721 .to_matchable(),
2722 one_of(vec![
2723 Sequence::new(vec![
2724 Ref::keyword("WITH").to_matchable(),
2725 Ref::new("RelationOptionsSegment").to_matchable(),
2726 ])
2727 .to_matchable(),
2728 Sequence::new(vec![
2729 Ref::keyword("WITHOUT").to_matchable(),
2730 Ref::keyword("OIDS").to_matchable(),
2731 ])
2732 .to_matchable(),
2733 ])
2734 .to_matchable(),
2735 Sequence::new(vec![
2736 Ref::keyword("ON").to_matchable(),
2737 Ref::keyword("COMMIT").to_matchable(),
2738 one_of(vec![
2739 Sequence::new(vec![
2740 Ref::keyword("PRESERVE").to_matchable(),
2741 Ref::keyword("ROWS").to_matchable(),
2742 ])
2743 .to_matchable(),
2744 Sequence::new(vec![
2745 Ref::keyword("DELETE").to_matchable(),
2746 Ref::keyword("ROWS").to_matchable(),
2747 ])
2748 .to_matchable(),
2749 Ref::keyword("DROP").to_matchable(),
2750 ])
2751 .to_matchable(),
2752 ])
2753 .to_matchable(),
2754 Sequence::new(vec![
2755 Ref::keyword("TABLESPACE").to_matchable(),
2756 Ref::new("TablespaceReferenceSegment").to_matchable(),
2757 ])
2758 .to_matchable(),
2759 ])
2760 .to_matchable(),
2761 ])
2762 .to_matchable(),
2763 );
2764
2765 postgres.add([(
2766 "CreateTableAsStatementSegment".into(),
2767 NodeMatcher::new(SyntaxKind::CreateTableAsStatement, |_| {
2768 Sequence::new(vec![
2769 Ref::keyword("CREATE").to_matchable(),
2770 one_of(vec![
2771 Sequence::new(vec![
2772 one_of(vec![
2773 Ref::keyword("GLOBAL").to_matchable(),
2774 Ref::keyword("LOCAL").to_matchable(),
2775 ])
2776 .config(|this| this.optional())
2777 .to_matchable(),
2778 Ref::new("TemporaryGrammar").to_matchable(),
2779 ])
2780 .to_matchable(),
2781 Ref::keyword("UNLOGGED").to_matchable(),
2782 ])
2783 .config(|this| this.optional())
2784 .to_matchable(),
2785 Ref::keyword("TABLE").to_matchable(),
2786 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
2787 Ref::new("TableReferenceSegment").to_matchable(),
2788 AnyNumberOf::new(vec![
2789 Sequence::new(vec![
2790 Bracketed::new(vec![
2791 Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
2792 .to_matchable(),
2793 ])
2794 .to_matchable(),
2795 ])
2796 .config(|this| this.optional())
2797 .to_matchable(),
2798 Sequence::new(vec![
2799 Ref::keyword("USING").to_matchable(),
2800 Ref::new("ParameterNameSegment").to_matchable(),
2801 ])
2802 .config(|this| this.optional())
2803 .to_matchable(),
2804 one_of(vec![
2805 Sequence::new(vec![
2806 Ref::keyword("WITH").to_matchable(),
2807 Bracketed::new(vec![
2808 Delimited::new(vec![
2809 Sequence::new(vec![
2810 Ref::new("ParameterNameSegment").to_matchable(),
2811 Sequence::new(vec![
2812 Ref::new("EqualsSegment").to_matchable(),
2813 one_of(vec![
2814 Ref::new("LiteralGrammar").to_matchable(),
2815 Ref::new("NakedIdentifierSegment").to_matchable(),
2816 ])
2817 .to_matchable(),
2818 ])
2819 .config(|this| this.optional())
2820 .to_matchable(),
2821 ])
2822 .to_matchable(),
2823 ])
2824 .to_matchable(),
2825 ])
2826 .to_matchable(),
2827 ])
2828 .to_matchable(),
2829 Sequence::new(vec![
2830 Ref::keyword("WITHOUT").to_matchable(),
2831 Ref::keyword("OIDS").to_matchable(),
2832 ])
2833 .to_matchable(),
2834 ])
2835 .config(|this| this.optional())
2836 .to_matchable(),
2837 Sequence::new(vec![
2838 Ref::keyword("ON").to_matchable(),
2839 Ref::keyword("COMMIT").to_matchable(),
2840 one_of(vec![
2841 Sequence::new(vec![
2842 Ref::keyword("PRESERVE").to_matchable(),
2843 Ref::keyword("ROWS").to_matchable(),
2844 ])
2845 .to_matchable(),
2846 Sequence::new(vec![
2847 Ref::keyword("DELETE").to_matchable(),
2848 Ref::keyword("ROWS").to_matchable(),
2849 ])
2850 .to_matchable(),
2851 Ref::keyword("DROP").to_matchable(),
2852 ])
2853 .to_matchable(),
2854 ])
2855 .config(|this| this.optional())
2856 .to_matchable(),
2857 Sequence::new(vec![
2858 Ref::keyword("TABLESPACE").to_matchable(),
2859 Ref::new("TablespaceReferenceSegment").to_matchable(),
2860 ])
2861 .config(|this| this.optional())
2862 .to_matchable(),
2863 ])
2864 .to_matchable(),
2865 Ref::keyword("AS").to_matchable(),
2866 one_of(vec![
2867 optionally_bracketed(vec![Ref::new("SelectableGrammar").to_matchable()])
2868 .to_matchable(),
2869 optionally_bracketed(vec![
2870 Sequence::new(vec![
2871 Ref::keyword("TABLE").to_matchable(),
2872 Ref::new("TableReferenceSegment").to_matchable(),
2873 ])
2874 .to_matchable(),
2875 ])
2876 .to_matchable(),
2877 Ref::new("ValuesClauseSegment").to_matchable(),
2878 optionally_bracketed(vec![
2879 Sequence::new(vec![
2880 Ref::keyword("EXECUTE").to_matchable(),
2881 Ref::new("FunctionSegment").to_matchable(),
2882 ])
2883 .to_matchable(),
2884 ])
2885 .to_matchable(),
2886 ])
2887 .to_matchable(),
2888 Ref::new("WithDataClauseSegment").optional().to_matchable(),
2889 ])
2890 .to_matchable()
2891 })
2892 .to_matchable()
2893 .into(),
2894 )]);
2895
2896 postgres.add([(
2899 "AlterAggregateStatementSegment".into(),
2900 Sequence::new(vec![
2901 Ref::keyword("ALTER").to_matchable(),
2902 Ref::keyword("AGGREGATE").to_matchable(),
2903 Ref::new("ObjectReferenceSegment").to_matchable(),
2904 Bracketed::new(vec![
2905 one_of(vec![
2906 Ref::new("FunctionParameterListGrammar").to_matchable(),
2907 Anything::new().to_matchable(),
2908 Ref::new("StarSegment").to_matchable(),
2909 ])
2910 .to_matchable(),
2911 ])
2912 .to_matchable(),
2913 one_of(vec![
2914 Sequence::new(vec![
2915 Ref::keyword("RENAME").to_matchable(),
2916 Ref::keyword("TO").to_matchable(),
2917 Ref::new("FunctionNameSegment").to_matchable(),
2918 ])
2919 .to_matchable(),
2920 Sequence::new(vec![
2921 Ref::keyword("OWNER").to_matchable(),
2922 Ref::keyword("TO").to_matchable(),
2923 one_of(vec![
2924 Ref::keyword("CURRENT_ROLE").to_matchable(),
2925 Ref::keyword("CURRENT_USER").to_matchable(),
2926 Ref::keyword("SESSION_USER").to_matchable(),
2927 Ref::new("RoleReferenceSegment").to_matchable(),
2928 ])
2929 .to_matchable(),
2930 ])
2931 .to_matchable(),
2932 Sequence::new(vec![
2933 Ref::keyword("SET").to_matchable(),
2934 Ref::keyword("SCHEMA").to_matchable(),
2935 Ref::new("SchemaReferenceSegment").to_matchable(),
2936 ])
2937 .to_matchable(),
2938 ])
2939 .to_matchable(),
2940 ])
2941 .to_matchable()
2942 .into(),
2943 )]);
2944
2945 postgres.replace_grammar(
2946 "AlterTableStatementSegment",
2947 Sequence::new(vec![
2948 Ref::keyword("ALTER").to_matchable(),
2949 Ref::keyword("TABLE").to_matchable(),
2950 one_of(vec![
2951 Sequence::new(vec![
2952 Ref::new("IfExistsGrammar").optional().to_matchable(),
2953 Ref::keyword("ONLY").optional().to_matchable(),
2954 Ref::new("TableReferenceSegment").to_matchable(),
2955 Ref::new("StarSegment").optional().to_matchable(),
2956 one_of(vec![
2957 Delimited::new(vec![Ref::new("AlterTableActionSegment").to_matchable()])
2958 .to_matchable(),
2959 Sequence::new(vec![
2960 Ref::keyword("RENAME").to_matchable(),
2961 Ref::keyword("COLUMN").optional().to_matchable(),
2962 Ref::new("ColumnReferenceSegment").to_matchable(),
2963 Ref::keyword("TO").to_matchable(),
2964 Ref::new("ColumnReferenceSegment").to_matchable(),
2965 ])
2966 .to_matchable(),
2967 Sequence::new(vec![
2968 Ref::keyword("RENAME").to_matchable(),
2969 Ref::keyword("CONSTRAINT").to_matchable(),
2970 Ref::new("ParameterNameSegment").to_matchable(),
2971 Ref::keyword("TO").to_matchable(),
2972 Ref::new("ParameterNameSegment").to_matchable(),
2973 ])
2974 .to_matchable(),
2975 ])
2976 .to_matchable(),
2977 ])
2978 .to_matchable(),
2979 Sequence::new(vec![
2980 Ref::new("IfExistsGrammar").optional().to_matchable(),
2981 Ref::new("TableReferenceSegment").to_matchable(),
2982 one_of(vec![
2983 Sequence::new(vec![
2984 Ref::keyword("RENAME").to_matchable(),
2985 Ref::keyword("TO").to_matchable(),
2986 Ref::new("TableReferenceSegment").to_matchable(),
2987 ])
2988 .to_matchable(),
2989 Sequence::new(vec![
2990 Ref::keyword("SET").to_matchable(),
2991 Ref::keyword("SCHEMA").to_matchable(),
2992 Ref::new("SchemaReferenceSegment").to_matchable(),
2993 ])
2994 .to_matchable(),
2995 Sequence::new(vec![
2996 Ref::keyword("ATTACH").to_matchable(),
2997 Ref::keyword("PARTITION").to_matchable(),
2998 Ref::new("ParameterNameSegment").to_matchable(),
2999 one_of(vec![
3000 Sequence::new(vec![
3001 Ref::keyword("FOR").to_matchable(),
3002 Ref::keyword("VALUES").to_matchable(),
3003 Ref::new("PartitionBoundSpecSegment").to_matchable(),
3004 ])
3005 .to_matchable(),
3006 Ref::keyword("DEFAULT").to_matchable(),
3007 ])
3008 .to_matchable(),
3009 ])
3010 .to_matchable(),
3011 Sequence::new(vec![
3012 Ref::keyword("DETACH").to_matchable(),
3013 Ref::keyword("PARTITION").to_matchable(),
3014 Ref::new("ParameterNameSegment").to_matchable(),
3015 Ref::keyword("CONCURRENTLY").optional().to_matchable(),
3016 Ref::keyword("FINALIZE").optional().to_matchable(),
3017 ])
3018 .to_matchable(),
3019 ])
3020 .to_matchable(),
3021 ])
3022 .to_matchable(),
3023 Sequence::new(vec![
3024 Ref::keyword("ALL").to_matchable(),
3025 Ref::keyword("IN").to_matchable(),
3026 Ref::keyword("TABLESPACE").to_matchable(),
3027 Ref::new("TablespaceReferenceSegment").to_matchable(),
3028 Sequence::new(vec![
3029 Ref::keyword("OWNED").to_matchable(),
3030 Ref::keyword("BY").to_matchable(),
3031 Delimited::new(vec![Ref::new("ObjectReferenceSegment").to_matchable()])
3032 .config(|this| this.optional())
3033 .to_matchable(),
3034 ])
3035 .to_matchable(),
3036 Ref::keyword("SET").to_matchable(),
3037 Ref::keyword("TABLESPACE").to_matchable(),
3038 Ref::new("TablespaceReferenceSegment").to_matchable(),
3039 Ref::keyword("NOWAIT").optional().to_matchable(),
3040 ])
3041 .to_matchable(),
3042 ])
3043 .to_matchable(),
3044 ])
3045 .to_matchable(),
3046 );
3047
3048 postgres.add([
3049 (
3050 "AlterTableActionSegment".into(),
3051 NodeMatcher::new(SyntaxKind::AlterTableActionSegment, |_| {
3052 one_of(vec![
3053 Sequence::new(vec![
3054 Ref::keyword("ADD").to_matchable(),
3055 Ref::keyword("COLUMN").optional().to_matchable(),
3056 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
3057 Ref::new("ColumnReferenceSegment").to_matchable(),
3058 Ref::new("DatatypeSegment").to_matchable(),
3059 Sequence::new(vec![
3060 Ref::keyword("COLLATE").to_matchable(),
3061 Ref::new("CollationReferenceSegment").to_matchable(),
3062 ])
3063 .config(|this| this.optional())
3064 .to_matchable(),
3065 AnyNumberOf::new(vec![Ref::new("ColumnConstraintSegment").to_matchable()])
3066 .to_matchable(),
3067 ])
3068 .to_matchable(),
3069 Sequence::new(vec![
3070 Ref::keyword("DROP").to_matchable(),
3071 Ref::keyword("COLUMN").optional().to_matchable(),
3072 Ref::new("IfExistsGrammar").optional().to_matchable(),
3073 Ref::new("ColumnReferenceSegment").to_matchable(),
3074 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
3075 ])
3076 .to_matchable(),
3077 Sequence::new(vec![
3078 Ref::keyword("ALTER").to_matchable(),
3079 Ref::keyword("COLUMN").optional().to_matchable(),
3080 Ref::new("ColumnReferenceSegment").to_matchable(),
3081 one_of(vec![
3082 Sequence::new(vec![
3083 Sequence::new(vec![
3084 Ref::keyword("SET").to_matchable(),
3085 Ref::keyword("DATA").to_matchable(),
3086 ])
3087 .config(|this| this.optional())
3088 .to_matchable(),
3089 Ref::keyword("TYPE").to_matchable(),
3090 Ref::new("DatatypeSegment").to_matchable(),
3091 Sequence::new(vec![
3092 Ref::keyword("COLLATE").to_matchable(),
3093 Ref::new("CollationReferenceSegment").to_matchable(),
3094 ])
3095 .config(|this| this.optional())
3096 .to_matchable(),
3097 Sequence::new(vec![
3098 Ref::keyword("USING").to_matchable(),
3099 one_of(vec![Ref::new("ExpressionSegment").to_matchable()])
3100 .to_matchable(),
3101 ])
3102 .config(|this| this.optional())
3103 .to_matchable(),
3104 ])
3105 .to_matchable(),
3106 Sequence::new(vec![
3107 Ref::keyword("SET").to_matchable(),
3108 Ref::keyword("DEFAULT").to_matchable(),
3109 one_of(vec![
3110 Ref::new("LiteralGrammar").to_matchable(),
3111 Ref::new("FunctionSegment").to_matchable(),
3112 Ref::new("BareFunctionSegment").to_matchable(),
3113 Ref::new("ExpressionSegment").to_matchable(),
3114 ])
3115 .to_matchable(),
3116 ])
3117 .to_matchable(),
3118 Sequence::new(vec![
3119 Ref::keyword("DROP").to_matchable(),
3120 Ref::keyword("DEFAULT").to_matchable(),
3121 ])
3122 .to_matchable(),
3123 Sequence::new(vec![
3124 one_of(vec![
3125 Ref::keyword("SET").to_matchable(),
3126 Ref::keyword("DROP").to_matchable(),
3127 ])
3128 .config(|this| this.optional())
3129 .to_matchable(),
3130 Ref::keyword("NOT").to_matchable(),
3131 Ref::keyword("NULL").to_matchable(),
3132 ])
3133 .to_matchable(),
3134 Sequence::new(vec![
3135 Ref::keyword("DROP").to_matchable(),
3136 Ref::keyword("EXPRESSION").to_matchable(),
3137 Ref::new("IfExistsGrammar").optional().to_matchable(),
3138 ])
3139 .to_matchable(),
3140 Sequence::new(vec![
3141 Ref::keyword("ADD").to_matchable(),
3142 Ref::keyword("GENERATED").to_matchable(),
3143 one_of(vec![
3144 Ref::keyword("ALWAYS").to_matchable(),
3145 Sequence::new(vec![
3146 Ref::keyword("BY").to_matchable(),
3147 Ref::keyword("DEFAULT").to_matchable(),
3148 ])
3149 .to_matchable(),
3150 ])
3151 .to_matchable(),
3152 Ref::keyword("AS").to_matchable(),
3153 Ref::keyword("IDENTITY").to_matchable(),
3154 Bracketed::new(vec![
3155 AnyNumberOf::new(vec![
3156 Ref::new("AlterSequenceOptionsSegment").to_matchable(),
3157 ])
3158 .config(|this| this.optional())
3159 .to_matchable(),
3160 ])
3161 .to_matchable(),
3162 ])
3163 .to_matchable(),
3164 Sequence::new(vec![
3165 one_of(vec![
3166 Sequence::new(vec![
3167 Ref::keyword("SET").to_matchable(),
3168 Ref::keyword("GENERATED").to_matchable(),
3169 one_of(vec![
3170 Ref::keyword("ALWAYS").to_matchable(),
3171 Sequence::new(vec![
3172 Ref::keyword("BY").to_matchable(),
3173 Ref::keyword("DEFAULT").to_matchable(),
3174 ])
3175 .to_matchable(),
3176 ])
3177 .to_matchable(),
3178 ])
3179 .to_matchable(),
3180 Sequence::new(vec![
3181 Ref::keyword("SET").to_matchable(),
3182 Ref::new("AlterSequenceOptionsSegment").to_matchable(),
3183 ])
3184 .to_matchable(),
3185 Sequence::new(vec![
3186 Ref::keyword("RESTART").to_matchable(),
3187 Sequence::new(vec![
3188 Ref::keyword("WITH").to_matchable(),
3189 Ref::new("NumericLiteralSegment").to_matchable(),
3190 ])
3191 .to_matchable(),
3192 ])
3193 .to_matchable(),
3194 ])
3195 .to_matchable(),
3196 ])
3197 .to_matchable(),
3198 Sequence::new(vec![
3199 Ref::keyword("DROP").to_matchable(),
3200 Ref::keyword("IDENTITY").to_matchable(),
3201 Ref::new("IfExistsGrammar").optional().to_matchable(),
3202 ])
3203 .to_matchable(),
3204 Sequence::new(vec![
3205 Ref::keyword("SET").to_matchable(),
3206 Ref::keyword("STATISTICS").to_matchable(),
3207 Ref::new("NumericLiteralSegment").to_matchable(),
3208 ])
3209 .to_matchable(),
3210 Sequence::new(vec![
3211 Ref::keyword("SET").to_matchable(),
3212 Ref::new("RelationOptionsSegment").to_matchable(),
3213 ])
3214 .to_matchable(),
3215 Sequence::new(vec![
3216 Ref::keyword("RESET").to_matchable(),
3217 Ref::new("RelationOptionsSegment").to_matchable(),
3218 ])
3219 .to_matchable(),
3220 Sequence::new(vec![
3221 Ref::keyword("SET").to_matchable(),
3222 Ref::keyword("STORAGE").to_matchable(),
3223 one_of(vec![
3224 Ref::keyword("PLAIN").to_matchable(),
3225 Ref::keyword("EXTERNAL").to_matchable(),
3226 Ref::keyword("EXTENDED").to_matchable(),
3227 Ref::keyword("MAIN").to_matchable(),
3228 ])
3229 .to_matchable(),
3230 ])
3231 .to_matchable(),
3232 ])
3233 .to_matchable(),
3234 ])
3235 .to_matchable(),
3236 Sequence::new(vec![
3237 Ref::keyword("ADD").to_matchable(),
3238 Ref::new("TableConstraintSegment").to_matchable(),
3239 ])
3240 .to_matchable(),
3241 Sequence::new(vec![
3242 Ref::keyword("ADD").to_matchable(),
3243 Ref::new("TableConstraintUsingIndexSegment").to_matchable(),
3244 ])
3245 .to_matchable(),
3246 Sequence::new(vec![
3247 Ref::keyword("ALTER").to_matchable(),
3248 Ref::keyword("CONSTRAINT").to_matchable(),
3249 Ref::new("ParameterNameSegment").to_matchable(),
3250 one_of(vec![
3251 Ref::keyword("DEFERRABLE").to_matchable(),
3252 Sequence::new(vec![
3253 Ref::keyword("NOT").to_matchable(),
3254 Ref::keyword("DEFERRABLE").to_matchable(),
3255 ])
3256 .to_matchable(),
3257 ])
3258 .config(|this| this.optional())
3259 .to_matchable(),
3260 one_of(vec![
3261 Sequence::new(vec![
3262 Ref::keyword("INITIALLY").to_matchable(),
3263 Ref::keyword("DEFERRED").to_matchable(),
3264 ])
3265 .to_matchable(),
3266 Sequence::new(vec![
3267 Ref::keyword("INITIALLY").to_matchable(),
3268 Ref::keyword("IMMEDIATE").to_matchable(),
3269 ])
3270 .to_matchable(),
3271 ])
3272 .config(|this| this.optional())
3273 .to_matchable(),
3274 ])
3275 .to_matchable(),
3276 Sequence::new(vec![
3277 Ref::keyword("VALIDATE").to_matchable(),
3278 Ref::keyword("CONSTRAINT").to_matchable(),
3279 Ref::new("ParameterNameSegment").to_matchable(),
3280 ])
3281 .to_matchable(),
3282 Sequence::new(vec![
3283 Ref::keyword("DROP").to_matchable(),
3284 Ref::keyword("CONSTRAINT").to_matchable(),
3285 Ref::new("IfExistsGrammar").optional().to_matchable(),
3286 Ref::new("ParameterNameSegment").to_matchable(),
3287 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
3288 ])
3289 .to_matchable(),
3290 Sequence::new(vec![
3291 one_of(vec![
3292 Ref::keyword("ENABLE").to_matchable(),
3293 Ref::keyword("DISABLE").to_matchable(),
3294 ])
3295 .to_matchable(),
3296 Ref::keyword("TRIGGER").to_matchable(),
3297 one_of(vec![
3298 Ref::new("ParameterNameSegment").to_matchable(),
3299 Ref::keyword("ALL").to_matchable(),
3300 Ref::keyword("USER").to_matchable(),
3301 ])
3302 .to_matchable(),
3303 ])
3304 .to_matchable(),
3305 Sequence::new(vec![
3306 Ref::keyword("ENABLE").to_matchable(),
3307 one_of(vec![
3308 Ref::keyword("REPLICA").to_matchable(),
3309 Ref::keyword("ALWAYS").to_matchable(),
3310 ])
3311 .to_matchable(),
3312 Ref::keyword("TRIGGER").to_matchable(),
3313 Ref::new("ParameterNameSegment").to_matchable(),
3314 ])
3315 .to_matchable(),
3316 Sequence::new(vec![
3317 one_of(vec![
3318 Ref::keyword("ENABLE").to_matchable(),
3319 Ref::keyword("DISABLE").to_matchable(),
3320 Sequence::new(vec![
3321 Ref::keyword("ENABLE").to_matchable(),
3322 Ref::keyword("REPLICA").to_matchable(),
3323 ])
3324 .to_matchable(),
3325 Sequence::new(vec![
3326 Ref::keyword("ENABLE").to_matchable(),
3327 Ref::keyword("RULE").to_matchable(),
3328 ])
3329 .to_matchable(),
3330 ])
3331 .to_matchable(),
3332 Ref::keyword("RULE").to_matchable(),
3333 Ref::new("ParameterNameSegment").to_matchable(),
3334 ])
3335 .to_matchable(),
3336 Sequence::new(vec![
3337 one_of(vec![
3338 Ref::keyword("DISABLE").to_matchable(),
3339 Ref::keyword("ENABLE").to_matchable(),
3340 Ref::keyword("FORCE").to_matchable(),
3341 Sequence::new(vec![
3342 Ref::keyword("NO").to_matchable(),
3343 Ref::keyword("FORCE").to_matchable(),
3344 ])
3345 .to_matchable(),
3346 ])
3347 .to_matchable(),
3348 Ref::keyword("ROW").to_matchable(),
3349 Ref::keyword("LEVEL").to_matchable(),
3350 Ref::keyword("SECURITY").to_matchable(),
3351 ])
3352 .to_matchable(),
3353 Sequence::new(vec![
3354 Ref::keyword("CLUSTER").to_matchable(),
3355 Ref::keyword("ON").to_matchable(),
3356 Ref::new("ParameterNameSegment").to_matchable(),
3357 ])
3358 .to_matchable(),
3359 Sequence::new(vec![
3360 Ref::keyword("SET").to_matchable(),
3361 Ref::keyword("WITHOUT").to_matchable(),
3362 one_of(vec![
3363 Ref::keyword("CLUSTER").to_matchable(),
3364 Ref::keyword("OIDS").to_matchable(),
3365 ])
3366 .to_matchable(),
3367 ])
3368 .to_matchable(),
3369 Sequence::new(vec![
3370 Ref::keyword("SET").to_matchable(),
3371 Ref::keyword("TABLESPACE").to_matchable(),
3372 Ref::new("TablespaceReferenceSegment").to_matchable(),
3373 ])
3374 .to_matchable(),
3375 Sequence::new(vec![
3376 Ref::keyword("SET").to_matchable(),
3377 one_of(vec![
3378 Ref::keyword("LOGGED").to_matchable(),
3379 Ref::keyword("UNLOGGED").to_matchable(),
3380 ])
3381 .to_matchable(),
3382 ])
3383 .to_matchable(),
3384 Sequence::new(vec![
3385 Ref::keyword("SET").to_matchable(),
3386 Ref::new("RelationOptionsSegment").to_matchable(),
3387 ])
3388 .to_matchable(),
3389 Sequence::new(vec![
3390 Ref::keyword("RESET").to_matchable(),
3391 Ref::new("RelationOptionsSegment").to_matchable(),
3392 ])
3393 .to_matchable(),
3394 Sequence::new(vec![
3395 Ref::keyword("NO").optional().to_matchable(),
3396 Ref::keyword("INHERIT").to_matchable(),
3397 Ref::new("TableReferenceSegment").to_matchable(),
3398 ])
3399 .to_matchable(),
3400 Sequence::new(vec![
3401 Ref::keyword("OF").to_matchable(),
3402 Ref::new("ParameterNameSegment").to_matchable(),
3403 ])
3404 .to_matchable(),
3405 Sequence::new(vec![
3406 Ref::keyword("NOT").to_matchable(),
3407 Ref::keyword("OF").to_matchable(),
3408 ])
3409 .to_matchable(),
3410 Sequence::new(vec![
3411 Ref::keyword("OWNER").to_matchable(),
3412 Ref::keyword("TO").to_matchable(),
3413 one_of(vec![
3414 Ref::new("ParameterNameSegment").to_matchable(),
3415 Ref::keyword("CURRENT_ROLE").to_matchable(),
3416 Ref::keyword("CURRENT_USER").to_matchable(),
3417 Ref::keyword("SESSION_USER").to_matchable(),
3418 ])
3419 .to_matchable(),
3420 ])
3421 .to_matchable(),
3422 Sequence::new(vec![
3423 Ref::keyword("REPLICA").to_matchable(),
3424 Ref::keyword("IDENTITY").to_matchable(),
3425 one_of(vec![
3426 Ref::keyword("DEFAULT").to_matchable(),
3427 Sequence::new(vec![
3428 Ref::keyword("USING").to_matchable(),
3429 Ref::keyword("INDEX").to_matchable(),
3430 Ref::new("IndexReferenceSegment").to_matchable(),
3431 ])
3432 .to_matchable(),
3433 Ref::keyword("FULL").to_matchable(),
3434 Ref::keyword("NOTHING").to_matchable(),
3435 ])
3436 .to_matchable(),
3437 ])
3438 .to_matchable(),
3439 ])
3440 .to_matchable()
3441 })
3442 .to_matchable()
3443 .into(),
3444 ),
3445 (
3446 "VersionIdentifierSegment".into(),
3447 NodeMatcher::new(SyntaxKind::VersionIdentifier, |_| {
3448 one_of(vec![
3449 Ref::new("QuotedLiteralSegment").to_matchable(),
3450 Ref::new("NakedIdentifierSegment").to_matchable(),
3451 ])
3452 .to_matchable()
3453 })
3454 .to_matchable()
3455 .into(),
3456 ),
3457 (
3458 "CreateExtensionStatementSegment".into(),
3459 NodeMatcher::new(SyntaxKind::CreateExtensionStatement, |_| {
3460 Sequence::new(vec![
3461 Ref::keyword("CREATE").to_matchable(),
3462 Ref::keyword("EXTENSION").to_matchable(),
3463 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
3464 Ref::new("ExtensionReferenceSegment").to_matchable(),
3465 Ref::keyword("WITH").optional().to_matchable(),
3466 Sequence::new(vec![
3467 Ref::keyword("SCHEMA").to_matchable(),
3468 Ref::new("SchemaReferenceSegment").to_matchable(),
3469 ])
3470 .config(|this| this.optional())
3471 .to_matchable(),
3472 Sequence::new(vec![
3473 Ref::keyword("VERSION").to_matchable(),
3474 Ref::new("VersionIdentifierSegment").to_matchable(),
3475 ])
3476 .config(|this| this.optional())
3477 .to_matchable(),
3478 Sequence::new(vec![
3479 Ref::keyword("FROM").to_matchable(),
3480 Ref::new("VersionIdentifierSegment").to_matchable(),
3481 ])
3482 .config(|this| this.optional())
3483 .to_matchable(),
3484 ])
3485 .to_matchable()
3486 })
3487 .to_matchable()
3488 .into(),
3489 ),
3490 (
3491 "DropExtensionStatementSegment".into(),
3492 NodeMatcher::new(SyntaxKind::DropExtensionStatement, |_| {
3493 Sequence::new(vec![
3494 Ref::keyword("DROP").to_matchable(),
3495 Ref::keyword("EXTENSION").to_matchable(),
3496 Ref::new("IfExistsGrammar").optional().to_matchable(),
3497 Ref::new("ExtensionReferenceSegment").to_matchable(),
3498 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
3499 ])
3500 .to_matchable()
3501 })
3502 .to_matchable()
3503 .into(),
3504 ),
3505 (
3506 "PublicationReferenceSegment".into(),
3507 NodeMatcher::new(SyntaxKind::PublicationReference, |_| {
3508 Ref::new("SingleIdentifierGrammar").to_matchable()
3509 })
3510 .to_matchable()
3511 .into(),
3512 ),
3513 (
3514 "PublicationTableSegment".into(),
3515 NodeMatcher::new(SyntaxKind::PublicationTable, |_| {
3516 Sequence::new(vec![
3517 Ref::new("ExtendedTableReferenceGrammar").to_matchable(),
3518 Ref::new("BracketedColumnReferenceListGrammar")
3519 .optional()
3520 .to_matchable(),
3521 Sequence::new(vec![
3522 Ref::keyword("WHERE").to_matchable(),
3523 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
3524 .to_matchable(),
3525 ])
3526 .config(|this| this.optional())
3527 .to_matchable(),
3528 ])
3529 .to_matchable()
3530 })
3531 .to_matchable()
3532 .into(),
3533 ),
3534 (
3535 "PublicationObjectsSegment".into(),
3536 NodeMatcher::new(SyntaxKind::PublicationObjects, |_| {
3537 one_of(vec![
3538 Sequence::new(vec![
3539 Ref::keyword("TABLE").to_matchable(),
3540 Delimited::new(vec![Ref::new("PublicationTableSegment").to_matchable()])
3541 .config(|this| {
3542 this.terminators = vec![
3543 Sequence::new(vec![
3544 Ref::new("CommaSegment").to_matchable(),
3545 one_of(vec![
3546 Ref::keyword("TABLE").to_matchable(),
3547 Ref::keyword("TABLES").to_matchable(),
3548 ])
3549 .to_matchable(),
3550 ])
3551 .to_matchable(),
3552 ];
3553 })
3554 .to_matchable(),
3555 ])
3556 .to_matchable(),
3557 Sequence::new(vec![
3558 Ref::keyword("TABLES").to_matchable(),
3559 Ref::keyword("IN").to_matchable(),
3560 Ref::keyword("SCHEMA").to_matchable(),
3561 Delimited::new(vec![
3562 one_of(vec![
3563 Ref::new("SchemaReferenceSegment").to_matchable(),
3564 Ref::keyword("CURRENT_SCHEMA").to_matchable(),
3565 ])
3566 .to_matchable(),
3567 ])
3568 .config(|this| {
3569 this.terminators = vec![
3570 Sequence::new(vec![
3571 Ref::new("CommaSegment").to_matchable(),
3572 one_of(vec![
3573 Ref::keyword("TABLE").to_matchable(),
3574 Ref::keyword("TABLES").to_matchable(),
3575 ])
3576 .to_matchable(),
3577 ])
3578 .to_matchable(),
3579 ];
3580 })
3581 .to_matchable(),
3582 ])
3583 .to_matchable(),
3584 ])
3585 .to_matchable()
3586 })
3587 .to_matchable()
3588 .into(),
3589 ),
3590 (
3591 "CreatePublicationStatementSegment".into(),
3592 NodeMatcher::new(SyntaxKind::CreatePublicationStatement, |_| {
3593 Sequence::new(vec![
3594 Ref::keyword("CREATE").to_matchable(),
3595 Ref::keyword("PUBLICATION").to_matchable(),
3596 Ref::new("PublicationReferenceSegment").to_matchable(),
3597 one_of(vec![
3598 Sequence::new(vec![
3599 Ref::keyword("FOR").to_matchable(),
3600 Ref::keyword("ALL").to_matchable(),
3601 Ref::keyword("TABLES").to_matchable(),
3602 ])
3603 .to_matchable(),
3604 Sequence::new(vec![
3605 Ref::keyword("FOR").to_matchable(),
3606 Delimited::new(vec![
3607 Ref::new("PublicationObjectsSegment").to_matchable(),
3608 ])
3609 .to_matchable(),
3610 ])
3611 .to_matchable(),
3612 ])
3613 .config(|this| this.optional())
3614 .to_matchable(),
3615 Sequence::new(vec![
3616 Ref::keyword("WITH").to_matchable(),
3617 Ref::new("DefinitionParametersSegment").to_matchable(),
3618 ])
3619 .config(|this| this.optional())
3620 .to_matchable(),
3621 ])
3622 .to_matchable()
3623 })
3624 .to_matchable()
3625 .into(),
3626 ),
3627 (
3628 "AlterPublicationStatementSegment".into(),
3629 NodeMatcher::new(SyntaxKind::AlterPublicationStatement, |_| {
3630 Sequence::new(vec![
3631 Ref::keyword("ALTER").to_matchable(),
3632 Ref::keyword("PUBLICATION").to_matchable(),
3633 Ref::new("PublicationReferenceSegment").to_matchable(),
3634 one_of(vec![
3635 Sequence::new(vec![
3636 Ref::keyword("SET").to_matchable(),
3637 Ref::new("DefinitionParametersSegment").to_matchable(),
3638 ])
3639 .to_matchable(),
3640 Sequence::new(vec![
3641 Ref::keyword("ADD").to_matchable(),
3642 Delimited::new(vec![
3643 Ref::new("PublicationObjectsSegment").to_matchable(),
3644 ])
3645 .to_matchable(),
3646 ])
3647 .to_matchable(),
3648 Sequence::new(vec![
3649 Ref::keyword("SET").to_matchable(),
3650 Delimited::new(vec![
3651 Ref::new("PublicationObjectsSegment").to_matchable(),
3652 ])
3653 .to_matchable(),
3654 ])
3655 .to_matchable(),
3656 Sequence::new(vec![
3657 Ref::keyword("DROP").to_matchable(),
3658 Delimited::new(vec![
3659 Ref::new("PublicationObjectsSegment").to_matchable(),
3660 ])
3661 .to_matchable(),
3662 ])
3663 .to_matchable(),
3664 Sequence::new(vec![
3665 Ref::keyword("RENAME").to_matchable(),
3666 Ref::keyword("TO").to_matchable(),
3667 Ref::new("PublicationReferenceSegment").to_matchable(),
3668 ])
3669 .to_matchable(),
3670 Sequence::new(vec![
3671 Ref::keyword("OWNER").to_matchable(),
3672 Ref::keyword("TO").to_matchable(),
3673 one_of(vec![
3674 Ref::keyword("CURRENT_ROLE").to_matchable(),
3675 Ref::keyword("CURRENT_USER").to_matchable(),
3676 Ref::keyword("SESSION_USER").to_matchable(),
3677 Ref::new("RoleReferenceSegment").to_matchable(),
3678 ])
3679 .to_matchable(),
3680 ])
3681 .to_matchable(),
3682 ])
3683 .to_matchable(),
3684 ])
3685 .to_matchable()
3686 })
3687 .to_matchable()
3688 .into(),
3689 ),
3690 ]);
3691
3692 postgres.add([
3693 (
3694 "DropPublicationStatementSegment".into(),
3695 NodeMatcher::new(SyntaxKind::DropPublicationStatement, |_| {
3696 Sequence::new(vec![
3697 Ref::keyword("DROP").to_matchable(),
3698 Ref::keyword("PUBLICATION").to_matchable(),
3699 Ref::new("IfExistsGrammar").optional().to_matchable(),
3700 Delimited::new(vec![Ref::new("PublicationReferenceSegment").to_matchable()])
3701 .to_matchable(),
3702 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
3703 ])
3704 .to_matchable()
3705 })
3706 .to_matchable()
3707 .into(),
3708 ),
3709 (
3710 "CreateMaterializedViewStatementSegment".into(),
3711 NodeMatcher::new(SyntaxKind::CreateMaterializedViewStatement, |_| {
3712 Sequence::new(vec![
3713 Ref::keyword("CREATE").to_matchable(),
3714 Ref::new("OrReplaceGrammar").optional().to_matchable(),
3715 Ref::keyword("MATERIALIZED").to_matchable(),
3716 Ref::keyword("VIEW").to_matchable(),
3717 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
3718 Ref::new("TableReferenceSegment").to_matchable(),
3719 Ref::new("BracketedColumnReferenceListGrammar")
3720 .optional()
3721 .to_matchable(),
3722 Sequence::new(vec![
3723 Ref::keyword("USING").to_matchable(),
3724 Ref::new("ParameterNameSegment").to_matchable(),
3725 ])
3726 .config(|this| this.optional())
3727 .to_matchable(),
3728 Sequence::new(vec![
3729 Ref::keyword("WITH").to_matchable(),
3730 Ref::new("RelationOptionsSegment").to_matchable(),
3731 ])
3732 .config(|this| this.optional())
3733 .to_matchable(),
3734 Sequence::new(vec![
3735 Ref::keyword("TABLESPACE").to_matchable(),
3736 Ref::new("TablespaceReferenceSegment").to_matchable(),
3737 ])
3738 .config(|this| this.optional())
3739 .to_matchable(),
3740 Ref::keyword("AS").to_matchable(),
3741 one_of(vec![
3742 optionally_bracketed(vec![Ref::new("SelectableGrammar").to_matchable()])
3743 .to_matchable(),
3744 optionally_bracketed(vec![
3745 Sequence::new(vec![
3746 Ref::keyword("TABLE").to_matchable(),
3747 Ref::new("TableReferenceSegment").to_matchable(),
3748 ])
3749 .to_matchable(),
3750 ])
3751 .to_matchable(),
3752 Ref::new("ValuesClauseSegment").to_matchable(),
3753 optionally_bracketed(vec![
3754 Sequence::new(vec![
3755 Ref::keyword("EXECUTE").to_matchable(),
3756 Ref::new("FunctionSegment").to_matchable(),
3757 ])
3758 .to_matchable(),
3759 ])
3760 .to_matchable(),
3761 ])
3762 .to_matchable(),
3763 Ref::new("WithDataClauseSegment").optional().to_matchable(),
3764 ])
3765 .to_matchable()
3766 })
3767 .to_matchable()
3768 .into(),
3769 ),
3770 (
3771 "AlterMaterializedViewStatementSegment".into(),
3772 NodeMatcher::new(SyntaxKind::AlterMaterializedViewStatement, |_| {
3773 Sequence::new(vec![
3774 Ref::keyword("ALTER").to_matchable(),
3775 Ref::keyword("MATERIALIZED").to_matchable(),
3776 Ref::keyword("VIEW").to_matchable(),
3777 one_of(vec![
3778 Sequence::new(vec![
3779 Ref::new("IfExistsGrammar").optional().to_matchable(),
3780 Ref::new("TableReferenceSegment").to_matchable(),
3781 one_of(vec![
3782 Delimited::new(vec![
3783 Ref::new("AlterMaterializedViewActionSegment").to_matchable(),
3784 ])
3785 .to_matchable(),
3786 Sequence::new(vec![
3787 Ref::keyword("RENAME").to_matchable(),
3788 Sequence::new(vec![Ref::keyword("COLUMN").to_matchable()])
3789 .config(|this| this.optional())
3790 .to_matchable(),
3791 Ref::new("ColumnReferenceSegment").to_matchable(),
3792 Ref::keyword("TO").to_matchable(),
3793 Ref::new("ColumnReferenceSegment").to_matchable(),
3794 ])
3795 .to_matchable(),
3796 Sequence::new(vec![
3797 Ref::keyword("RENAME").to_matchable(),
3798 Ref::keyword("TO").to_matchable(),
3799 Ref::new("TableReferenceSegment").to_matchable(),
3800 ])
3801 .to_matchable(),
3802 Sequence::new(vec![
3803 Ref::keyword("SET").to_matchable(),
3804 Ref::keyword("SCHEMA").to_matchable(),
3805 Ref::new("SchemaReferenceSegment").to_matchable(),
3806 ])
3807 .to_matchable(),
3808 ])
3809 .to_matchable(),
3810 ])
3811 .to_matchable(),
3812 Sequence::new(vec![
3813 Ref::new("TableReferenceSegment").to_matchable(),
3814 Ref::keyword("NO").optional().to_matchable(),
3815 Ref::keyword("DEPENDS").to_matchable(),
3816 Ref::keyword("ON").to_matchable(),
3817 Ref::keyword("EXTENSION").to_matchable(),
3818 Ref::new("ExtensionReferenceSegment").to_matchable(),
3819 ])
3820 .to_matchable(),
3821 Sequence::new(vec![
3822 Ref::keyword("ALL").to_matchable(),
3823 Ref::keyword("IN").to_matchable(),
3824 Ref::keyword("TABLESPACE").to_matchable(),
3825 Ref::new("TablespaceReferenceSegment").to_matchable(),
3826 Sequence::new(vec![
3827 Ref::keyword("OWNED").to_matchable(),
3828 Ref::keyword("BY").to_matchable(),
3829 Delimited::new(vec![
3830 Ref::new("ObjectReferenceSegment").to_matchable(),
3831 ])
3832 .to_matchable(),
3833 ])
3834 .config(|this| this.optional())
3835 .to_matchable(),
3836 Ref::keyword("SET").to_matchable(),
3837 Ref::keyword("TABLESPACE").to_matchable(),
3838 Ref::new("TablespaceReferenceSegment").to_matchable(),
3839 Sequence::new(vec![Ref::keyword("NOWAIT").to_matchable()])
3840 .config(|this| this.optional())
3841 .to_matchable(),
3842 ])
3843 .to_matchable(),
3844 ])
3845 .to_matchable(),
3846 ])
3847 .to_matchable()
3848 })
3849 .to_matchable()
3850 .into(),
3851 ),
3852 (
3853 "AlterMaterializedViewActionSegment".into(),
3854 NodeMatcher::new(SyntaxKind::AlterMaterializedViewActionSegment, |_| {
3855 one_of(vec![
3856 Sequence::new(vec![
3857 Ref::keyword("ALTER").to_matchable(),
3858 Ref::keyword("COLUMN").optional().to_matchable(),
3859 Ref::new("ColumnReferenceSegment").to_matchable(),
3860 one_of(vec![
3861 Sequence::new(vec![
3862 Ref::keyword("SET").to_matchable(),
3863 Ref::keyword("STATISTICS").to_matchable(),
3864 Ref::new("NumericLiteralSegment").to_matchable(),
3865 ])
3866 .to_matchable(),
3867 Sequence::new(vec![
3868 Ref::keyword("SET").to_matchable(),
3869 Bracketed::new(vec![
3870 Delimited::new(vec![
3871 Sequence::new(vec![
3872 Ref::new("ParameterNameSegment").to_matchable(),
3873 Ref::new("EqualsSegment").to_matchable(),
3874 Ref::new("LiteralGrammar").to_matchable(),
3875 ])
3876 .to_matchable(),
3877 ])
3878 .to_matchable(),
3879 ])
3880 .to_matchable(),
3881 ])
3882 .to_matchable(),
3883 Sequence::new(vec![
3884 Ref::keyword("RESET").to_matchable(),
3885 Bracketed::new(vec![
3886 Delimited::new(vec![
3887 Ref::new("ParameterNameSegment").to_matchable(),
3888 ])
3889 .to_matchable(),
3890 ])
3891 .to_matchable(),
3892 ])
3893 .to_matchable(),
3894 Sequence::new(vec![
3895 Ref::keyword("SET").to_matchable(),
3896 Ref::keyword("STORAGE").to_matchable(),
3897 one_of(vec![
3898 Ref::keyword("PLAIN").to_matchable(),
3899 Ref::keyword("EXTERNAL").to_matchable(),
3900 Ref::keyword("EXTENDED").to_matchable(),
3901 Ref::keyword("MAIN").to_matchable(),
3902 ])
3903 .to_matchable(),
3904 ])
3905 .to_matchable(),
3906 Sequence::new(vec![
3907 Ref::keyword("SET").to_matchable(),
3908 Ref::keyword("COMPRESSION").to_matchable(),
3909 Ref::new("ParameterNameSegment").to_matchable(),
3910 ])
3911 .to_matchable(),
3912 ])
3913 .to_matchable(),
3914 ])
3915 .to_matchable(),
3916 Sequence::new(vec![
3917 Ref::keyword("CLUSTER").to_matchable(),
3918 Ref::keyword("ON").to_matchable(),
3919 Ref::new("ParameterNameSegment").to_matchable(),
3920 ])
3921 .to_matchable(),
3922 Sequence::new(vec![
3923 Ref::keyword("SET").to_matchable(),
3924 Ref::keyword("WITHOUT").to_matchable(),
3925 Ref::keyword("CLUSTER").to_matchable(),
3926 ])
3927 .to_matchable(),
3928 Sequence::new(vec![
3929 Ref::keyword("SET").to_matchable(),
3930 Bracketed::new(vec![
3931 Delimited::new(vec![
3932 Sequence::new(vec![
3933 Ref::new("ParameterNameSegment").to_matchable(),
3934 Sequence::new(vec![
3935 Ref::new("EqualsSegment").to_matchable(),
3936 Ref::new("LiteralGrammar").to_matchable(),
3937 ])
3938 .config(|this| this.optional())
3939 .to_matchable(),
3940 ])
3941 .to_matchable(),
3942 ])
3943 .to_matchable(),
3944 ])
3945 .to_matchable(),
3946 ])
3947 .to_matchable(),
3948 Sequence::new(vec![
3949 Ref::keyword("RESET").to_matchable(),
3950 Bracketed::new(vec![
3951 Delimited::new(vec![Ref::new("ParameterNameSegment").to_matchable()])
3952 .to_matchable(),
3953 ])
3954 .to_matchable(),
3955 ])
3956 .to_matchable(),
3957 Sequence::new(vec![
3958 Ref::keyword("OWNER").to_matchable(),
3959 Ref::keyword("TO").to_matchable(),
3960 one_of(vec![
3961 Ref::new("ObjectReferenceSegment").to_matchable(),
3962 Ref::keyword("CURRENT_ROLE").to_matchable(),
3963 Ref::keyword("CURRENT_USER").to_matchable(),
3964 Ref::keyword("SESSION_USER").to_matchable(),
3965 ])
3966 .to_matchable(),
3967 ])
3968 .to_matchable(),
3969 ])
3970 .to_matchable()
3971 })
3972 .to_matchable()
3973 .into(),
3974 ),
3975 (
3976 "RefreshMaterializedViewStatementSegment".into(),
3977 NodeMatcher::new(SyntaxKind::RefreshMaterializedViewStatement, |_| {
3978 Sequence::new(vec![
3979 Ref::keyword("REFRESH").to_matchable(),
3980 Ref::keyword("MATERIALIZED").to_matchable(),
3981 Ref::keyword("VIEW").to_matchable(),
3982 Ref::keyword("CONCURRENTLY").optional().to_matchable(),
3983 Ref::new("TableReferenceSegment").to_matchable(),
3984 Ref::new("WithDataClauseSegment").optional().to_matchable(),
3985 ])
3986 .to_matchable()
3987 })
3988 .to_matchable()
3989 .into(),
3990 ),
3991 (
3992 "DropMaterializedViewStatementSegment".into(),
3993 NodeMatcher::new(SyntaxKind::DropMaterializedViewStatement, |_| {
3994 Sequence::new(vec![
3995 Ref::keyword("DROP").to_matchable(),
3996 Ref::keyword("MATERIALIZED").to_matchable(),
3997 Ref::keyword("VIEW").to_matchable(),
3998 Ref::new("IfExistsGrammar").optional().to_matchable(),
3999 Delimited::new(vec![Ref::new("TableReferenceSegment").to_matchable()])
4000 .to_matchable(),
4001 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
4002 ])
4003 .to_matchable()
4004 })
4005 .to_matchable()
4006 .into(),
4007 ),
4008 (
4009 "WithCheckOptionSegment".into(),
4010 NodeMatcher::new(SyntaxKind::WithCheckOption, |_| {
4011 Sequence::new(vec![
4012 Ref::keyword("WITH").to_matchable(),
4013 one_of(vec![
4014 Ref::keyword("CASCADED").to_matchable(),
4015 Ref::keyword("LOCAL").to_matchable(),
4016 ])
4017 .to_matchable(),
4018 Ref::keyword("CHECK").to_matchable(),
4019 Ref::keyword("OPTION").to_matchable(),
4020 ])
4021 .to_matchable()
4022 })
4023 .to_matchable()
4024 .into(),
4025 ),
4026 (
4027 "AlterPolicyStatementSegment".into(),
4028 NodeMatcher::new(SyntaxKind::AlterPolicyStatement, |_| {
4029 Sequence::new(vec![
4030 Ref::keyword("ALTER").to_matchable(),
4031 Ref::keyword("POLICY").to_matchable(),
4032 Ref::new("ObjectReferenceSegment").to_matchable(),
4033 Ref::keyword("ON").to_matchable(),
4034 Ref::new("TableReferenceSegment").to_matchable(),
4035 one_of(vec![
4036 Sequence::new(vec![
4037 Ref::keyword("RENAME").to_matchable(),
4038 Ref::keyword("TO").to_matchable(),
4039 Ref::new("ObjectReferenceSegment").to_matchable(),
4040 ])
4041 .to_matchable(),
4042 Sequence::new(vec![
4043 Ref::keyword("TO").to_matchable(),
4044 Delimited::new(vec![
4045 one_of(vec![
4046 Ref::new("RoleReferenceSegment").to_matchable(),
4047 Ref::keyword("PUBLIC").to_matchable(),
4048 Ref::keyword("CURRENT_ROLE").to_matchable(),
4049 Ref::keyword("CURRENT_USER").to_matchable(),
4050 Ref::keyword("SESSION_USER").to_matchable(),
4051 ])
4052 .to_matchable(),
4053 ])
4054 .to_matchable(),
4055 ])
4056 .config(|this| this.optional())
4057 .to_matchable(),
4058 Sequence::new(vec![
4059 Ref::keyword("USING").to_matchable(),
4060 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
4061 .to_matchable(),
4062 ])
4063 .config(|this| this.optional())
4064 .to_matchable(),
4065 Sequence::new(vec![
4066 Ref::keyword("WITH").to_matchable(),
4067 Ref::keyword("CHECK").to_matchable(),
4068 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
4069 .to_matchable(),
4070 ])
4071 .config(|this| this.optional())
4072 .to_matchable(),
4073 ])
4074 .to_matchable(),
4075 ])
4076 .to_matchable()
4077 })
4078 .to_matchable()
4079 .into(),
4080 ),
4081 ]);
4082
4083 postgres.add([
4084 (
4085 "CreateViewStatementSegment".into(),
4086 NodeMatcher::new(SyntaxKind::CreateViewStatement, |_| {
4087 Sequence::new(vec![
4088 Ref::keyword("CREATE").to_matchable(),
4089 Ref::new("OrReplaceGrammar").optional().to_matchable(),
4090 Ref::new("TemporaryGrammar").optional().to_matchable(),
4091 Ref::keyword("RECURSIVE").optional().to_matchable(),
4092 Ref::keyword("VIEW").to_matchable(),
4093 Ref::new("TableReferenceSegment").to_matchable(),
4094 Ref::new("BracketedColumnReferenceListGrammar")
4095 .optional()
4096 .to_matchable(),
4097 Sequence::new(vec![
4098 Ref::keyword("WITH").to_matchable(),
4099 Ref::new("RelationOptionsSegment").to_matchable(),
4100 ])
4101 .config(|this| this.optional())
4102 .to_matchable(),
4103 Ref::keyword("AS").to_matchable(),
4104 one_of(vec![
4105 optionally_bracketed(vec![Ref::new("SelectableGrammar").to_matchable()])
4106 .to_matchable(),
4107 Ref::new("ValuesClauseSegment").to_matchable(),
4108 ])
4109 .to_matchable(),
4110 Ref::new("WithCheckOptionSegment").optional().to_matchable(),
4111 ])
4112 .to_matchable()
4113 })
4114 .to_matchable()
4115 .into(),
4116 ),
4117 (
4118 "AlterViewStatementSegment".into(),
4119 NodeMatcher::new(SyntaxKind::AlterViewStatement, |_| {
4120 Sequence::new(vec![
4121 Ref::keyword("ALTER").to_matchable(),
4122 Ref::keyword("VIEW").to_matchable(),
4123 Ref::new("IfExistsGrammar").optional().to_matchable(),
4124 Ref::new("TableReferenceSegment").to_matchable(),
4125 one_of(vec![
4126 Sequence::new(vec![
4127 Ref::keyword("ALTER").to_matchable(),
4128 Ref::keyword("COLUMN").optional().to_matchable(),
4129 Ref::new("ColumnReferenceSegment").to_matchable(),
4130 one_of(vec![
4131 Sequence::new(vec![
4132 Ref::keyword("SET").to_matchable(),
4133 Ref::keyword("DEFAULT").to_matchable(),
4134 one_of(vec![
4135 Ref::new("LiteralGrammar").to_matchable(),
4136 Ref::new("FunctionSegment").to_matchable(),
4137 Ref::new("BareFunctionSegment").to_matchable(),
4138 Ref::new("ExpressionSegment").to_matchable(),
4139 ])
4140 .to_matchable(),
4141 ])
4142 .to_matchable(),
4143 Sequence::new(vec![
4144 Ref::keyword("DROP").to_matchable(),
4145 Ref::keyword("DEFAULT").to_matchable(),
4146 ])
4147 .to_matchable(),
4148 ])
4149 .to_matchable(),
4150 ])
4151 .to_matchable(),
4152 Sequence::new(vec![
4153 Ref::keyword("OWNER").to_matchable(),
4154 Ref::keyword("TO").to_matchable(),
4155 one_of(vec![
4156 Ref::new("ObjectReferenceSegment").to_matchable(),
4157 Ref::keyword("CURRENT_ROLE").to_matchable(),
4158 Ref::keyword("CURRENT_USER").to_matchable(),
4159 Ref::keyword("SESSION_USER").to_matchable(),
4160 ])
4161 .to_matchable(),
4162 ])
4163 .to_matchable(),
4164 Sequence::new(vec![
4165 Ref::keyword("RENAME").to_matchable(),
4166 Ref::keyword("COLUMN").optional().to_matchable(),
4167 Ref::new("ColumnReferenceSegment").to_matchable(),
4168 Ref::keyword("TO").to_matchable(),
4169 Ref::new("ColumnReferenceSegment").to_matchable(),
4170 ])
4171 .to_matchable(),
4172 Sequence::new(vec![
4173 Ref::keyword("RENAME").to_matchable(),
4174 Ref::keyword("TO").to_matchable(),
4175 Ref::new("TableReferenceSegment").to_matchable(),
4176 ])
4177 .to_matchable(),
4178 Sequence::new(vec![
4179 Ref::keyword("SET").to_matchable(),
4180 Ref::keyword("SCHEMA").to_matchable(),
4181 Ref::new("SchemaReferenceSegment").to_matchable(),
4182 ])
4183 .to_matchable(),
4184 Sequence::new(vec![
4185 Ref::keyword("SET").to_matchable(),
4186 Bracketed::new(vec![
4187 Delimited::new(vec![
4188 Sequence::new(vec![
4189 Ref::new("ParameterNameSegment").to_matchable(),
4190 Sequence::new(vec![
4191 Ref::new("EqualsSegment").to_matchable(),
4192 Ref::new("LiteralGrammar").to_matchable(),
4193 ])
4194 .config(|this| this.optional())
4195 .to_matchable(),
4196 ])
4197 .to_matchable(),
4198 ])
4199 .to_matchable(),
4200 ])
4201 .to_matchable(),
4202 ])
4203 .to_matchable(),
4204 Sequence::new(vec![
4205 Ref::keyword("RESET").to_matchable(),
4206 Bracketed::new(vec![
4207 Delimited::new(vec![
4208 Ref::new("ParameterNameSegment").to_matchable(),
4209 ])
4210 .to_matchable(),
4211 ])
4212 .to_matchable(),
4213 ])
4214 .to_matchable(),
4215 ])
4216 .to_matchable(),
4217 ])
4218 .to_matchable()
4219 })
4220 .to_matchable()
4221 .into(),
4222 ),
4223 ]);
4224
4225 postgres.add([
4226 (
4227 "DropViewStatementSegment".into(),
4228 NodeMatcher::new(SyntaxKind::DropViewStatement, |_| {
4229 Sequence::new(vec![
4230 Ref::keyword("DROP").to_matchable(),
4231 Ref::keyword("VIEW").to_matchable(),
4232 Ref::new("IfExistsGrammar").optional().to_matchable(),
4233 Delimited::new(vec![Ref::new("TableReferenceSegment").to_matchable()])
4234 .to_matchable(),
4235 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
4236 ])
4237 .to_matchable()
4238 })
4239 .to_matchable()
4240 .into(),
4241 ),
4242 (
4243 "CreateDatabaseStatementSegment".into(),
4244 NodeMatcher::new(SyntaxKind::CreateDatabaseStatement, |_| {
4245 Sequence::new(vec![
4246 Ref::keyword("CREATE").to_matchable(),
4247 Ref::keyword("DATABASE").to_matchable(),
4248 Ref::new("DatabaseReferenceSegment").to_matchable(),
4249 Ref::keyword("WITH").optional().to_matchable(),
4250 AnyNumberOf::new(vec![
4251 Sequence::new(vec![
4252 Ref::keyword("OWNER").to_matchable(),
4253 Ref::new("EqualsSegment").optional().to_matchable(),
4254 Ref::new("ObjectReferenceSegment").to_matchable(),
4255 ])
4256 .to_matchable(),
4257 Sequence::new(vec![
4258 Ref::keyword("TEMPLATE").to_matchable(),
4259 Ref::new("EqualsSegment").optional().to_matchable(),
4260 Ref::new("ObjectReferenceSegment").to_matchable(),
4261 ])
4262 .to_matchable(),
4263 Sequence::new(vec![
4264 Ref::keyword("ENCODING").to_matchable(),
4265 Ref::new("EqualsSegment").optional().to_matchable(),
4266 one_of(vec![
4267 Ref::new("QuotedLiteralSegment").to_matchable(),
4268 Ref::keyword("DEFAULT").to_matchable(),
4269 ])
4270 .to_matchable(),
4271 ])
4272 .to_matchable(),
4273 one_of(vec![
4274 Sequence::new(vec![
4275 Ref::keyword("LOCALE").to_matchable(),
4276 Ref::new("EqualsSegment").optional().to_matchable(),
4277 Ref::new("QuotedLiteralSegment").to_matchable(),
4278 ])
4279 .to_matchable(),
4280 AnyNumberOf::new(vec![
4281 Sequence::new(vec![
4282 Ref::keyword("LC_COLLATE").to_matchable(),
4283 Ref::new("EqualsSegment").optional().to_matchable(),
4284 Ref::new("QuotedLiteralSegment").to_matchable(),
4285 ])
4286 .to_matchable(),
4287 Sequence::new(vec![
4288 Ref::keyword("LC_CTYPE").to_matchable(),
4289 Ref::new("EqualsSegment").optional().to_matchable(),
4290 Ref::new("QuotedLiteralSegment").to_matchable(),
4291 ])
4292 .to_matchable(),
4293 ])
4294 .to_matchable(),
4295 ])
4296 .to_matchable(),
4297 Sequence::new(vec![
4298 Ref::keyword("TABLESPACE").to_matchable(),
4299 Ref::new("EqualsSegment").optional().to_matchable(),
4300 one_of(vec![
4301 Ref::new("TablespaceReferenceSegment").to_matchable(),
4302 Ref::keyword("DEFAULT").to_matchable(),
4303 ])
4304 .to_matchable(),
4305 ])
4306 .to_matchable(),
4307 Sequence::new(vec![
4308 Ref::keyword("ALLOW_CONNECTIONS").to_matchable(),
4309 Ref::new("EqualsSegment").optional().to_matchable(),
4310 Ref::new("BooleanLiteralGrammar").to_matchable(),
4311 ])
4312 .to_matchable(),
4313 Sequence::new(vec![
4314 Ref::keyword("CONNECTION").to_matchable(),
4315 Ref::keyword("LIMIT").to_matchable(),
4316 Ref::new("EqualsSegment").optional().to_matchable(),
4317 Ref::new("NumericLiteralSegment").to_matchable(),
4318 ])
4319 .to_matchable(),
4320 Sequence::new(vec![
4321 Ref::keyword("IS_TEMPLATE").to_matchable(),
4322 Ref::new("EqualsSegment").optional().to_matchable(),
4323 Ref::new("BooleanLiteralGrammar").to_matchable(),
4324 ])
4325 .to_matchable(),
4326 ])
4327 .to_matchable(),
4328 ])
4329 .to_matchable()
4330 })
4331 .to_matchable()
4332 .into(),
4333 ),
4334 ]);
4335
4336 postgres.add([(
4337 "AlterDatabaseStatementSegment".into(),
4338 NodeMatcher::new(SyntaxKind::AlterDatabaseStatement, |_| {
4339 Sequence::new(vec![
4340 Ref::keyword("ALTER").to_matchable(),
4341 Ref::keyword("DATABASE").to_matchable(),
4342 Ref::new("DatabaseReferenceSegment").to_matchable(),
4343 one_of(vec![
4344 Sequence::new(vec![
4345 Ref::keyword("WITH").optional().to_matchable(),
4346 AnyNumberOf::new(vec![
4347 Sequence::new(vec![
4348 Ref::keyword("ALLOW_CONNECTIONS").to_matchable(),
4349 Ref::new("BooleanLiteralGrammar").to_matchable(),
4350 ])
4351 .to_matchable(),
4352 Sequence::new(vec![
4353 Ref::keyword("CONNECTION").to_matchable(),
4354 Ref::keyword("LIMIT").to_matchable(),
4355 Ref::new("NumericLiteralSegment").to_matchable(),
4356 ])
4357 .to_matchable(),
4358 Sequence::new(vec![
4359 Ref::keyword("IS_TEMPLATE").to_matchable(),
4360 Ref::new("BooleanLiteralGrammar").to_matchable(),
4361 ])
4362 .to_matchable(),
4363 ])
4364 .config(|this| this.min_times(1))
4365 .to_matchable(),
4366 ])
4367 .to_matchable(),
4368 Sequence::new(vec![
4369 Ref::keyword("RENAME").to_matchable(),
4370 Ref::keyword("TO").to_matchable(),
4371 Ref::new("DatabaseReferenceSegment").to_matchable(),
4372 ])
4373 .to_matchable(),
4374 Sequence::new(vec![
4375 Ref::keyword("OWNER").to_matchable(),
4376 Ref::keyword("TO").to_matchable(),
4377 one_of(vec![
4378 Ref::new("ObjectReferenceSegment").to_matchable(),
4379 Ref::keyword("CURRENT_ROLE").to_matchable(),
4380 Ref::keyword("CURRENT_USER").to_matchable(),
4381 Ref::keyword("SESSION_USER").to_matchable(),
4382 ])
4383 .to_matchable(),
4384 ])
4385 .to_matchable(),
4386 Sequence::new(vec![
4387 Ref::keyword("SET").to_matchable(),
4388 Ref::keyword("TABLESPACE").to_matchable(),
4389 Ref::new("TablespaceReferenceSegment").to_matchable(),
4390 ])
4391 .to_matchable(),
4392 Sequence::new(vec![
4393 Ref::keyword("SET").to_matchable(),
4394 Ref::new("ParameterNameSegment").to_matchable(),
4395 one_of(vec![
4396 Sequence::new(vec![
4397 one_of(vec![
4398 Ref::keyword("TO").to_matchable(),
4399 Ref::new("EqualsSegment").to_matchable(),
4400 ])
4401 .to_matchable(),
4402 one_of(vec![
4403 Ref::keyword("DEFAULT").to_matchable(),
4404 Ref::new("LiteralGrammar").to_matchable(),
4405 ])
4406 .to_matchable(),
4407 ])
4408 .to_matchable(),
4409 Sequence::new(vec![
4410 Ref::keyword("FROM").to_matchable(),
4411 Ref::keyword("CURRENT").to_matchable(),
4412 ])
4413 .to_matchable(),
4414 ])
4415 .to_matchable(),
4416 ])
4417 .to_matchable(),
4418 Sequence::new(vec![
4419 Ref::keyword("RESET").to_matchable(),
4420 one_of(vec![
4421 Ref::keyword("ALL").to_matchable(),
4422 Ref::new("ParameterNameSegment").to_matchable(),
4423 ])
4424 .to_matchable(),
4425 ])
4426 .to_matchable(),
4427 ])
4428 .config(|this| this.optional())
4429 .to_matchable(),
4430 ])
4431 .to_matchable()
4432 })
4433 .to_matchable()
4434 .into(),
4435 )]);
4436
4437 postgres.replace_grammar(
4438 "DropDatabaseStatementSegment",
4439 Sequence::new(vec![
4440 Ref::keyword("DROP").to_matchable(),
4441 Ref::keyword("DATABASE").to_matchable(),
4442 Ref::new("IfExistsGrammar").optional().to_matchable(),
4443 Ref::new("DatabaseReferenceSegment").to_matchable(),
4444 Sequence::new(vec![
4445 Ref::keyword("WITH").optional().to_matchable(),
4446 Bracketed::new(vec![Ref::keyword("FORCE").to_matchable()]).to_matchable(),
4447 ])
4448 .config(|this| this.optional())
4449 .to_matchable(),
4450 ])
4451 .to_matchable(),
4452 );
4453
4454 postgres.add([
4455 (
4456 "VacuumStatementSegment".into(),
4457 NodeMatcher::new(SyntaxKind::VacuumStatement, |_| {
4458 Sequence::new(vec![
4459 Ref::keyword("VACUUM").to_matchable(),
4460 one_of(vec![
4461 Sequence::new(vec![
4462 Ref::keyword("FULL").optional().to_matchable(),
4463 Ref::keyword("FREEZE").optional().to_matchable(),
4464 Ref::keyword("VERBOSE").optional().to_matchable(),
4465 one_of(vec![
4466 Ref::keyword("ANALYZE").to_matchable(),
4467 Ref::keyword("ANALYSE").to_matchable(),
4468 ])
4469 .config(|this| this.optional())
4470 .to_matchable(),
4471 ])
4472 .to_matchable(),
4473 Bracketed::new(vec![
4474 Delimited::new(vec![
4475 Sequence::new(vec![
4476 one_of(vec![
4477 Ref::keyword("FULL").to_matchable(),
4478 Ref::keyword("FREEZE").to_matchable(),
4479 Ref::keyword("VERBOSE").to_matchable(),
4480 Ref::keyword("ANALYZE").to_matchable(),
4481 Ref::keyword("ANALYSE").to_matchable(),
4482 Ref::keyword("DISABLE_PAGE_SKIPPING").to_matchable(),
4483 Ref::keyword("SKIP_LOCKED").to_matchable(),
4484 Ref::keyword("INDEX_CLEANUP").to_matchable(),
4485 Ref::keyword("PROCESS_TOAST").to_matchable(),
4486 Ref::keyword("TRUNCATE").to_matchable(),
4487 Ref::keyword("PARALLEL").to_matchable(),
4488 ])
4489 .to_matchable(),
4490 one_of(vec![
4491 Ref::new("LiteralGrammar").to_matchable(),
4492 Ref::new("NakedIdentifierSegment").to_matchable(),
4493 Ref::new("OnKeywordAsIdentifierSegment").to_matchable(),
4494 ])
4495 .config(|this| this.optional())
4496 .to_matchable(),
4497 ])
4498 .to_matchable(),
4499 ])
4500 .to_matchable(),
4501 ])
4502 .to_matchable(),
4503 ])
4504 .config(|this| this.optional())
4505 .to_matchable(),
4506 Delimited::new(vec![
4507 Sequence::new(vec![
4508 Ref::new("TableReferenceSegment").to_matchable(),
4509 Ref::new("BracketedColumnReferenceListGrammar")
4510 .optional()
4511 .to_matchable(),
4512 ])
4513 .to_matchable(),
4514 ])
4515 .config(|this| this.optional())
4516 .to_matchable(),
4517 ])
4518 .to_matchable()
4519 })
4520 .to_matchable()
4521 .into(),
4522 ),
4523 (
4524 "LikeOptionSegment".into(),
4525 NodeMatcher::new(SyntaxKind::LikeOptionSegment, |_| {
4526 Sequence::new(vec![
4527 one_of(vec![
4528 Ref::keyword("INCLUDING").to_matchable(),
4529 Ref::keyword("EXCLUDING").to_matchable(),
4530 ])
4531 .to_matchable(),
4532 one_of(vec![
4533 Ref::keyword("COMMENTS").to_matchable(),
4534 Ref::keyword("CONSTRAINTS").to_matchable(),
4535 Ref::keyword("DEFAULTS").to_matchable(),
4536 Ref::keyword("GENERATED").to_matchable(),
4537 Ref::keyword("IDENTITY").to_matchable(),
4538 Ref::keyword("INDEXES").to_matchable(),
4539 Ref::keyword("STATISTICS").to_matchable(),
4540 Ref::keyword("STORAGE").to_matchable(),
4541 Ref::keyword("ALL").to_matchable(),
4542 ])
4543 .to_matchable(),
4544 ])
4545 .to_matchable()
4546 })
4547 .to_matchable()
4548 .into(),
4549 ),
4550 ]);
4551
4552 postgres.replace_grammar(
4553 "ColumnConstraintSegment",
4554 Sequence::new(vec![
4555 Sequence::new(vec![
4556 Ref::keyword("CONSTRAINT").to_matchable(),
4557 Ref::new("ObjectReferenceSegment").to_matchable(),
4558 ])
4559 .config(|this| this.optional())
4560 .to_matchable(),
4561 one_of(vec![
4562 Sequence::new(vec![
4563 Ref::keyword("NOT").optional().to_matchable(),
4564 Ref::keyword("NULL").to_matchable(),
4565 ])
4566 .to_matchable(),
4567 Sequence::new(vec![
4568 Ref::keyword("CHECK").to_matchable(),
4569 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
4570 .to_matchable(),
4571 Sequence::new(vec![
4572 Ref::keyword("NO").to_matchable(),
4573 Ref::keyword("INHERIT").to_matchable(),
4574 ])
4575 .config(|this| this.optional())
4576 .to_matchable(),
4577 ])
4578 .to_matchable(),
4579 Sequence::new(vec![
4580 Ref::keyword("DEFAULT").to_matchable(),
4581 one_of(vec![
4582 Ref::new("ShorthandCastSegment").to_matchable(),
4583 Ref::new("LiteralGrammar").to_matchable(),
4584 Ref::new("FunctionSegment").to_matchable(),
4585 Ref::new("BareFunctionSegment").to_matchable(),
4586 Ref::new("ExpressionSegment").to_matchable(),
4587 ])
4588 .to_matchable(),
4589 ])
4590 .to_matchable(),
4591 Sequence::new(vec![
4592 Ref::keyword("GENERATED").to_matchable(),
4593 Ref::keyword("ALWAYS").to_matchable(),
4594 Ref::keyword("AS").to_matchable(),
4595 Ref::new("ExpressionSegment").to_matchable(),
4596 Ref::keyword("STORED").to_matchable(),
4597 ])
4598 .to_matchable(),
4599 Sequence::new(vec![
4600 Ref::keyword("GENERATED").to_matchable(),
4601 one_of(vec![
4602 Ref::keyword("ALWAYS").to_matchable(),
4603 Sequence::new(vec![
4604 Ref::keyword("BY").to_matchable(),
4605 Ref::keyword("DEFAULT").to_matchable(),
4606 ])
4607 .to_matchable(),
4608 ])
4609 .to_matchable(),
4610 Ref::keyword("AS").to_matchable(),
4611 Ref::keyword("IDENTITY").to_matchable(),
4612 Bracketed::new(vec![
4613 AnyNumberOf::new(vec![
4614 Ref::new("AlterSequenceOptionsSegment").to_matchable(),
4615 ])
4616 .to_matchable(),
4617 ])
4618 .config(|this| this.optional())
4619 .to_matchable(),
4620 ])
4621 .to_matchable(),
4622 Sequence::new(vec![
4623 Ref::keyword("UNIQUE").to_matchable(),
4624 Sequence::new(vec![
4625 Ref::keyword("NULLS").to_matchable(),
4626 Ref::keyword("NOT").optional().to_matchable(),
4627 Ref::keyword("DISTINCT").to_matchable(),
4628 ])
4629 .config(|this| this.optional())
4630 .to_matchable(),
4631 Sequence::new(vec![
4632 Ref::keyword("WITH").to_matchable(),
4633 Ref::new("DefinitionParametersSegment").to_matchable(),
4634 ])
4635 .config(|this| this.optional())
4636 .to_matchable(),
4637 Sequence::new(vec![
4638 Ref::keyword("USING").to_matchable(),
4639 Ref::keyword("INDEX").to_matchable(),
4640 Ref::keyword("TABLESPACE").to_matchable(),
4641 Ref::new("TablespaceReferenceSegment").to_matchable(),
4642 ])
4643 .config(|this| this.optional())
4644 .to_matchable(),
4645 ])
4646 .to_matchable(),
4647 Sequence::new(vec![
4648 Ref::keyword("PRIMARY").to_matchable(),
4649 Ref::keyword("KEY").to_matchable(),
4650 Sequence::new(vec![
4651 Ref::keyword("WITH").to_matchable(),
4652 Ref::new("DefinitionParametersSegment").to_matchable(),
4653 ])
4654 .config(|this| this.optional())
4655 .to_matchable(),
4656 Sequence::new(vec![
4657 Ref::keyword("USING").to_matchable(),
4658 Ref::keyword("INDEX").to_matchable(),
4659 Ref::keyword("TABLESPACE").to_matchable(),
4660 Ref::new("TablespaceReferenceSegment").to_matchable(),
4661 ])
4662 .config(|this| this.optional())
4663 .to_matchable(),
4664 ])
4665 .to_matchable(),
4666 Ref::new("ReferenceDefinitionGrammar").to_matchable(),
4667 ])
4668 .to_matchable(),
4669 one_of(vec![
4670 Ref::keyword("DEFERRABLE").to_matchable(),
4671 Sequence::new(vec![
4672 Ref::keyword("NOT").to_matchable(),
4673 Ref::keyword("DEFERRABLE").to_matchable(),
4674 ])
4675 .to_matchable(),
4676 ])
4677 .config(|this| this.optional())
4678 .to_matchable(),
4679 one_of(vec![
4680 Sequence::new(vec![
4681 Ref::keyword("INITIALLY").to_matchable(),
4682 Ref::keyword("DEFERRED").to_matchable(),
4683 ])
4684 .to_matchable(),
4685 Sequence::new(vec![
4686 Ref::keyword("INITIALLY").to_matchable(),
4687 Ref::keyword("IMMEDIATE").to_matchable(),
4688 ])
4689 .to_matchable(),
4690 ])
4691 .config(|this| this.optional())
4692 .to_matchable(),
4693 ])
4694 .to_matchable(),
4695 );
4696
4697 postgres.add([(
4698 "PartitionBoundSpecSegment".into(),
4699 NodeMatcher::new(SyntaxKind::PartitionBoundSpec, |_| {
4700 one_of(vec![
4701 Sequence::new(vec![
4702 Ref::keyword("IN").to_matchable(),
4703 Bracketed::new(vec![
4704 Delimited::new(vec![Ref::new("ExpressionSegment").to_matchable()])
4705 .to_matchable(),
4706 ])
4707 .to_matchable(),
4708 ])
4709 .to_matchable(),
4710 Sequence::new(vec![
4711 Ref::keyword("FROM").to_matchable(),
4712 Bracketed::new(vec![
4713 Delimited::new(vec![
4714 one_of(vec![
4715 Ref::new("ExpressionSegment").to_matchable(),
4716 Ref::keyword("MINVALUE").to_matchable(),
4717 Ref::keyword("MAXVALUE").to_matchable(),
4718 ])
4719 .to_matchable(),
4720 ])
4721 .to_matchable(),
4722 ])
4723 .to_matchable(),
4724 Ref::keyword("TO").to_matchable(),
4725 Bracketed::new(vec![
4726 Delimited::new(vec![
4727 one_of(vec![
4728 Ref::new("ExpressionSegment").to_matchable(),
4729 Ref::keyword("MINVALUE").to_matchable(),
4730 Ref::keyword("MAXVALUE").to_matchable(),
4731 ])
4732 .to_matchable(),
4733 ])
4734 .to_matchable(),
4735 ])
4736 .to_matchable(),
4737 ])
4738 .to_matchable(),
4739 Sequence::new(vec![
4740 Ref::keyword("WITH").to_matchable(),
4741 Bracketed::new(vec![
4742 Sequence::new(vec![
4743 Ref::keyword("MODULUS").to_matchable(),
4744 Ref::new("NumericLiteralSegment").to_matchable(),
4745 Ref::new("CommaSegment").to_matchable(),
4746 Ref::keyword("REMAINDER").to_matchable(),
4747 Ref::new("NumericLiteralSegment").to_matchable(),
4748 ])
4749 .to_matchable(),
4750 ])
4751 .to_matchable(),
4752 ])
4753 .to_matchable(),
4754 ])
4755 .to_matchable()
4756 })
4757 .to_matchable()
4758 .into(),
4759 )]);
4760
4761 postgres.add([(
4762 "TableConstraintSegment".into(),
4763 NodeMatcher::new(SyntaxKind::TableConstraint, |_| {
4764 Sequence::new(vec![
4765 Sequence::new(vec![
4766 Ref::keyword("CONSTRAINT").to_matchable(),
4767 Ref::new("ObjectReferenceSegment").to_matchable(),
4768 ])
4769 .config(|this| this.optional())
4770 .to_matchable(),
4771 one_of(vec![
4772 Sequence::new(vec![
4773 Ref::keyword("CHECK").to_matchable(),
4774 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
4775 .to_matchable(),
4776 Sequence::new(vec![
4777 Ref::keyword("NO").to_matchable(),
4778 Ref::keyword("INHERIT").to_matchable(),
4779 ])
4780 .config(|this| this.optional())
4781 .to_matchable(),
4782 ])
4783 .to_matchable(),
4784 Sequence::new(vec![
4785 Ref::keyword("UNIQUE").to_matchable(),
4786 Sequence::new(vec![
4787 Ref::keyword("NULLS").to_matchable(),
4788 Ref::keyword("NOT").optional().to_matchable(),
4789 Ref::keyword("DISTINCT").to_matchable(),
4790 ])
4791 .config(|this| this.optional())
4792 .to_matchable(),
4793 Ref::new("BracketedColumnReferenceListGrammar").to_matchable(),
4794 Ref::new("IndexParametersSegment").optional().to_matchable(),
4795 ])
4796 .to_matchable(),
4797 Sequence::new(vec![
4798 Ref::new("PrimaryKeyGrammar").to_matchable(),
4799 Ref::new("BracketedColumnReferenceListGrammar").to_matchable(),
4800 Ref::new("IndexParametersSegment").optional().to_matchable(),
4801 ])
4802 .to_matchable(),
4803 Sequence::new(vec![
4804 Ref::keyword("EXCLUDE").to_matchable(),
4805 Sequence::new(vec![
4806 Ref::keyword("USING").to_matchable(),
4807 Ref::new("IndexAccessMethodSegment").to_matchable(),
4808 ])
4809 .config(|this| this.optional())
4810 .to_matchable(),
4811 Bracketed::new(vec![
4812 Delimited::new(vec![
4813 Ref::new("ExclusionConstraintElementSegment").to_matchable(),
4814 ])
4815 .to_matchable(),
4816 ])
4817 .to_matchable(),
4818 Ref::new("IndexParametersSegment").optional().to_matchable(),
4819 Sequence::new(vec![
4820 Ref::keyword("WHERE").to_matchable(),
4821 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
4822 .to_matchable(),
4823 ])
4824 .config(|this| this.optional())
4825 .to_matchable(),
4826 ])
4827 .to_matchable(),
4828 Sequence::new(vec![
4829 Ref::keyword("FOREIGN").to_matchable(),
4830 Ref::keyword("KEY").to_matchable(),
4831 Ref::new("BracketedColumnReferenceListGrammar").to_matchable(),
4832 Ref::new("ReferenceDefinitionGrammar").to_matchable(),
4833 ])
4834 .to_matchable(),
4835 ])
4836 .to_matchable(),
4837 AnyNumberOf::new(vec![
4838 one_of(vec![
4839 Ref::keyword("DEFERRABLE").to_matchable(),
4840 Sequence::new(vec![
4841 Ref::keyword("NOT").to_matchable(),
4842 Ref::keyword("DEFERRABLE").to_matchable(),
4843 ])
4844 .to_matchable(),
4845 ])
4846 .to_matchable(),
4847 one_of(vec![
4848 Sequence::new(vec![
4849 Ref::keyword("INITIALLY").to_matchable(),
4850 Ref::keyword("DEFERRED").to_matchable(),
4851 ])
4852 .to_matchable(),
4853 Sequence::new(vec![
4854 Ref::keyword("INITIALLY").to_matchable(),
4855 Ref::keyword("IMMEDIATE").to_matchable(),
4856 ])
4857 .to_matchable(),
4858 ])
4859 .to_matchable(),
4860 Sequence::new(vec![
4861 Ref::keyword("NOT").to_matchable(),
4862 Ref::keyword("VALID").to_matchable(),
4863 ])
4864 .to_matchable(),
4865 Sequence::new(vec![
4866 Ref::keyword("NO").to_matchable(),
4867 Ref::keyword("INHERIT").to_matchable(),
4868 ])
4869 .to_matchable(),
4870 ])
4871 .to_matchable(),
4872 ])
4873 .to_matchable()
4874 })
4875 .to_matchable()
4876 .into(),
4877 )]);
4878
4879 postgres.add([(
4880 "TableConstraintUsingIndexSegment".into(),
4881 NodeMatcher::new(SyntaxKind::TableConstraint, |_| {
4882 Sequence::new(vec![
4883 Sequence::new(vec![
4884 Ref::keyword("CONSTRAINT").to_matchable(),
4885 Ref::new("ObjectReferenceSegment").to_matchable(),
4886 ])
4887 .config(|this| this.optional())
4888 .to_matchable(),
4889 Sequence::new(vec![
4890 one_of(vec![
4891 Ref::keyword("UNIQUE").to_matchable(),
4892 Ref::new("PrimaryKeyGrammar").to_matchable(),
4893 ])
4894 .to_matchable(),
4895 Ref::keyword("USING").to_matchable(),
4896 Ref::keyword("INDEX").to_matchable(),
4897 Ref::new("IndexReferenceSegment").to_matchable(),
4898 ])
4899 .to_matchable(),
4900 one_of(vec![
4901 Ref::keyword("DEFERRABLE").to_matchable(),
4902 Sequence::new(vec![
4903 Ref::keyword("NOT").to_matchable(),
4904 Ref::keyword("DEFERRABLE").to_matchable(),
4905 ])
4906 .to_matchable(),
4907 ])
4908 .config(|this| this.optional())
4909 .to_matchable(),
4910 one_of(vec![
4911 Sequence::new(vec![
4912 Ref::keyword("INITIALLY").to_matchable(),
4913 Ref::keyword("DEFERRED").to_matchable(),
4914 ])
4915 .to_matchable(),
4916 Sequence::new(vec![
4917 Ref::keyword("INITIALLY").to_matchable(),
4918 Ref::keyword("IMMEDIATE").to_matchable(),
4919 ])
4920 .to_matchable(),
4921 ])
4922 .config(|this| this.optional())
4923 .to_matchable(),
4924 ])
4925 .to_matchable()
4926 })
4927 .to_matchable()
4928 .into(),
4929 )]);
4930
4931 postgres.add([
4932 (
4933 "IndexParametersSegment".into(),
4934 NodeMatcher::new(SyntaxKind::IndexParameters, |_| {
4935 Sequence::new(vec![
4936 Sequence::new(vec![
4937 Ref::keyword("INCLUDE").to_matchable(),
4938 Ref::new("BracketedColumnReferenceListGrammar").to_matchable(),
4939 ])
4940 .config(|this| this.optional())
4941 .to_matchable(),
4942 Sequence::new(vec![
4943 Ref::keyword("WITH").to_matchable(),
4944 Ref::new("DefinitionParametersSegment").to_matchable(),
4945 ])
4946 .config(|this| this.optional())
4947 .to_matchable(),
4948 Sequence::new(vec![
4949 Ref::keyword("USING").to_matchable(),
4950 Ref::keyword("INDEX").to_matchable(),
4951 Ref::keyword("TABLESPACE").to_matchable(),
4952 Ref::new("TablespaceReferenceSegment").to_matchable(),
4953 ])
4954 .config(|this| this.optional())
4955 .to_matchable(),
4956 ])
4957 .to_matchable()
4958 })
4959 .to_matchable()
4960 .into(),
4961 ),
4962 (
4963 "ReferentialActionSegment".into(),
4964 NodeMatcher::new(SyntaxKind::ReferentialActionSegment, |_| {
4965 one_of(vec![
4966 Ref::keyword("CASCADE").to_matchable(),
4967 Sequence::new(vec![
4968 Ref::keyword("SET").to_matchable(),
4969 Ref::keyword("NULL").to_matchable(),
4970 ])
4971 .to_matchable(),
4972 Sequence::new(vec![
4973 Ref::keyword("SET").to_matchable(),
4974 Ref::keyword("DEFAULT").to_matchable(),
4975 ])
4976 .to_matchable(),
4977 Ref::keyword("RESTRICT").to_matchable(),
4978 Sequence::new(vec![
4979 Ref::keyword("NO").to_matchable(),
4980 Ref::keyword("ACTION").to_matchable(),
4981 ])
4982 .to_matchable(),
4983 ])
4984 .to_matchable()
4985 })
4986 .to_matchable()
4987 .into(),
4988 ),
4989 (
4990 "IndexElementOptionsSegment".into(),
4991 NodeMatcher::new(SyntaxKind::IndexElementOptions, |_| {
4992 Sequence::new(vec![
4993 Sequence::new(vec![
4994 Ref::keyword("COLLATE").to_matchable(),
4995 Ref::new("CollationReferenceSegment").to_matchable(),
4996 ])
4997 .config(|this| this.optional())
4998 .to_matchable(),
4999 Sequence::new(vec![
5000 Ref::new("OperatorClassReferenceSegment")
5001 .config(|this| {
5002 this.exclude = Some(
5003 Sequence::new(vec![
5004 Ref::keyword("NULLS").to_matchable(),
5005 one_of(vec![
5006 Ref::keyword("FIRST").to_matchable(),
5007 Ref::keyword("LAST").to_matchable(),
5008 ])
5009 .to_matchable(),
5010 ])
5011 .to_matchable(),
5012 );
5013 })
5014 .to_matchable(),
5015 Ref::new("RelationOptionsSegment").optional().to_matchable(),
5016 ])
5017 .config(|this| this.optional())
5018 .to_matchable(),
5019 one_of(vec![
5020 Ref::keyword("ASC").to_matchable(),
5021 Ref::keyword("DESC").to_matchable(),
5022 ])
5023 .config(|this| this.optional())
5024 .to_matchable(),
5025 Sequence::new(vec![
5026 Ref::keyword("NULLS").to_matchable(),
5027 one_of(vec![
5028 Ref::keyword("FIRST").to_matchable(),
5029 Ref::keyword("LAST").to_matchable(),
5030 ])
5031 .to_matchable(),
5032 ])
5033 .config(|this| this.optional())
5034 .to_matchable(),
5035 ])
5036 .to_matchable()
5037 })
5038 .to_matchable()
5039 .into(),
5040 ),
5041 (
5042 "IndexElementSegment".into(),
5043 NodeMatcher::new(SyntaxKind::IndexElement, |_| {
5044 Sequence::new(vec![
5045 one_of(vec![
5046 Ref::new("ColumnReferenceSegment").to_matchable(),
5047 Ref::new("FunctionSegment").to_matchable(),
5048 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
5049 .to_matchable(),
5050 ])
5051 .to_matchable(),
5052 Ref::new("IndexElementOptionsSegment")
5053 .optional()
5054 .to_matchable(),
5055 ])
5056 .to_matchable()
5057 })
5058 .to_matchable()
5059 .into(),
5060 ),
5061 (
5062 "ExclusionConstraintElementSegment".into(),
5063 NodeMatcher::new(SyntaxKind::ExclusionConstraintElement, |_| {
5064 Sequence::new(vec![
5065 Ref::new("IndexElementSegment").to_matchable(),
5066 Ref::keyword("WITH").to_matchable(),
5067 Ref::new("ComparisonOperatorGrammar").to_matchable(),
5068 ])
5069 .to_matchable()
5070 })
5071 .to_matchable()
5072 .into(),
5073 ),
5074 (
5075 "AlterDefaultPrivilegesStatementSegment".into(),
5076 NodeMatcher::new(SyntaxKind::AlterDefaultPrivilegesStatement, |_| {
5077 Sequence::new(vec![
5078 Ref::keyword("ALTER").to_matchable(),
5079 Ref::keyword("DEFAULT").to_matchable(),
5080 Ref::keyword("PRIVILEGES").to_matchable(),
5081 Sequence::new(vec![
5082 Ref::keyword("FOR").to_matchable(),
5083 one_of(vec![
5084 Ref::keyword("ROLE").to_matchable(),
5085 Ref::keyword("USER").to_matchable(),
5086 ])
5087 .to_matchable(),
5088 Delimited::new(vec![Ref::new("ObjectReferenceSegment").to_matchable()])
5089 .config(|this| {
5090 this.terminators = vec![
5091 Ref::keyword("IN").to_matchable(),
5092 Ref::keyword("GRANT").to_matchable(),
5093 Ref::keyword("REVOKE").to_matchable(),
5094 ];
5095 })
5096 .to_matchable(),
5097 ])
5098 .config(|this| this.optional())
5099 .to_matchable(),
5100 Sequence::new(vec![
5101 Ref::keyword("IN").to_matchable(),
5102 Ref::keyword("SCHEMA").to_matchable(),
5103 Delimited::new(vec![Ref::new("SchemaReferenceSegment").to_matchable()])
5104 .config(|this| {
5105 this.terminators = vec![
5106 Ref::keyword("GRANT").to_matchable(),
5107 Ref::keyword("REVOKE").to_matchable(),
5108 ];
5109 })
5110 .to_matchable(),
5111 ])
5112 .config(|this| this.optional())
5113 .to_matchable(),
5114 one_of(vec![
5115 Ref::new("AlterDefaultPrivilegesGrantSegment").to_matchable(),
5116 Ref::new("AlterDefaultPrivilegesRevokeSegment").to_matchable(),
5117 ])
5118 .to_matchable(),
5119 ])
5120 .to_matchable()
5121 })
5122 .to_matchable()
5123 .into(),
5124 ),
5125 (
5126 "AlterDefaultPrivilegesObjectPrivilegesSegment".into(),
5127 NodeMatcher::new(SyntaxKind::AlterDefaultPrivilegesObjectPrivilege, |_| {
5128 one_of(vec![
5129 Sequence::new(vec![
5130 Ref::keyword("ALL").to_matchable(),
5131 Ref::keyword("PRIVILEGES").optional().to_matchable(),
5132 ])
5133 .to_matchable(),
5134 Delimited::new(vec![
5135 Ref::keyword("CREATE").to_matchable(),
5136 Ref::keyword("DELETE").to_matchable(),
5137 Ref::keyword("EXECUTE").to_matchable(),
5138 Ref::keyword("INSERT").to_matchable(),
5139 Ref::keyword("REFERENCES").to_matchable(),
5140 Ref::keyword("SELECT").to_matchable(),
5141 Ref::keyword("TRIGGER").to_matchable(),
5142 Ref::keyword("TRUNCATE").to_matchable(),
5143 Ref::keyword("UPDATE").to_matchable(),
5144 Ref::keyword("USAGE").to_matchable(),
5145 ])
5146 .config(|this| {
5147 this.terminators = vec![Ref::keyword("ON").to_matchable()];
5148 })
5149 .to_matchable(),
5150 ])
5151 .to_matchable()
5152 })
5153 .to_matchable()
5154 .into(),
5155 ),
5156 (
5157 "AlterDefaultPrivilegesSchemaObjectsSegment".into(),
5158 NodeMatcher::new(SyntaxKind::AlterDefaultPrivilegesSchemaObject, |_| {
5159 one_of(vec![
5160 Ref::keyword("TABLES").to_matchable(),
5161 Ref::keyword("FUNCTIONS").to_matchable(),
5162 Ref::keyword("ROUTINES").to_matchable(),
5163 Ref::keyword("SEQUENCES").to_matchable(),
5164 Ref::keyword("TYPES").to_matchable(),
5165 Ref::keyword("SCHEMAS").to_matchable(),
5166 ])
5167 .to_matchable()
5168 })
5169 .to_matchable()
5170 .into(),
5171 ),
5172 (
5173 "AlterDefaultPrivilegesToFromRolesSegment".into(),
5174 NodeMatcher::new(SyntaxKind::AlterDefaultPrivilegesToFromRoles, |_| {
5175 one_of(vec![
5176 Sequence::new(vec![
5177 Ref::keyword("GROUP").optional().to_matchable(),
5178 Ref::new("RoleReferenceSegment").to_matchable(),
5179 ])
5180 .to_matchable(),
5181 Ref::keyword("PUBLIC").to_matchable(),
5182 ])
5183 .to_matchable()
5184 })
5185 .to_matchable()
5186 .into(),
5187 ),
5188 (
5189 "AlterDefaultPrivilegesGrantSegment".into(),
5190 NodeMatcher::new(SyntaxKind::AlterDefaultPrivilegesGrant, |_| {
5191 Sequence::new(vec![
5192 Ref::keyword("GRANT").to_matchable(),
5193 Ref::new("AlterDefaultPrivilegesObjectPrivilegesSegment").to_matchable(),
5194 Ref::keyword("ON").to_matchable(),
5195 Ref::new("AlterDefaultPrivilegesSchemaObjectsSegment").to_matchable(),
5196 Ref::keyword("TO").to_matchable(),
5197 Delimited::new(vec![
5198 Ref::new("AlterDefaultPrivilegesToFromRolesSegment").to_matchable(),
5199 ])
5200 .config(|this| {
5201 this.terminators = vec![Ref::keyword("WITH").to_matchable()];
5202 })
5203 .to_matchable(),
5204 Sequence::new(vec![
5205 Ref::keyword("WITH").to_matchable(),
5206 Ref::keyword("GRANT").to_matchable(),
5207 Ref::keyword("OPTION").to_matchable(),
5208 ])
5209 .config(|this| this.optional())
5210 .to_matchable(),
5211 ])
5212 .to_matchable()
5213 })
5214 .to_matchable()
5215 .into(),
5216 ),
5217 (
5218 "AlterDefaultPrivilegesRevokeSegment".into(),
5219 NodeMatcher::new(SyntaxKind::AlterDefaultPrivilegesRevoke, |_| {
5220 Sequence::new(vec![
5221 Ref::keyword("REVOKE").to_matchable(),
5222 Sequence::new(vec![
5223 Ref::keyword("GRANT").to_matchable(),
5224 Ref::keyword("OPTION").to_matchable(),
5225 Ref::keyword("FOR").to_matchable(),
5226 ])
5227 .config(|this| this.optional())
5228 .to_matchable(),
5229 Ref::new("AlterDefaultPrivilegesObjectPrivilegesSegment").to_matchable(),
5230 Ref::keyword("ON").to_matchable(),
5231 Ref::new("AlterDefaultPrivilegesSchemaObjectsSegment").to_matchable(),
5232 Ref::keyword("FROM").to_matchable(),
5233 Delimited::new(vec![
5234 Ref::new("AlterDefaultPrivilegesToFromRolesSegment").to_matchable(),
5235 ])
5236 .config(|this| {
5237 this.terminators = vec![
5238 Ref::keyword("RESTRICT").to_matchable(),
5239 Ref::keyword("CASCADE").to_matchable(),
5240 ];
5241 })
5242 .to_matchable(),
5243 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
5244 ])
5245 .to_matchable()
5246 })
5247 .to_matchable()
5248 .into(),
5249 ),
5250 (
5251 "DropOwnedStatementSegment".into(),
5252 NodeMatcher::new(SyntaxKind::DropOwnedStatement, |_| {
5253 Sequence::new(vec![
5254 Ref::keyword("DROP").to_matchable(),
5255 Ref::keyword("OWNED").to_matchable(),
5256 Ref::keyword("BY").to_matchable(),
5257 Delimited::new(vec![
5258 one_of(vec![
5259 Ref::keyword("CURRENT_ROLE").to_matchable(),
5260 Ref::keyword("CURRENT_USER").to_matchable(),
5261 Ref::keyword("SESSION_USER").to_matchable(),
5262 Ref::new("RoleReferenceSegment").to_matchable(),
5263 ])
5264 .to_matchable(),
5265 ])
5266 .to_matchable(),
5267 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
5268 ])
5269 .to_matchable()
5270 })
5271 .to_matchable()
5272 .into(),
5273 ),
5274 (
5275 "ReassignOwnedStatementSegment".into(),
5276 NodeMatcher::new(SyntaxKind::ReassignOwnedStatement, |_| {
5277 Sequence::new(vec![
5278 Ref::keyword("REASSIGN").to_matchable(),
5279 Ref::keyword("OWNED").to_matchable(),
5280 Ref::keyword("BY").to_matchable(),
5281 Delimited::new(vec![
5282 one_of(vec![
5283 Ref::keyword("CURRENT_ROLE").to_matchable(),
5284 Ref::keyword("CURRENT_USER").to_matchable(),
5285 Ref::keyword("SESSION_USER").to_matchable(),
5286 Ref::new("RoleReferenceSegment").to_matchable(),
5287 ])
5288 .to_matchable(),
5289 ])
5290 .to_matchable(),
5291 Ref::keyword("TO").to_matchable(),
5292 one_of(vec![
5293 Ref::keyword("CURRENT_ROLE").to_matchable(),
5294 Ref::keyword("CURRENT_USER").to_matchable(),
5295 Ref::keyword("SESSION_USER").to_matchable(),
5296 Ref::new("RoleReferenceSegment").to_matchable(),
5297 ])
5298 .to_matchable(),
5299 ])
5300 .to_matchable()
5301 })
5302 .to_matchable()
5303 .into(),
5304 ),
5305 (
5306 "CommentOnStatementSegment".into(),
5307 NodeMatcher::new(SyntaxKind::CommentClause, |_| {
5308 Sequence::new(vec![
5309 Ref::keyword("COMMENT").to_matchable(),
5310 Ref::keyword("ON").to_matchable(),
5311 Sequence::new(vec![
5312 one_of(vec![
5313 Sequence::new(vec![
5314 one_of(vec![
5315 Ref::keyword("TABLE").to_matchable(),
5316 Ref::keyword("VIEW").to_matchable(),
5317 ])
5318 .to_matchable(),
5319 Ref::new("TableReferenceSegment").to_matchable(),
5320 ])
5321 .to_matchable(),
5322 Sequence::new(vec![
5323 Ref::keyword("CAST").to_matchable(),
5324 Bracketed::new(vec![
5325 Sequence::new(vec![
5326 Ref::new("ObjectReferenceSegment").to_matchable(),
5327 Ref::keyword("AS").to_matchable(),
5328 Ref::new("ObjectReferenceSegment").to_matchable(),
5329 ])
5330 .to_matchable(),
5331 ])
5332 .to_matchable(),
5333 ])
5334 .to_matchable(),
5335 Sequence::new(vec![
5336 Ref::keyword("COLUMN").to_matchable(),
5337 Ref::new("ColumnReferenceSegment").to_matchable(),
5338 ])
5339 .to_matchable(),
5340 Sequence::new(vec![
5341 Ref::keyword("CONSTRAINT").to_matchable(),
5342 Ref::new("ObjectReferenceSegment").to_matchable(),
5343 Sequence::new(vec![
5344 Ref::keyword("ON").to_matchable(),
5345 Ref::keyword("DOMAIN").optional().to_matchable(),
5346 Ref::new("ObjectReferenceSegment").to_matchable(),
5347 ])
5348 .to_matchable(),
5349 ])
5350 .to_matchable(),
5351 Sequence::new(vec![
5352 Ref::keyword("DATABASE").to_matchable(),
5353 Ref::new("DatabaseReferenceSegment").to_matchable(),
5354 ])
5355 .to_matchable(),
5356 Sequence::new(vec![
5357 Ref::keyword("EXTENSION").to_matchable(),
5358 Ref::new("ExtensionReferenceSegment").to_matchable(),
5359 ])
5360 .to_matchable(),
5361 Sequence::new(vec![
5362 Ref::keyword("FUNCTION").to_matchable(),
5363 Ref::new("FunctionNameSegment").to_matchable(),
5364 Sequence::new(vec![
5365 Ref::new("FunctionParameterListGrammar").to_matchable(),
5366 ])
5367 .config(|this| this.optional())
5368 .to_matchable(),
5369 ])
5370 .to_matchable(),
5371 Sequence::new(vec![
5372 Ref::keyword("INDEX").to_matchable(),
5373 Ref::new("IndexReferenceSegment").to_matchable(),
5374 ])
5375 .to_matchable(),
5376 Sequence::new(vec![
5377 Ref::keyword("SCHEMA").to_matchable(),
5378 Ref::new("SchemaReferenceSegment").to_matchable(),
5379 ])
5380 .to_matchable(),
5381 Sequence::new(vec![
5382 one_of(vec![
5383 Ref::keyword("COLLATION").to_matchable(),
5384 Ref::keyword("CONVERSION").to_matchable(),
5385 Ref::keyword("DOMAIN").to_matchable(),
5386 Ref::keyword("LANGUAGE").to_matchable(),
5387 Ref::keyword("POLICY").to_matchable(),
5388 Ref::keyword("PUBLICATION").to_matchable(),
5389 Ref::keyword("ROLE").to_matchable(),
5390 Ref::keyword("RULE").to_matchable(),
5391 Ref::keyword("SEQUENCE").to_matchable(),
5392 Ref::keyword("SERVER").to_matchable(),
5393 Ref::keyword("STATISTICS").to_matchable(),
5394 Ref::keyword("SUBSCRIPTION").to_matchable(),
5395 Ref::keyword("TABLESPACE").to_matchable(),
5396 Ref::keyword("TRIGGER").to_matchable(),
5397 Ref::keyword("TYPE").to_matchable(),
5398 Sequence::new(vec![
5399 Ref::keyword("ACCESS").to_matchable(),
5400 Ref::keyword("METHOD").to_matchable(),
5401 ])
5402 .to_matchable(),
5403 Sequence::new(vec![
5404 Ref::keyword("EVENT").to_matchable(),
5405 Ref::keyword("TRIGGER").to_matchable(),
5406 ])
5407 .to_matchable(),
5408 Sequence::new(vec![
5409 Ref::keyword("FOREIGN").to_matchable(),
5410 Ref::keyword("DATA").to_matchable(),
5411 Ref::keyword("WRAPPER").to_matchable(),
5412 ])
5413 .to_matchable(),
5414 Sequence::new(vec![
5415 Ref::keyword("FOREIGN").to_matchable(),
5416 Ref::keyword("TABLE").to_matchable(),
5417 ])
5418 .to_matchable(),
5419 Sequence::new(vec![
5420 Ref::keyword("MATERIALIZED").to_matchable(),
5421 Ref::keyword("VIEW").to_matchable(),
5422 ])
5423 .to_matchable(),
5424 Sequence::new(vec![
5425 Ref::keyword("TEXT").to_matchable(),
5426 Ref::keyword("SEARCH").to_matchable(),
5427 Ref::keyword("CONFIGURATION").to_matchable(),
5428 ])
5429 .to_matchable(),
5430 Sequence::new(vec![
5431 Ref::keyword("TEXT").to_matchable(),
5432 Ref::keyword("SEARCH").to_matchable(),
5433 Ref::keyword("DICTIONARY").to_matchable(),
5434 ])
5435 .to_matchable(),
5436 Sequence::new(vec![
5437 Ref::keyword("TEXT").to_matchable(),
5438 Ref::keyword("SEARCH").to_matchable(),
5439 Ref::keyword("PARSER").to_matchable(),
5440 ])
5441 .to_matchable(),
5442 Sequence::new(vec![
5443 Ref::keyword("TEXT").to_matchable(),
5444 Ref::keyword("SEARCH").to_matchable(),
5445 Ref::keyword("TEMPLATE").to_matchable(),
5446 ])
5447 .to_matchable(),
5448 ])
5449 .to_matchable(),
5450 Ref::new("ObjectReferenceSegment").to_matchable(),
5451 Sequence::new(vec![
5452 Ref::keyword("ON").to_matchable(),
5453 Ref::new("ObjectReferenceSegment").to_matchable(),
5454 ])
5455 .config(|this| this.optional())
5456 .to_matchable(),
5457 ])
5458 .to_matchable(),
5459 Sequence::new(vec![
5460 one_of(vec![
5461 Ref::keyword("AGGREGATE").to_matchable(),
5462 Ref::keyword("PROCEDURE").to_matchable(),
5463 Ref::keyword("ROUTINE").to_matchable(),
5464 ])
5465 .to_matchable(),
5466 Ref::new("ObjectReferenceSegment").to_matchable(),
5467 Bracketed::new(vec![
5468 Sequence::new(vec![Anything::new().to_matchable()])
5469 .config(|this| this.optional())
5470 .to_matchable(),
5471 ])
5472 .config(|this| this.optional())
5473 .to_matchable(),
5474 ])
5475 .to_matchable(),
5476 ])
5477 .to_matchable(),
5478 Sequence::new(vec![
5479 Ref::keyword("IS").to_matchable(),
5480 one_of(vec![
5481 Ref::new("QuotedLiteralSegment").to_matchable(),
5482 Ref::keyword("NULL").to_matchable(),
5483 ])
5484 .to_matchable(),
5485 ])
5486 .to_matchable(),
5487 ])
5488 .to_matchable(),
5489 ])
5490 .to_matchable()
5491 })
5492 .to_matchable()
5493 .into(),
5494 ),
5495 ]);
5496
5497 postgres.replace_grammar(
5498 "CreateIndexStatementSegment",
5499 Sequence::new(vec![
5500 Ref::keyword("CREATE").to_matchable(),
5501 Ref::keyword("UNIQUE").optional().to_matchable(),
5502 Ref::keyword("INDEX").to_matchable(),
5503 Ref::keyword("CONCURRENTLY").optional().to_matchable(),
5504 Sequence::new(vec![
5505 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
5506 Ref::new("IndexReferenceSegment").to_matchable(),
5507 ])
5508 .config(|this| this.optional())
5509 .to_matchable(),
5510 Ref::keyword("ON").to_matchable(),
5511 Ref::keyword("ONLY").optional().to_matchable(),
5512 Ref::new("TableReferenceSegment").to_matchable(),
5513 Sequence::new(vec![
5514 Ref::keyword("USING").to_matchable(),
5515 Ref::new("IndexAccessMethodSegment").to_matchable(),
5516 ])
5517 .config(|this| this.optional())
5518 .to_matchable(),
5519 Bracketed::new(vec![
5520 Delimited::new(vec![Ref::new("IndexElementSegment").to_matchable()]).to_matchable(),
5521 ])
5522 .to_matchable(),
5523 Sequence::new(vec![
5524 Ref::keyword("INCLUDE").to_matchable(),
5525 Bracketed::new(vec![
5526 Delimited::new(vec![Ref::new("IndexElementSegment").to_matchable()])
5527 .to_matchable(),
5528 ])
5529 .to_matchable(),
5530 ])
5531 .config(|this| this.optional())
5532 .to_matchable(),
5533 Sequence::new(vec![
5534 Ref::keyword("NULLS").to_matchable(),
5535 Ref::keyword("NOT").optional().to_matchable(),
5536 Ref::keyword("DISTINCT").to_matchable(),
5537 ])
5538 .config(|this| this.optional())
5539 .to_matchable(),
5540 Sequence::new(vec![
5541 Ref::keyword("WITH").to_matchable(),
5542 Ref::new("RelationOptionsSegment").to_matchable(),
5543 ])
5544 .config(|this| this.optional())
5545 .to_matchable(),
5546 Sequence::new(vec![
5547 Ref::keyword("TABLESPACE").to_matchable(),
5548 Ref::new("TablespaceReferenceSegment").to_matchable(),
5549 ])
5550 .config(|this| this.optional())
5551 .to_matchable(),
5552 Sequence::new(vec![
5553 Ref::keyword("WHERE").to_matchable(),
5554 Ref::new("ExpressionSegment").to_matchable(),
5555 ])
5556 .config(|this| this.optional())
5557 .to_matchable(),
5558 ])
5559 .to_matchable(),
5560 );
5561
5562 postgres.add([(
5563 "AlterIndexStatementSegment".into(),
5564 NodeMatcher::new(SyntaxKind::AlterIndexStatement, |_| {
5565 Sequence::new(vec![
5566 Ref::keyword("ALTER").to_matchable(),
5567 Ref::keyword("INDEX").to_matchable(),
5568 one_of(vec![
5569 Sequence::new(vec![
5570 Ref::new("IfExistsGrammar").optional().to_matchable(),
5571 Ref::new("IndexReferenceSegment").to_matchable(),
5572 one_of(vec![
5573 Sequence::new(vec![
5574 Ref::keyword("RENAME").to_matchable(),
5575 Ref::keyword("TO").to_matchable(),
5576 Ref::new("IndexReferenceSegment").to_matchable(),
5577 ])
5578 .to_matchable(),
5579 Sequence::new(vec![
5580 Ref::keyword("SET").to_matchable(),
5581 Ref::keyword("TABLESPACE").to_matchable(),
5582 Ref::new("TablespaceReferenceSegment").to_matchable(),
5583 ])
5584 .to_matchable(),
5585 Sequence::new(vec![
5586 Ref::keyword("ATTACH").to_matchable(),
5587 Ref::keyword("PARTITION").to_matchable(),
5588 Ref::new("IndexReferenceSegment").to_matchable(),
5589 ])
5590 .to_matchable(),
5591 Sequence::new(vec![
5592 Ref::keyword("NO").optional().to_matchable(),
5593 Ref::keyword("DEPENDS").to_matchable(),
5594 Ref::keyword("ON").to_matchable(),
5595 Ref::keyword("EXTENSION").to_matchable(),
5596 Ref::new("ExtensionReferenceSegment").to_matchable(),
5597 ])
5598 .to_matchable(),
5599 Sequence::new(vec![
5600 Ref::keyword("SET").to_matchable(),
5601 Bracketed::new(vec![
5602 Delimited::new(vec![
5603 Sequence::new(vec![
5604 Ref::new("ParameterNameSegment").to_matchable(),
5605 Sequence::new(vec![
5606 Ref::new("EqualsSegment").to_matchable(),
5607 Ref::new("LiteralGrammar").to_matchable(),
5608 ])
5609 .config(|this| this.optional())
5610 .to_matchable(),
5611 ])
5612 .to_matchable(),
5613 ])
5614 .to_matchable(),
5615 ])
5616 .to_matchable(),
5617 ])
5618 .to_matchable(),
5619 Sequence::new(vec![
5620 Ref::keyword("RESET").to_matchable(),
5621 Bracketed::new(vec![
5622 Delimited::new(vec![
5623 Ref::new("ParameterNameSegment").to_matchable(),
5624 ])
5625 .to_matchable(),
5626 ])
5627 .to_matchable(),
5628 ])
5629 .to_matchable(),
5630 Sequence::new(vec![
5631 Ref::keyword("ALTER").to_matchable(),
5632 Ref::keyword("COLUMN").optional().to_matchable(),
5633 Ref::new("NumericLiteralSegment").to_matchable(),
5634 Ref::keyword("SET").to_matchable(),
5635 Ref::keyword("STATISTICS").to_matchable(),
5636 Ref::new("NumericLiteralSegment").to_matchable(),
5637 ])
5638 .to_matchable(),
5639 ])
5640 .to_matchable(),
5641 ])
5642 .to_matchable(),
5643 Sequence::new(vec![
5644 Ref::keyword("ALL").to_matchable(),
5645 Ref::keyword("IN").to_matchable(),
5646 Ref::keyword("TABLESPACE").to_matchable(),
5647 Ref::new("TablespaceReferenceSegment").to_matchable(),
5648 Sequence::new(vec![
5649 Ref::keyword("OWNED").to_matchable(),
5650 Ref::keyword("BY").to_matchable(),
5651 Delimited::new(vec![Ref::new("RoleReferenceSegment").to_matchable()])
5652 .to_matchable(),
5653 ])
5654 .config(|this| this.optional())
5655 .to_matchable(),
5656 Ref::keyword("SET").to_matchable(),
5657 Ref::keyword("TABLESPACE").to_matchable(),
5658 Ref::new("TablespaceReferenceSegment").to_matchable(),
5659 Ref::keyword("NOWAIT").optional().to_matchable(),
5660 ])
5661 .to_matchable(),
5662 ])
5663 .to_matchable(),
5664 ])
5665 .to_matchable()
5666 })
5667 .to_matchable()
5668 .into(),
5669 )]);
5670
5671 postgres.add([(
5672 "ReindexStatementSegment".into(),
5673 NodeMatcher::new(SyntaxKind::ReindexStatementSegment, |_| {
5674 Sequence::new(vec![
5675 Ref::keyword("REINDEX").to_matchable(),
5676 Bracketed::new(vec![
5677 Delimited::new(vec![
5678 Sequence::new(vec![
5679 Ref::keyword("CONCURRENTLY").to_matchable(),
5680 Ref::new("BooleanLiteralGrammar").optional().to_matchable(),
5681 ])
5682 .to_matchable(),
5683 Sequence::new(vec![
5684 Ref::keyword("TABLESPACE").to_matchable(),
5685 Ref::new("TablespaceReferenceSegment").to_matchable(),
5686 ])
5687 .to_matchable(),
5688 Sequence::new(vec![
5689 Ref::keyword("VERBOSE").to_matchable(),
5690 Ref::new("BooleanLiteralGrammar").optional().to_matchable(),
5691 ])
5692 .to_matchable(),
5693 ])
5694 .to_matchable(),
5695 ])
5696 .config(|this| this.optional())
5697 .to_matchable(),
5698 one_of(vec![
5699 Sequence::new(vec![
5700 Ref::keyword("INDEX").to_matchable(),
5701 Ref::keyword("CONCURRENTLY").optional().to_matchable(),
5702 Ref::new("IndexReferenceSegment").to_matchable(),
5703 ])
5704 .to_matchable(),
5705 Sequence::new(vec![
5706 Ref::keyword("TABLE").to_matchable(),
5707 Ref::keyword("CONCURRENTLY").optional().to_matchable(),
5708 Ref::new("TableReferenceSegment").to_matchable(),
5709 ])
5710 .to_matchable(),
5711 Sequence::new(vec![
5712 Ref::keyword("SCHEMA").to_matchable(),
5713 Ref::keyword("CONCURRENTLY").optional().to_matchable(),
5714 Ref::new("SchemaReferenceSegment").to_matchable(),
5715 ])
5716 .to_matchable(),
5717 Sequence::new(vec![
5718 one_of(vec![
5719 Ref::keyword("DATABASE").to_matchable(),
5720 Ref::keyword("SYSTEM").to_matchable(),
5721 ])
5722 .to_matchable(),
5723 Ref::keyword("CONCURRENTLY").optional().to_matchable(),
5724 Ref::new("DatabaseReferenceSegment").to_matchable(),
5725 ])
5726 .to_matchable(),
5727 ])
5728 .to_matchable(),
5729 ])
5730 .to_matchable()
5731 })
5732 .to_matchable()
5733 .into(),
5734 )]);
5735
5736 postgres.replace_grammar(
5737 "DropIndexStatementSegment",
5738 Sequence::new(vec![
5739 Ref::keyword("DROP").to_matchable(),
5740 Ref::keyword("INDEX").to_matchable(),
5741 Ref::keyword("CONCURRENTLY").optional().to_matchable(),
5742 Ref::new("IfExistsGrammar").optional().to_matchable(),
5743 Delimited::new(vec![Ref::new("IndexReferenceSegment").to_matchable()]).to_matchable(),
5744 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
5745 ])
5746 .to_matchable(),
5747 );
5748
5749 postgres.replace_grammar(
5750 "FrameClauseSegment",
5751 {
5752 let frame_extent = ansi::frame_extent();
5753
5754 let frame_exclusion = Sequence::new(vec![
5755 Ref::keyword("EXCLUDE").to_matchable(),
5756 one_of(vec![
5757 Sequence::new(vec![
5758 Ref::keyword("CURRENT").to_matchable(),
5759 Ref::keyword("ROW").to_matchable(),
5760 ])
5761 .to_matchable(),
5762 Ref::keyword("GROUP").to_matchable(),
5763 Ref::keyword("TIES").to_matchable(),
5764 Sequence::new(vec![
5765 Ref::keyword("NO").to_matchable(),
5766 Ref::keyword("OTHERS").to_matchable(),
5767 ])
5768 .to_matchable(),
5769 ])
5770 .to_matchable(),
5771 ])
5772 .config(|this| this.optional());
5773
5774 Sequence::new(vec![
5775 Ref::new("FrameClauseUnitGrammar").to_matchable(),
5776 one_of(vec![
5777 frame_extent.clone().to_matchable(),
5778 Sequence::new(vec![
5779 Ref::keyword("BETWEEN").to_matchable(),
5780 frame_extent.clone().to_matchable(),
5781 Ref::keyword("AND").to_matchable(),
5782 frame_extent.clone().to_matchable(),
5783 ])
5784 .to_matchable(),
5785 ])
5786 .to_matchable(),
5787 frame_exclusion.to_matchable(),
5788 ])
5789 }
5790 .to_matchable(),
5791 );
5792
5793 postgres.replace_grammar(
5794 "CreateSequenceOptionsSegment",
5795 one_of(vec![
5796 Sequence::new(vec![
5797 Ref::keyword("AS").to_matchable(),
5798 Ref::new("DatatypeSegment").to_matchable(),
5799 ])
5800 .to_matchable(),
5801 Sequence::new(vec![
5802 Ref::keyword("INCREMENT").to_matchable(),
5803 Ref::keyword("BY").optional().to_matchable(),
5804 Ref::new("NumericLiteralSegment").to_matchable(),
5805 ])
5806 .to_matchable(),
5807 one_of(vec![
5808 Sequence::new(vec![
5809 Ref::keyword("MINVALUE").to_matchable(),
5810 Ref::new("NumericLiteralSegment").to_matchable(),
5811 ])
5812 .to_matchable(),
5813 Sequence::new(vec![
5814 Ref::keyword("NO").to_matchable(),
5815 Ref::keyword("MINVALUE").to_matchable(),
5816 ])
5817 .to_matchable(),
5818 ])
5819 .to_matchable(),
5820 one_of(vec![
5821 Sequence::new(vec![
5822 Ref::keyword("MAXVALUE").to_matchable(),
5823 Ref::new("NumericLiteralSegment").to_matchable(),
5824 ])
5825 .to_matchable(),
5826 Sequence::new(vec![
5827 Ref::keyword("NO").to_matchable(),
5828 Ref::keyword("MAXVALUE").to_matchable(),
5829 ])
5830 .to_matchable(),
5831 ])
5832 .to_matchable(),
5833 Sequence::new(vec![
5834 Ref::keyword("START").to_matchable(),
5835 Ref::keyword("WITH").optional().to_matchable(),
5836 Ref::new("NumericLiteralSegment").to_matchable(),
5837 ])
5838 .to_matchable(),
5839 Sequence::new(vec![
5840 Ref::keyword("CACHE").to_matchable(),
5841 Ref::new("NumericLiteralSegment").to_matchable(),
5842 ])
5843 .to_matchable(),
5844 one_of(vec![
5845 Ref::keyword("CYCLE").to_matchable(),
5846 Sequence::new(vec![
5847 Ref::keyword("NO").to_matchable(),
5848 Ref::keyword("CYCLE").to_matchable(),
5849 ])
5850 .to_matchable(),
5851 ])
5852 .to_matchable(),
5853 Sequence::new(vec![
5854 Ref::keyword("OWNED").to_matchable(),
5855 Ref::keyword("BY").to_matchable(),
5856 one_of(vec![
5857 Ref::keyword("NONE").to_matchable(),
5858 Ref::new("ColumnReferenceSegment").to_matchable(),
5859 ])
5860 .to_matchable(),
5861 ])
5862 .to_matchable(),
5863 ])
5864 .to_matchable(),
5865 );
5866
5867 postgres.add([(
5868 "CreateSequenceStatementSegment".into(),
5869 NodeMatcher::new(SyntaxKind::CreateSequenceStatement, |_| {
5870 Sequence::new(vec![
5871 Ref::keyword("CREATE").to_matchable(),
5872 Ref::new("TemporaryGrammar").optional().to_matchable(),
5873 Ref::keyword("SEQUENCE").to_matchable(),
5874 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
5875 Ref::new("SequenceReferenceSegment").to_matchable(),
5876 AnyNumberOf::new(vec![
5877 Ref::new("CreateSequenceOptionsSegment").to_matchable(),
5878 ])
5879 .config(|this| this.optional())
5880 .to_matchable(),
5881 ])
5882 .to_matchable()
5883 })
5884 .to_matchable()
5885 .into(),
5886 )]);
5887
5888 postgres.replace_grammar(
5889 "AlterSequenceOptionsSegment",
5890 one_of(vec![
5891 Sequence::new(vec![
5892 Ref::keyword("AS").to_matchable(),
5893 Ref::new("DatatypeSegment").to_matchable(),
5894 ])
5895 .to_matchable(),
5896 Sequence::new(vec![
5897 Ref::keyword("INCREMENT").to_matchable(),
5898 Ref::keyword("BY").optional().to_matchable(),
5899 Ref::new("NumericLiteralSegment").to_matchable(),
5900 ])
5901 .to_matchable(),
5902 one_of(vec![
5903 Sequence::new(vec![
5904 Ref::keyword("MINVALUE").to_matchable(),
5905 Ref::new("NumericLiteralSegment").to_matchable(),
5906 ])
5907 .to_matchable(),
5908 Sequence::new(vec![
5909 Ref::keyword("NO").to_matchable(),
5910 Ref::keyword("MINVALUE").to_matchable(),
5911 ])
5912 .to_matchable(),
5913 ])
5914 .to_matchable(),
5915 one_of(vec![
5916 Sequence::new(vec![
5917 Ref::keyword("MAXVALUE").to_matchable(),
5918 Ref::new("NumericLiteralSegment").to_matchable(),
5919 ])
5920 .to_matchable(),
5921 Sequence::new(vec![
5922 Ref::keyword("NO").to_matchable(),
5923 Ref::keyword("MAXVALUE").to_matchable(),
5924 ])
5925 .to_matchable(),
5926 ])
5927 .to_matchable(),
5928 Sequence::new(vec![
5929 Ref::keyword("SEQUENCE").to_matchable(),
5930 Ref::keyword("NAME").to_matchable(),
5931 Ref::new("SequenceReferenceSegment").to_matchable(),
5932 ])
5933 .to_matchable(),
5934 Sequence::new(vec![
5935 Ref::keyword("START").to_matchable(),
5936 Ref::keyword("WITH").optional().to_matchable(),
5937 Ref::new("NumericLiteralSegment").to_matchable(),
5938 ])
5939 .to_matchable(),
5940 Sequence::new(vec![
5941 Ref::keyword("RESTART").to_matchable(),
5942 Ref::keyword("WITH").optional().to_matchable(),
5943 Ref::new("NumericLiteralSegment").to_matchable(),
5944 ])
5945 .to_matchable(),
5946 Sequence::new(vec![
5947 Ref::keyword("CACHE").to_matchable(),
5948 Ref::new("NumericLiteralSegment").to_matchable(),
5949 ])
5950 .to_matchable(),
5951 Sequence::new(vec![
5952 Ref::keyword("NO").optional().to_matchable(),
5953 Ref::keyword("CYCLE").to_matchable(),
5954 ])
5955 .to_matchable(),
5956 Sequence::new(vec![
5957 Ref::keyword("OWNED").to_matchable(),
5958 Ref::keyword("BY").to_matchable(),
5959 one_of(vec![
5960 Ref::keyword("NONE").to_matchable(),
5961 Ref::new("ColumnReferenceSegment").to_matchable(),
5962 ])
5963 .to_matchable(),
5964 ])
5965 .to_matchable(),
5966 ])
5967 .to_matchable(),
5968 );
5969
5970 postgres.replace_grammar(
5971 "AlterSequenceStatementSegment",
5972 Sequence::new(vec![
5973 Ref::keyword("ALTER").to_matchable(),
5974 Ref::keyword("SEQUENCE").to_matchable(),
5975 Ref::new("IfExistsGrammar").optional().to_matchable(),
5976 Ref::new("SequenceReferenceSegment").to_matchable(),
5977 one_of(vec![
5978 AnyNumberOf::new(vec![Ref::new("AlterSequenceOptionsSegment").to_matchable()])
5979 .config(|this| this.optional())
5980 .to_matchable(),
5981 Sequence::new(vec![
5982 Ref::keyword("OWNER").to_matchable(),
5983 Ref::keyword("TO").to_matchable(),
5984 one_of(vec![
5985 Ref::new("ParameterNameSegment").to_matchable(),
5986 Ref::keyword("CURRENT_USER").to_matchable(),
5987 Ref::keyword("SESSION_USER").to_matchable(),
5988 ])
5989 .to_matchable(),
5990 ])
5991 .to_matchable(),
5992 Sequence::new(vec![
5993 Ref::keyword("RENAME").to_matchable(),
5994 Ref::keyword("TO").to_matchable(),
5995 Ref::new("SequenceReferenceSegment").to_matchable(),
5996 ])
5997 .to_matchable(),
5998 Sequence::new(vec![
5999 Ref::keyword("SET").to_matchable(),
6000 Ref::keyword("SCHEMA").to_matchable(),
6001 Ref::new("SchemaReferenceSegment").to_matchable(),
6002 ])
6003 .to_matchable(),
6004 ])
6005 .to_matchable(),
6006 ])
6007 .to_matchable(),
6008 );
6009
6010 postgres.replace_grammar(
6011 "DropSequenceStatementSegment",
6012 Sequence::new(vec![
6013 Ref::keyword("DROP").to_matchable(),
6014 Ref::keyword("SEQUENCE").to_matchable(),
6015 Ref::new("IfExistsGrammar").optional().to_matchable(),
6016 Delimited::new(vec![Ref::new("SequenceReferenceSegment").to_matchable()])
6017 .to_matchable(),
6018 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
6019 ])
6020 .to_matchable(),
6021 );
6022
6023 postgres.add([(
6024 "AnalyzeStatementSegment".into(),
6025 NodeMatcher::new(SyntaxKind::AnalyzeStatement, |_| {
6026 {
6027 let option = Sequence::new(vec![
6028 one_of(vec![
6029 Ref::keyword("VERBOSE").to_matchable(),
6030 Ref::keyword("SKIP_LOCKED").to_matchable(),
6031 ])
6032 .to_matchable(),
6033 Ref::new("BooleanLiteralGrammar").optional().to_matchable(),
6034 ]);
6035
6036 let tables_and_columns = Sequence::new(vec![
6037 Ref::new("TableReferenceSegment").to_matchable(),
6038 Bracketed::new(vec![
6039 Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
6040 .to_matchable(),
6041 ])
6042 .config(|this| this.optional())
6043 .to_matchable(),
6044 ]);
6045
6046 Sequence::new(vec![
6047 one_of(vec![
6048 Ref::keyword("ANALYZE").to_matchable(),
6049 Ref::keyword("ANALYSE").to_matchable(),
6050 ])
6051 .to_matchable(),
6052 one_of(vec![
6053 Bracketed::new(vec![
6054 Delimited::new(vec![option.to_matchable()]).to_matchable(),
6055 ])
6056 .to_matchable(),
6057 Ref::keyword("VERBOSE").to_matchable(),
6058 ])
6059 .config(|this| this.optional())
6060 .to_matchable(),
6061 Delimited::new(vec![tables_and_columns.to_matchable()])
6062 .config(|this| this.optional())
6063 .to_matchable(),
6064 ])
6065 }
6066 .to_matchable()
6067 })
6068 .to_matchable()
6069 .into(),
6070 )]);
6071
6072 postgres.replace_grammar("StatementSegment", statement_segment());
6073
6074 postgres.replace_grammar(
6075 "CreateTriggerStatementSegment",
6076 Sequence::new(vec![
6077 Ref::keyword("CREATE").to_matchable(),
6078 Sequence::new(vec![
6079 Ref::keyword("OR").to_matchable(),
6080 Ref::keyword("REPLACE").to_matchable(),
6081 ])
6082 .config(|this| this.optional())
6083 .to_matchable(),
6084 Ref::keyword("CONSTRAINT").optional().to_matchable(),
6085 Ref::keyword("TRIGGER").to_matchable(),
6086 Ref::new("TriggerReferenceSegment").to_matchable(),
6087 one_of(vec![
6088 Ref::keyword("BEFORE").to_matchable(),
6089 Ref::keyword("AFTER").to_matchable(),
6090 Sequence::new(vec![
6091 Ref::keyword("INSTEAD").to_matchable(),
6092 Ref::keyword("OF").to_matchable(),
6093 ])
6094 .to_matchable(),
6095 ])
6096 .to_matchable(),
6097 Delimited::new(vec![
6098 Ref::keyword("INSERT").to_matchable(),
6099 Ref::keyword("DELETE").to_matchable(),
6100 Ref::keyword("TRUNCATE").to_matchable(),
6101 Sequence::new(vec![
6102 Ref::keyword("UPDATE").to_matchable(),
6103 Sequence::new(vec![
6104 Ref::keyword("OF").to_matchable(),
6105 Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
6106 .config(|this| {
6107 this.terminators = vec![
6108 Ref::keyword("OR").to_matchable(),
6109 Ref::keyword("ON").to_matchable(),
6110 ];
6111 this.optional();
6112 })
6113 .to_matchable(),
6114 ])
6115 .config(|this| this.optional())
6116 .to_matchable(),
6117 ])
6118 .to_matchable(),
6119 ])
6120 .config(|this| this.delimiter(Ref::keyword("OR")))
6121 .to_matchable(),
6122 Ref::keyword("ON").to_matchable(),
6123 Ref::new("TableReferenceSegment").to_matchable(),
6124 AnyNumberOf::new(vec![
6125 Sequence::new(vec![
6126 Ref::keyword("FROM").to_matchable(),
6127 Ref::new("TableReferenceSegment").to_matchable(),
6128 ])
6129 .to_matchable(),
6130 one_of(vec![
6131 Sequence::new(vec![
6132 Ref::keyword("NOT").to_matchable(),
6133 Ref::keyword("DEFERRABLE").to_matchable(),
6134 ])
6135 .to_matchable(),
6136 Sequence::new(vec![
6137 Ref::keyword("DEFERRABLE").optional().to_matchable(),
6138 one_of(vec![
6139 Sequence::new(vec![
6140 Ref::keyword("INITIALLY").to_matchable(),
6141 Ref::keyword("IMMEDIATE").to_matchable(),
6142 ])
6143 .to_matchable(),
6144 Sequence::new(vec![
6145 Ref::keyword("INITIALLY").to_matchable(),
6146 Ref::keyword("DEFERRED").to_matchable(),
6147 ])
6148 .to_matchable(),
6149 ])
6150 .to_matchable(),
6151 ])
6152 .to_matchable(),
6153 ])
6154 .to_matchable(),
6155 Sequence::new(vec![
6156 Ref::keyword("REFERENCING").to_matchable(),
6157 one_of(vec![
6158 Ref::keyword("OLD").to_matchable(),
6159 Ref::keyword("NEW").to_matchable(),
6160 ])
6161 .to_matchable(),
6162 Ref::keyword("TABLE").to_matchable(),
6163 Ref::keyword("AS").to_matchable(),
6164 Ref::new("TableReferenceSegment").to_matchable(),
6165 Sequence::new(vec![
6166 one_of(vec![
6167 Ref::keyword("OLD").to_matchable(),
6168 Ref::keyword("NEW").to_matchable(),
6169 ])
6170 .to_matchable(),
6171 Ref::keyword("TABLE").to_matchable(),
6172 Ref::keyword("AS").to_matchable(),
6173 Ref::new("TableReferenceSegment").to_matchable(),
6174 ])
6175 .config(|this| this.optional())
6176 .to_matchable(),
6177 ])
6178 .to_matchable(),
6179 Sequence::new(vec![
6180 Ref::keyword("FOR").to_matchable(),
6181 Ref::keyword("EACH").optional().to_matchable(),
6182 one_of(vec![
6183 Ref::keyword("ROW").to_matchable(),
6184 Ref::keyword("STATEMENT").to_matchable(),
6185 ])
6186 .to_matchable(),
6187 ])
6188 .to_matchable(),
6189 Sequence::new(vec![
6190 Ref::keyword("WHEN").to_matchable(),
6191 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
6192 .to_matchable(),
6193 ])
6194 .to_matchable(),
6195 ])
6196 .to_matchable(),
6197 Sequence::new(vec![
6198 Ref::keyword("EXECUTE").to_matchable(),
6199 one_of(vec![
6200 Ref::keyword("FUNCTION").to_matchable(),
6201 Ref::keyword("PROCEDURE").to_matchable(),
6202 ])
6203 .to_matchable(),
6204 Ref::new("FunctionSegment").to_matchable(),
6205 ])
6206 .to_matchable(),
6207 ])
6208 .to_matchable(),
6209 );
6210
6211 postgres.add([(
6212 "AlterTriggerStatementSegment".into(),
6213 NodeMatcher::new(SyntaxKind::AlterTrigger, |_| {
6214 Sequence::new(vec![
6215 Ref::keyword("ALTER").to_matchable(),
6216 Ref::keyword("TRIGGER").to_matchable(),
6217 Ref::new("TriggerReferenceSegment").to_matchable(),
6218 Ref::keyword("ON").to_matchable(),
6219 Ref::new("TableReferenceSegment").to_matchable(),
6220 one_of(vec![
6221 Sequence::new(vec![
6222 Ref::keyword("RENAME").to_matchable(),
6223 Ref::keyword("TO").to_matchable(),
6224 Ref::new("TriggerReferenceSegment").to_matchable(),
6225 ])
6226 .to_matchable(),
6227 Sequence::new(vec![
6228 Ref::keyword("NO").optional().to_matchable(),
6229 Ref::keyword("DEPENDS").to_matchable(),
6230 Ref::keyword("ON").to_matchable(),
6231 Ref::keyword("EXTENSION").to_matchable(),
6232 Ref::new("ExtensionReferenceSegment").to_matchable(),
6233 ])
6234 .to_matchable(),
6235 ])
6236 .to_matchable(),
6237 ])
6238 .to_matchable()
6239 })
6240 .to_matchable()
6241 .into(),
6242 )]);
6243
6244 postgres.replace_grammar(
6245 "DropTriggerStatementSegment",
6246 Sequence::new(vec![
6247 Ref::keyword("DROP").to_matchable(),
6248 Ref::keyword("TRIGGER").to_matchable(),
6249 Ref::new("IfExistsGrammar").optional().to_matchable(),
6250 Ref::new("TriggerReferenceSegment").to_matchable(),
6251 Ref::keyword("ON").to_matchable(),
6252 Ref::new("TableReferenceSegment").to_matchable(),
6253 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
6254 ])
6255 .to_matchable(),
6256 );
6257
6258 postgres.replace_grammar(
6259 "AliasExpressionSegment",
6260 Sequence::new(vec![
6261 Ref::keyword("AS").optional().to_matchable(),
6262 one_of(vec![
6263 Sequence::new(vec![
6264 Ref::new("SingleIdentifierGrammar").to_matchable(),
6265 Bracketed::new(vec![Ref::new("SingleIdentifierListSegment").to_matchable()])
6266 .config(|this| this.optional())
6267 .to_matchable(),
6268 ])
6269 .to_matchable(),
6270 Sequence::new(vec![
6271 Ref::new("SingleIdentifierGrammar")
6272 .optional()
6273 .to_matchable(),
6274 Bracketed::new(vec![
6275 Delimited::new(vec![
6276 Sequence::new(vec![
6277 Ref::new("ParameterNameSegment").to_matchable(),
6278 Ref::new("DatatypeSegment").to_matchable(),
6279 ])
6280 .to_matchable(),
6281 ])
6282 .to_matchable(),
6283 ])
6284 .to_matchable(),
6285 ])
6286 .to_matchable(),
6287 ])
6288 .to_matchable(),
6289 ])
6290 .to_matchable(),
6291 );
6292
6293 postgres.add([(
6294 "AsAliasExpressionSegment".into(),
6295 NodeMatcher::new(SyntaxKind::AliasExpression, |_| {
6296 Sequence::new(vec![
6297 MetaSegment::indent().to_matchable(),
6298 Ref::keyword("AS").to_matchable(),
6299 Ref::new("SingleIdentifierGrammar").to_matchable(),
6300 MetaSegment::dedent().to_matchable(),
6301 ])
6302 .to_matchable()
6303 })
6304 .to_matchable()
6305 .into(),
6306 )]);
6307
6308 postgres.add([(
6309 "OperationClassReferenceSegment".into(),
6310 NodeMatcher::new(SyntaxKind::OperationClassReference, |postgres| {
6311 postgres
6312 .grammar("ObjectReferenceSegment")
6313 .match_grammar(postgres)
6314 .unwrap()
6315 })
6316 .to_matchable()
6317 .into(),
6318 )]);
6319
6320 postgres.add([
6321 (
6322 "ConflictActionSegment".into(),
6323 NodeMatcher::new(SyntaxKind::ConflictAction, |_| {
6324 Sequence::new(vec![
6325 Ref::keyword("DO").to_matchable(),
6326 one_of(vec![
6327 Ref::keyword("NOTHING").to_matchable(),
6328 Sequence::new(vec![
6329 Ref::keyword("UPDATE").to_matchable(),
6330 Ref::keyword("SET").to_matchable(),
6331 Delimited::new(vec![
6332 one_of(vec![
6333 Sequence::new(vec![
6334 Ref::new("ColumnReferenceSegment").to_matchable(),
6335 Ref::new("EqualsSegment").to_matchable(),
6336 one_of(vec![
6337 Ref::new("ExpressionSegment").to_matchable(),
6338 Ref::keyword("DEFAULT").to_matchable(),
6339 ])
6340 .to_matchable(),
6341 ])
6342 .to_matchable(),
6343 Sequence::new(vec![
6344 Bracketed::new(vec![
6345 Delimited::new(vec![
6346 Ref::new("ColumnReferenceSegment").to_matchable(),
6347 ])
6348 .to_matchable(),
6349 ])
6350 .to_matchable(),
6351 Ref::new("EqualsSegment").to_matchable(),
6352 Ref::keyword("ROW").optional().to_matchable(),
6353 Bracketed::new(vec![
6354 Delimited::new(vec![
6355 one_of(vec![
6356 Ref::new("ExpressionSegment").to_matchable(),
6357 Ref::keyword("DEFAULT").to_matchable(),
6358 ])
6359 .to_matchable(),
6360 ])
6361 .to_matchable(),
6362 ])
6363 .to_matchable(),
6364 ])
6365 .to_matchable(),
6366 Sequence::new(vec![
6367 Bracketed::new(vec![
6368 Delimited::new(vec![
6369 Ref::new("ColumnReferenceSegment").to_matchable(),
6370 ])
6371 .to_matchable(),
6372 ])
6373 .to_matchable(),
6374 Ref::new("EqualsSegment").to_matchable(),
6375 Bracketed::new(vec![
6376 Ref::new("SelectableGrammar").to_matchable(),
6377 ])
6378 .to_matchable(),
6379 ])
6380 .to_matchable(),
6381 ])
6382 .to_matchable(),
6383 ])
6384 .to_matchable(),
6385 Sequence::new(vec![
6386 Ref::keyword("WHERE").to_matchable(),
6387 Ref::new("ExpressionSegment").to_matchable(),
6388 ])
6389 .config(|this| this.optional())
6390 .to_matchable(),
6391 ])
6392 .to_matchable(),
6393 ])
6394 .to_matchable(),
6395 ])
6396 .to_matchable()
6397 })
6398 .to_matchable()
6399 .into(),
6400 ),
6401 (
6402 "ConflictTargetSegment".into(),
6403 NodeMatcher::new(SyntaxKind::ConflictTarget, |_| {
6404 one_of(vec![
6405 Sequence::new(vec![
6406 Bracketed::new(vec![
6407 Delimited::new(vec![
6408 Sequence::new(vec![
6409 one_of(vec![
6410 Ref::new("ColumnReferenceSegment").to_matchable(),
6411 Bracketed::new(vec![
6412 Ref::new("ExpressionSegment").to_matchable(),
6413 ])
6414 .to_matchable(),
6415 ])
6416 .to_matchable(),
6417 Sequence::new(vec![
6418 Ref::keyword("COLLATE").to_matchable(),
6419 Ref::new("CollationReferenceSegment").to_matchable(),
6420 ])
6421 .config(|this| this.optional())
6422 .to_matchable(),
6423 Ref::new("OperationClassReferenceSegment")
6424 .optional()
6425 .to_matchable(),
6426 ])
6427 .to_matchable(),
6428 ])
6429 .to_matchable(),
6430 ])
6431 .to_matchable(),
6432 Sequence::new(vec![
6433 Ref::keyword("WHERE").to_matchable(),
6434 Ref::new("ExpressionSegment").to_matchable(),
6435 ])
6436 .config(|this| this.optional())
6437 .to_matchable(),
6438 ])
6439 .to_matchable(),
6440 Sequence::new(vec![
6441 Ref::keyword("ON").to_matchable(),
6442 Ref::keyword("CONSTRAINT").to_matchable(),
6443 Ref::new("ParameterNameSegment").to_matchable(),
6444 ])
6445 .to_matchable(),
6446 ])
6447 .to_matchable()
6448 })
6449 .to_matchable()
6450 .into(),
6451 ),
6452 ]);
6453
6454 postgres.replace_grammar(
6455 "InsertStatementSegment",
6456 Sequence::new(vec![
6457 Ref::keyword("INSERT").to_matchable(),
6458 Ref::keyword("INTO").to_matchable(),
6459 Ref::new("TableReferenceSegment").to_matchable(),
6460 Ref::new("AsAliasExpressionSegment")
6461 .optional()
6462 .to_matchable(),
6463 Ref::new("BracketedColumnReferenceListGrammar")
6464 .optional()
6465 .to_matchable(),
6466 Sequence::new(vec![
6467 Ref::keyword("OVERRIDING").to_matchable(),
6468 one_of(vec![
6469 Ref::keyword("SYSTEM").to_matchable(),
6470 Ref::keyword("USER").to_matchable(),
6471 ])
6472 .to_matchable(),
6473 Ref::keyword("VALUE").to_matchable(),
6474 ])
6475 .config(|this| this.optional())
6476 .to_matchable(),
6477 one_of(vec![
6478 Sequence::new(vec![
6479 Ref::keyword("DEFAULT").to_matchable(),
6480 Ref::keyword("VALUES").to_matchable(),
6481 ])
6482 .to_matchable(),
6483 Ref::new("SelectableGrammar").to_matchable(),
6484 ])
6485 .to_matchable(),
6486 Sequence::new(vec![
6487 Ref::keyword("ON").to_matchable(),
6488 Ref::keyword("CONFLICT").to_matchable(),
6489 Ref::new("ConflictTargetSegment").optional().to_matchable(),
6490 Ref::new("ConflictActionSegment").to_matchable(),
6491 ])
6492 .config(|this| this.optional())
6493 .to_matchable(),
6494 Sequence::new(vec![
6495 Ref::keyword("RETURNING").to_matchable(),
6496 MetaSegment::indent().to_matchable(),
6497 one_of(vec![
6498 Ref::new("StarSegment").to_matchable(),
6499 Delimited::new(vec![
6500 Sequence::new(vec![
6501 Ref::new("ExpressionSegment").to_matchable(),
6502 Ref::new("AsAliasExpressionSegment")
6503 .optional()
6504 .to_matchable(),
6505 ])
6506 .to_matchable(),
6507 ])
6508 .to_matchable(),
6509 ])
6510 .to_matchable(),
6511 MetaSegment::dedent().to_matchable(),
6512 ])
6513 .config(|this| this.optional())
6514 .to_matchable(),
6515 ])
6516 .to_matchable(),
6517 );
6518
6519 postgres.replace_grammar(
6520 "DropTypeStatementSegment",
6521 Sequence::new(vec![
6522 Ref::keyword("DROP").to_matchable(),
6523 Ref::keyword("TYPE").to_matchable(),
6524 Ref::new("IfExistsGrammar").optional().to_matchable(),
6525 Delimited::new(vec![Ref::new("DatatypeSegment").to_matchable()]).to_matchable(),
6526 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
6527 ])
6528 .to_matchable(),
6529 );
6530
6531 postgres.add([
6532 (
6533 "SetStatementSegment".into(),
6534 NodeMatcher::new(SyntaxKind::SetStatement, |_| {
6535 Sequence::new(vec![
6536 Ref::keyword("SET").to_matchable(),
6537 one_of(vec![
6538 Ref::keyword("SESSION").to_matchable(),
6539 Ref::keyword("LOCAL").to_matchable(),
6540 ])
6541 .config(|this| this.optional())
6542 .to_matchable(),
6543 one_of(vec![
6544 Sequence::new(vec![
6545 Ref::new("ParameterNameSegment").to_matchable(),
6546 one_of(vec![
6547 Ref::keyword("TO").to_matchable(),
6548 Ref::new("EqualsSegment").to_matchable(),
6549 ])
6550 .to_matchable(),
6551 one_of(vec![
6552 Ref::keyword("DEFAULT").to_matchable(),
6553 Delimited::new(vec![
6554 Ref::new("LiteralGrammar").to_matchable(),
6555 Ref::new("NakedIdentifierSegment").to_matchable(),
6556 Ref::new("QuotedIdentifierSegment").to_matchable(),
6557 Ref::new("OnKeywordAsIdentifierSegment").to_matchable(),
6558 ])
6559 .to_matchable(),
6560 ])
6561 .to_matchable(),
6562 ])
6563 .to_matchable(),
6564 Sequence::new(vec![
6565 Ref::keyword("TIME").to_matchable(),
6566 Ref::keyword("ZONE").to_matchable(),
6567 one_of(vec![
6568 Ref::new("QuotedLiteralSegment").to_matchable(),
6569 Ref::keyword("LOCAL").to_matchable(),
6570 Ref::keyword("DEFAULT").to_matchable(),
6571 ])
6572 .to_matchable(),
6573 ])
6574 .to_matchable(),
6575 Sequence::new(vec![
6576 Ref::keyword("SCHEMA").to_matchable(),
6577 Ref::new("QuotedLiteralSegment").to_matchable(),
6578 ])
6579 .to_matchable(),
6580 Sequence::new(vec![
6581 Ref::keyword("ROLE").to_matchable(),
6582 one_of(vec![
6583 Ref::keyword("NONE").to_matchable(),
6584 Ref::new("RoleReferenceSegment").to_matchable(),
6585 ])
6586 .to_matchable(),
6587 ])
6588 .to_matchable(),
6589 ])
6590 .to_matchable(),
6591 ])
6592 .to_matchable()
6593 })
6594 .to_matchable()
6595 .into(),
6596 ),
6597 (
6598 "CreatePolicyStatementSegment".into(),
6599 NodeMatcher::new(SyntaxKind::CreatePolicyStatement, |_| {
6600 Sequence::new(vec![
6601 Ref::keyword("CREATE").to_matchable(),
6602 Ref::keyword("POLICY").to_matchable(),
6603 Ref::new("ObjectReferenceSegment").to_matchable(),
6604 Ref::keyword("ON").to_matchable(),
6605 Ref::new("TableReferenceSegment").to_matchable(),
6606 Sequence::new(vec![
6607 Ref::keyword("AS").to_matchable(),
6608 one_of(vec![
6609 Ref::keyword("PERMISSIVE").to_matchable(),
6610 Ref::keyword("RESTRICTIVE").to_matchable(),
6611 ])
6612 .to_matchable(),
6613 ])
6614 .config(|this| this.optional())
6615 .to_matchable(),
6616 Sequence::new(vec![
6617 Ref::keyword("FOR").to_matchable(),
6618 one_of(vec![
6619 Ref::keyword("ALL").to_matchable(),
6620 Ref::keyword("SELECT").to_matchable(),
6621 Ref::keyword("INSERT").to_matchable(),
6622 Ref::keyword("UPDATE").to_matchable(),
6623 Ref::keyword("DELETE").to_matchable(),
6624 ])
6625 .to_matchable(),
6626 ])
6627 .config(|this| this.optional())
6628 .to_matchable(),
6629 Sequence::new(vec![
6630 Ref::keyword("TO").to_matchable(),
6631 Delimited::new(vec![
6632 one_of(vec![
6633 Ref::new("ObjectReferenceSegment").to_matchable(),
6634 Ref::keyword("PUBLIC").to_matchable(),
6635 Ref::keyword("CURRENT_ROLE").to_matchable(),
6636 Ref::keyword("CURRENT_USER").to_matchable(),
6637 Ref::keyword("SESSION_USER").to_matchable(),
6638 ])
6639 .to_matchable(),
6640 ])
6641 .to_matchable(),
6642 ])
6643 .config(|this| this.optional())
6644 .to_matchable(),
6645 Sequence::new(vec![
6646 Ref::keyword("USING").to_matchable(),
6647 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
6648 .to_matchable(),
6649 ])
6650 .config(|this| this.optional())
6651 .to_matchable(),
6652 Sequence::new(vec![
6653 Ref::keyword("WITH").to_matchable(),
6654 Ref::keyword("CHECK").to_matchable(),
6655 Bracketed::new(vec![Ref::new("ExpressionSegment").to_matchable()])
6656 .to_matchable(),
6657 ])
6658 .config(|this| this.optional())
6659 .to_matchable(),
6660 ])
6661 .to_matchable()
6662 })
6663 .to_matchable()
6664 .into(),
6665 ),
6666 (
6667 "CallStoredProcedureSegment".into(),
6668 NodeMatcher::new(SyntaxKind::CallStatement, |_| {
6669 Sequence::new(vec![
6670 Ref::keyword("CALL").to_matchable(),
6671 Ref::new("FunctionSegment").to_matchable(),
6672 ])
6673 .to_matchable()
6674 })
6675 .to_matchable()
6676 .into(),
6677 ),
6678 (
6679 "CreateDomainStatementSegment".into(),
6680 NodeMatcher::new(SyntaxKind::CreateDomainStatement, |_| {
6681 Sequence::new(vec![
6682 Ref::keyword("CREATE").to_matchable(),
6683 Ref::keyword("DOMAIN").to_matchable(),
6684 Ref::new("ObjectReferenceSegment").to_matchable(),
6685 Sequence::new(vec![Ref::keyword("AS").to_matchable()])
6686 .config(|this| this.optional())
6687 .to_matchable(),
6688 Ref::new("DatatypeSegment").to_matchable(),
6689 Sequence::new(vec![
6690 Ref::keyword("COLLATE").to_matchable(),
6691 Ref::new("CollationReferenceSegment").to_matchable(),
6692 ])
6693 .config(|this| this.optional())
6694 .to_matchable(),
6695 Sequence::new(vec![
6696 Ref::keyword("DEFAULT").to_matchable(),
6697 Ref::new("ExpressionSegment").to_matchable(),
6698 ])
6699 .config(|this| this.optional())
6700 .to_matchable(),
6701 AnyNumberOf::new(vec![
6702 Sequence::new(vec![
6703 Sequence::new(vec![
6704 Ref::keyword("CONSTRAINT").to_matchable(),
6705 Ref::new("ObjectReferenceSegment").to_matchable(),
6706 ])
6707 .config(|this| this.optional())
6708 .to_matchable(),
6709 one_of(vec![
6710 Sequence::new(vec![
6711 Ref::keyword("NOT").optional().to_matchable(),
6712 Ref::keyword("NULL").to_matchable(),
6713 ])
6714 .to_matchable(),
6715 Sequence::new(vec![
6716 Ref::keyword("CHECK").to_matchable(),
6717 Ref::new("ExpressionSegment").to_matchable(),
6718 ])
6719 .to_matchable(),
6720 ])
6721 .to_matchable(),
6722 ])
6723 .to_matchable(),
6724 ])
6725 .to_matchable(),
6726 ])
6727 .to_matchable()
6728 })
6729 .to_matchable()
6730 .into(),
6731 ),
6732 (
6733 "AlterDomainStatementSegment".into(),
6734 NodeMatcher::new(SyntaxKind::AlterDomainStatement, |_| {
6735 Sequence::new(vec![
6736 Ref::keyword("ALTER").to_matchable(),
6737 Ref::keyword("DOMAIN").to_matchable(),
6738 Ref::new("ObjectReferenceSegment").to_matchable(),
6739 one_of(vec![
6740 Sequence::new(vec![
6741 Ref::keyword("SET").to_matchable(),
6742 Ref::keyword("DEFAULT").to_matchable(),
6743 Ref::new("ExpressionSegment").to_matchable(),
6744 ])
6745 .to_matchable(),
6746 Sequence::new(vec![
6747 Ref::keyword("DROP").to_matchable(),
6748 Ref::keyword("DEFAULT").to_matchable(),
6749 ])
6750 .to_matchable(),
6751 Sequence::new(vec![
6752 one_of(vec![
6753 Ref::keyword("SET").to_matchable(),
6754 Ref::keyword("DROP").to_matchable(),
6755 ])
6756 .to_matchable(),
6757 Ref::keyword("NOT").to_matchable(),
6758 Ref::keyword("NULL").to_matchable(),
6759 ])
6760 .to_matchable(),
6761 Sequence::new(vec![
6762 Ref::keyword("ADD").to_matchable(),
6763 Sequence::new(vec![
6764 Ref::keyword("CONSTRAINT").to_matchable(),
6765 Ref::new("ObjectReferenceSegment").to_matchable(),
6766 ])
6767 .config(|this| this.optional())
6768 .to_matchable(),
6769 one_of(vec![
6770 Sequence::new(vec![
6771 Ref::keyword("NOT").optional().to_matchable(),
6772 Ref::keyword("NULL").to_matchable(),
6773 ])
6774 .to_matchable(),
6775 Sequence::new(vec![
6776 Ref::keyword("CHECK").to_matchable(),
6777 Ref::new("ExpressionSegment").to_matchable(),
6778 ])
6779 .to_matchable(),
6780 ])
6781 .to_matchable(),
6782 Sequence::new(vec![
6783 Ref::keyword("NOT").to_matchable(),
6784 Ref::keyword("VALID").to_matchable(),
6785 ])
6786 .config(|this| this.optional())
6787 .to_matchable(),
6788 ])
6789 .to_matchable(),
6790 Sequence::new(vec![
6791 Ref::keyword("DROP").to_matchable(),
6792 Ref::keyword("CONSTRAINT").to_matchable(),
6793 Ref::new("IfExistsGrammar").optional().to_matchable(),
6794 Ref::new("ObjectReferenceSegment").to_matchable(),
6795 one_of(vec![
6796 Ref::keyword("RESTRICT").to_matchable(),
6797 Ref::keyword("CASCADE").to_matchable(),
6798 ])
6799 .config(|this| this.optional())
6800 .to_matchable(),
6801 ])
6802 .to_matchable(),
6803 Sequence::new(vec![
6804 Ref::keyword("RENAME").to_matchable(),
6805 Ref::keyword("CONSTRAINT").to_matchable(),
6806 Ref::new("ObjectReferenceSegment").to_matchable(),
6807 Ref::keyword("TO").to_matchable(),
6808 Ref::new("ObjectReferenceSegment").to_matchable(),
6809 ])
6810 .to_matchable(),
6811 Sequence::new(vec![
6812 Ref::keyword("VALIDATE").to_matchable(),
6813 Ref::keyword("CONSTRAINT").to_matchable(),
6814 Ref::new("ObjectReferenceSegment").to_matchable(),
6815 ])
6816 .to_matchable(),
6817 Sequence::new(vec![
6818 Ref::keyword("OWNER").to_matchable(),
6819 Ref::keyword("TO").to_matchable(),
6820 one_of(vec![
6821 Ref::new("ObjectReferenceSegment").to_matchable(),
6822 Ref::keyword("CURRENT_ROLE").to_matchable(),
6823 Ref::keyword("CURRENT_USER").to_matchable(),
6824 Ref::keyword("SESSION_USER").to_matchable(),
6825 ])
6826 .to_matchable(),
6827 ])
6828 .to_matchable(),
6829 Sequence::new(vec![
6830 Ref::keyword("RENAME").to_matchable(),
6831 Ref::keyword("TO").to_matchable(),
6832 Ref::new("ObjectReferenceSegment").to_matchable(),
6833 ])
6834 .to_matchable(),
6835 Sequence::new(vec![
6836 Ref::keyword("SET").to_matchable(),
6837 Ref::keyword("SCHEMA").to_matchable(),
6838 Ref::new("ObjectReferenceSegment").to_matchable(),
6839 ])
6840 .to_matchable(),
6841 ])
6842 .to_matchable(),
6843 ])
6844 .to_matchable()
6845 })
6846 .to_matchable()
6847 .into(),
6848 ),
6849 (
6850 "DropDomainStatementSegment".into(),
6851 NodeMatcher::new(SyntaxKind::DropDomainStatement, |_| {
6852 Sequence::new(vec![
6853 Ref::keyword("DROP").to_matchable(),
6854 Ref::keyword("DOMAIN").to_matchable(),
6855 Ref::new("IfExistsGrammar").optional().to_matchable(),
6856 Delimited::new(vec![Ref::new("ObjectReferenceSegment").to_matchable()])
6857 .to_matchable(),
6858 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
6859 ])
6860 .to_matchable()
6861 })
6862 .to_matchable()
6863 .into(),
6864 ),
6865 (
6866 "DropPolicyStatementSegment".into(),
6867 NodeMatcher::new(SyntaxKind::DropPolicyStatement, |_| {
6868 Sequence::new(vec![
6869 Ref::keyword("DROP").to_matchable(),
6870 Ref::keyword("POLICY").to_matchable(),
6871 Ref::new("IfExistsGrammar").optional().to_matchable(),
6872 Ref::new("ObjectReferenceSegment").to_matchable(),
6873 Ref::keyword("ON").to_matchable(),
6874 Ref::new("TableReferenceSegment").to_matchable(),
6875 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
6876 ])
6877 .to_matchable()
6878 })
6879 .to_matchable()
6880 .into(),
6881 ),
6882 (
6883 "LoadStatementSegment".into(),
6884 NodeMatcher::new(SyntaxKind::LoadStatement, |_| {
6885 Sequence::new(vec![
6886 Ref::keyword("LOAD").to_matchable(),
6887 Ref::new("QuotedLiteralSegment").to_matchable(),
6888 ])
6889 .to_matchable()
6890 })
6891 .to_matchable()
6892 .into(),
6893 ),
6894 (
6895 "ResetStatementSegment".into(),
6896 NodeMatcher::new(SyntaxKind::ResetStatement, |_| {
6897 Sequence::new(vec![
6898 Ref::keyword("RESET").to_matchable(),
6899 one_of(vec![
6900 Ref::keyword("ALL").to_matchable(),
6901 Ref::keyword("ROLE").to_matchable(),
6902 Ref::new("ParameterNameSegment").to_matchable(),
6903 ])
6904 .to_matchable(),
6905 ])
6906 .to_matchable()
6907 })
6908 .to_matchable()
6909 .into(),
6910 ),
6911 (
6912 "DiscardStatementSegment".into(),
6913 NodeMatcher::new(SyntaxKind::DiscardStatement, |_| {
6914 Sequence::new(vec![
6915 Ref::keyword("DISCARD").to_matchable(),
6916 one_of(vec![
6917 Ref::keyword("ALL").to_matchable(),
6918 Ref::keyword("PLANS").to_matchable(),
6919 Ref::keyword("SEQUENCES").to_matchable(),
6920 Ref::keyword("TEMPORARY").to_matchable(),
6921 Ref::keyword("TEMP").to_matchable(),
6922 ])
6923 .to_matchable(),
6924 ])
6925 .to_matchable()
6926 })
6927 .to_matchable()
6928 .into(),
6929 ),
6930 (
6931 "ListenStatementSegment".into(),
6932 NodeMatcher::new(SyntaxKind::ListenStatement, |_| {
6933 Sequence::new(vec![
6934 Ref::keyword("LISTEN").to_matchable(),
6935 Ref::new("SingleIdentifierGrammar").to_matchable(),
6936 ])
6937 .to_matchable()
6938 })
6939 .to_matchable()
6940 .into(),
6941 ),
6942 (
6943 "NotifyStatementSegment".into(),
6944 NodeMatcher::new(SyntaxKind::NotifyStatement, |_| {
6945 Sequence::new(vec![
6946 Ref::keyword("NOTIFY").to_matchable(),
6947 Ref::new("SingleIdentifierGrammar").to_matchable(),
6948 Sequence::new(vec![
6949 Ref::new("CommaSegment").to_matchable(),
6950 Ref::new("QuotedLiteralSegment").to_matchable(),
6951 ])
6952 .config(|this| this.optional())
6953 .to_matchable(),
6954 ])
6955 .to_matchable()
6956 })
6957 .to_matchable()
6958 .into(),
6959 ),
6960 (
6961 "UnlistenStatementSegment".into(),
6962 NodeMatcher::new(SyntaxKind::UnlistenStatement, |_| {
6963 Sequence::new(vec![
6964 Ref::keyword("UNLISTEN").to_matchable(),
6965 one_of(vec![
6966 Ref::new("SingleIdentifierGrammar").to_matchable(),
6967 Ref::new("StarSegment").to_matchable(),
6968 ])
6969 .to_matchable(),
6970 ])
6971 .to_matchable()
6972 })
6973 .to_matchable()
6974 .into(),
6975 ),
6976 ]);
6977
6978 postgres.replace_grammar(
6979 "TruncateStatementSegment",
6980 Sequence::new(vec![
6981 Ref::keyword("TRUNCATE").to_matchable(),
6982 Ref::keyword("TABLE").optional().to_matchable(),
6983 Delimited::new(vec![
6984 one_of(vec![
6985 Sequence::new(vec![
6986 Ref::keyword("ONLY").optional().to_matchable(),
6987 Ref::new("TableReferenceSegment").to_matchable(),
6988 ])
6989 .to_matchable(),
6990 Sequence::new(vec![
6991 Ref::new("TableReferenceSegment").to_matchable(),
6992 Ref::new("StarSegment").optional().to_matchable(),
6993 ])
6994 .to_matchable(),
6995 ])
6996 .to_matchable(),
6997 ])
6998 .to_matchable(),
6999 Sequence::new(vec![
7000 one_of(vec![
7001 Ref::keyword("RESTART").to_matchable(),
7002 Ref::keyword("CONTINUE").to_matchable(),
7003 ])
7004 .to_matchable(),
7005 Ref::keyword("IDENTITY").to_matchable(),
7006 ])
7007 .config(|this| this.optional())
7008 .to_matchable(),
7009 Ref::new("DropBehaviorGrammar").optional().to_matchable(),
7010 ])
7011 .to_matchable(),
7012 );
7013
7014 postgres.add([
7015 (
7016 "CopyStatementSegment".into(),
7017 NodeMatcher::new(SyntaxKind::CopyStatement, |_| {
7018 let _target_subset = one_of(vec![
7019 Ref::new("QuotedLiteralSegment").to_matchable(),
7020 Sequence::new(vec![
7021 Ref::keyword("PROGRAM").to_matchable(),
7022 Ref::new("QuotedLiteralSegment").to_matchable(),
7023 ])
7024 .to_matchable(),
7025 ]);
7026
7027 let _table_definition = Sequence::new(vec![
7028 Ref::new("TableReferenceSegment").to_matchable(),
7029 Bracketed::new(vec![
7030 Delimited::new(vec![Ref::new("ColumnReferenceSegment").to_matchable()])
7031 .to_matchable(),
7032 ])
7033 .config(|this| this.optional())
7034 .to_matchable(),
7035 ]);
7036
7037 let _option = Sequence::new(vec![
7038 Ref::keyword("WITH").optional().to_matchable(),
7039 Bracketed::new(vec![
7040 Delimited::new(vec![
7041 any_set_of(vec![
7042 Sequence::new(vec![
7043 Ref::keyword("FORMAT").to_matchable(),
7044 Ref::new("SingleIdentifierGrammar").to_matchable(),
7045 ])
7046 .to_matchable(),
7047 Sequence::new(vec![
7048 Ref::keyword("FREEZE").to_matchable(),
7049 Ref::new("BooleanLiteralGrammar").optional().to_matchable(),
7050 ])
7051 .to_matchable(),
7052 Sequence::new(vec![
7053 Ref::keyword("DELIMITER").to_matchable(),
7054 Ref::new("QuotedLiteralSegment").to_matchable(),
7055 ])
7056 .to_matchable(),
7057 Sequence::new(vec![
7058 Ref::keyword("NULL").to_matchable(),
7059 Ref::new("QuotedLiteralSegment").to_matchable(),
7060 ])
7061 .to_matchable(),
7062 Sequence::new(vec![
7063 Ref::keyword("HEADER").to_matchable(),
7064 Ref::new("BooleanLiteralGrammar").optional().to_matchable(),
7065 ])
7066 .to_matchable(),
7067 Sequence::new(vec![
7068 Ref::keyword("QUOTE").to_matchable(),
7069 Ref::new("QuotedLiteralSegment").to_matchable(),
7070 ])
7071 .to_matchable(),
7072 Sequence::new(vec![
7073 Ref::keyword("ESCAPE").to_matchable(),
7074 Ref::new("QuotedLiteralSegment").to_matchable(),
7075 ])
7076 .to_matchable(),
7077 Sequence::new(vec![
7078 Ref::keyword("FORCE_QUOTE").to_matchable(),
7079 one_of(vec![
7080 Bracketed::new(vec![
7081 Delimited::new(vec![
7082 Ref::new("ColumnReferenceSegment").to_matchable(),
7083 ])
7084 .to_matchable(),
7085 ])
7086 .to_matchable(),
7087 Ref::new("StarSegment").to_matchable(),
7088 ])
7089 .to_matchable(),
7090 ])
7091 .to_matchable(),
7092 Sequence::new(vec![
7093 Ref::keyword("FORCE_NOT_NULL").to_matchable(),
7094 Bracketed::new(vec![
7095 Delimited::new(vec![
7096 Ref::new("ColumnReferenceSegment").to_matchable(),
7097 ])
7098 .to_matchable(),
7099 ])
7100 .to_matchable(),
7101 ])
7102 .to_matchable(),
7103 Sequence::new(vec![
7104 Ref::keyword("FORCE_NULL").to_matchable(),
7105 Bracketed::new(vec![
7106 Delimited::new(vec![
7107 Ref::new("ColumnReferenceSegment").to_matchable(),
7108 ])
7109 .to_matchable(),
7110 ])
7111 .to_matchable(),
7112 ])
7113 .to_matchable(),
7114 Sequence::new(vec![
7115 Ref::keyword("ENCODING").to_matchable(),
7116 Ref::new("QuotedLiteralSegment").to_matchable(),
7117 ])
7118 .to_matchable(),
7119 ])
7120 .to_matchable(),
7121 ])
7122 .to_matchable(),
7123 ])
7124 .to_matchable(),
7125 ])
7126 .config(|this| this.optional());
7127
7128 Sequence::new(vec![
7129 Ref::keyword("COPY").to_matchable(),
7130 one_of(vec![
7131 Sequence::new(vec![
7132 _table_definition.clone().to_matchable(),
7133 Ref::keyword("FROM").to_matchable(),
7134 one_of(vec![
7135 _target_subset.clone().to_matchable(),
7136 Ref::keyword("STDIN").to_matchable(),
7137 ])
7138 .to_matchable(),
7139 _option.clone().to_matchable(),
7140 Sequence::new(vec![
7141 Ref::keyword("WHERE").to_matchable(),
7142 Ref::new("ExpressionSegment").to_matchable(),
7143 ])
7144 .config(|this| this.optional())
7145 .to_matchable(),
7146 ])
7147 .to_matchable(),
7148 Sequence::new(vec![
7149 one_of(vec![
7150 _table_definition.clone().to_matchable(),
7151 Bracketed::new(vec![
7152 Ref::new("UnorderedSelectStatementSegment").to_matchable(),
7153 ])
7154 .to_matchable(),
7155 ])
7156 .to_matchable(),
7157 Ref::keyword("TO").to_matchable(),
7158 one_of(vec![
7159 _target_subset.to_matchable(),
7160 Ref::keyword("STDOUT").to_matchable(),
7161 ])
7162 .to_matchable(),
7163 _option.to_matchable(),
7164 ])
7165 .to_matchable(),
7166 ])
7167 .to_matchable(),
7168 ])
7169 .to_matchable()
7170 })
7171 .to_matchable()
7172 .into(),
7173 ),
7174 (
7175 "AlterSchemaStatementSegment".into(),
7176 NodeMatcher::new(SyntaxKind::AlterSchemaStatement, |_| {
7177 Sequence::new(vec![
7178 Ref::keyword("ALTER").to_matchable(),
7179 Ref::keyword("SCHEMA").to_matchable(),
7180 Ref::new("SchemaReferenceSegment").to_matchable(),
7181 one_of(vec![
7182 Sequence::new(vec![
7183 Ref::keyword("RENAME").to_matchable(),
7184 Ref::keyword("TO").to_matchable(),
7185 Ref::new("SchemaReferenceSegment").to_matchable(),
7186 ])
7187 .to_matchable(),
7188 Sequence::new(vec![
7189 Ref::keyword("OWNER").to_matchable(),
7190 Ref::keyword("TO").to_matchable(),
7191 Ref::new("RoleReferenceSegment").to_matchable(),
7192 ])
7193 .to_matchable(),
7194 ])
7195 .to_matchable(),
7196 ])
7197 .to_matchable()
7198 })
7199 .to_matchable()
7200 .into(),
7201 ),
7202 (
7203 "LockTableStatementSegment".into(),
7204 NodeMatcher::new(SyntaxKind::LockTableStatement, |_| {
7205 Sequence::new(vec![
7206 Ref::keyword("LOCK").to_matchable(),
7207 Ref::keyword("TABLE").optional().to_matchable(),
7208 Ref::keyword("ONLY").optional().to_matchable(),
7209 one_of(vec![
7210 Delimited::new(vec![Ref::new("TableReferenceSegment").to_matchable()])
7211 .to_matchable(),
7212 Ref::new("StarSegment").to_matchable(),
7213 ])
7214 .to_matchable(),
7215 Sequence::new(vec![
7216 Ref::keyword("IN").to_matchable(),
7217 one_of(vec![
7218 Sequence::new(vec![
7219 Ref::keyword("ACCESS").to_matchable(),
7220 Ref::keyword("SHARE").to_matchable(),
7221 ])
7222 .to_matchable(),
7223 Sequence::new(vec![
7224 Ref::keyword("ROW").to_matchable(),
7225 Ref::keyword("SHARE").to_matchable(),
7226 ])
7227 .to_matchable(),
7228 Sequence::new(vec![
7229 Ref::keyword("ROW").to_matchable(),
7230 Ref::keyword("EXCLUSIVE").to_matchable(),
7231 ])
7232 .to_matchable(),
7233 Sequence::new(vec![
7234 Ref::keyword("SHARE").to_matchable(),
7235 Ref::keyword("UPDATE").to_matchable(),
7236 Ref::keyword("EXCLUSIVE").to_matchable(),
7237 ])
7238 .to_matchable(),
7239 Ref::keyword("SHARE").to_matchable(),
7240 Sequence::new(vec![
7241 Ref::keyword("SHARE").to_matchable(),
7242 Ref::keyword("ROW").to_matchable(),
7243 Ref::keyword("EXCLUSIVE").to_matchable(),
7244 ])
7245 .to_matchable(),
7246 Ref::keyword("EXCLUSIVE").to_matchable(),
7247 Sequence::new(vec![
7248 Ref::keyword("ACCESS").to_matchable(),
7249 Ref::keyword("EXCLUSIVE").to_matchable(),
7250 ])
7251 .to_matchable(),
7252 ])
7253 .to_matchable(),
7254 Ref::keyword("MODE").to_matchable(),
7255 ])
7256 .config(|this| this.optional())
7257 .to_matchable(),
7258 Ref::keyword("NOWAIT").optional().to_matchable(),
7259 ])
7260 .to_matchable()
7261 })
7262 .to_matchable()
7263 .into(),
7264 ),
7265 (
7266 "ClusterStatementSegment".into(),
7267 NodeMatcher::new(SyntaxKind::ClusterStatement, |_| {
7268 Sequence::new(vec![
7269 Ref::keyword("CLUSTER").to_matchable(),
7270 Ref::keyword("VERBOSE").optional().to_matchable(),
7271 one_of(vec![
7272 Sequence::new(vec![
7273 Ref::new("TableReferenceSegment").to_matchable(),
7274 Sequence::new(vec![
7275 Ref::keyword("USING").to_matchable(),
7276 Ref::new("IndexReferenceSegment").to_matchable(),
7277 ])
7278 .config(|this| this.optional())
7279 .to_matchable(),
7280 ])
7281 .to_matchable(),
7282 Sequence::new(vec![
7283 Ref::new("IndexReferenceSegment").to_matchable(),
7284 Ref::keyword("ON").to_matchable(),
7285 Ref::new("TableReferenceSegment").to_matchable(),
7286 ])
7287 .to_matchable(),
7288 ])
7289 .config(|this| this.optional())
7290 .to_matchable(),
7291 ])
7292 .to_matchable()
7293 })
7294 .to_matchable()
7295 .into(),
7296 ),
7297 (
7298 "LanguageClauseSegment".into(),
7299 NodeMatcher::new(SyntaxKind::LanguageClause, |_| {
7300 Sequence::new(vec![
7301 Ref::keyword("LANGUAGE").to_matchable(),
7302 one_of(vec![
7303 Ref::new("NakedIdentifierSegment").to_matchable(),
7304 Ref::new("SingleQuotedIdentifierSegment").to_matchable(),
7305 ])
7306 .to_matchable(),
7307 ])
7308 .to_matchable()
7309 })
7310 .to_matchable()
7311 .into(),
7312 ),
7313 (
7314 "DoStatementSegment".into(),
7315 NodeMatcher::new(SyntaxKind::DoStatement, |_| {
7316 Sequence::new(vec![
7317 Ref::keyword("DO").to_matchable(),
7318 one_of(vec![
7319 Sequence::new(vec![
7320 Ref::new("LanguageClauseSegment").optional().to_matchable(),
7321 Ref::new("QuotedLiteralSegment").to_matchable(),
7322 ])
7323 .to_matchable(),
7324 Sequence::new(vec![
7325 Ref::new("QuotedLiteralSegment").to_matchable(),
7326 Ref::new("LanguageClauseSegment").optional().to_matchable(),
7327 ])
7328 .to_matchable(),
7329 ])
7330 .to_matchable(),
7331 ])
7332 .to_matchable()
7333 })
7334 .to_matchable()
7335 .into(),
7336 ),
7337 ]);
7338
7339 postgres.replace_grammar(
7340 "CTEDefinitionSegment",
7341 Sequence::new(vec![
7342 Ref::new("SingleIdentifierGrammar").to_matchable(),
7343 Ref::new("CTEColumnList").optional().to_matchable(),
7344 Ref::keyword("AS").to_matchable(),
7345 Sequence::new(vec![
7346 Ref::keyword("NOT").optional().to_matchable(),
7347 Ref::keyword("MATERIALIZED").to_matchable(),
7348 ])
7349 .config(|this| this.optional())
7350 .to_matchable(),
7351 Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()])
7352 .config(|this| this.parse_mode = ParseMode::Greedy)
7353 .to_matchable(),
7354 one_of(vec![
7355 Sequence::new(vec![
7356 Ref::keyword("SEARCH").to_matchable(),
7357 one_of(vec![
7358 Ref::keyword("BREADTH").to_matchable(),
7359 Ref::keyword("DEPTH").to_matchable(),
7360 ])
7361 .to_matchable(),
7362 Ref::keyword("FIRST").to_matchable(),
7363 Ref::keyword("BY").to_matchable(),
7364 Ref::new("ColumnReferenceSegment").to_matchable(),
7365 Ref::keyword("SET").to_matchable(),
7366 Ref::new("ColumnReferenceSegment").to_matchable(),
7367 ])
7368 .to_matchable(),
7369 Sequence::new(vec![
7370 Ref::keyword("CYCLE").to_matchable(),
7371 Ref::new("ColumnReferenceSegment").to_matchable(),
7372 Ref::keyword("SET").to_matchable(),
7373 Ref::new("ColumnReferenceSegment").to_matchable(),
7374 Ref::keyword("USING").to_matchable(),
7375 Ref::new("ColumnReferenceSegment").to_matchable(),
7376 ])
7377 .to_matchable(),
7378 ])
7379 .config(|this| this.optional())
7380 .to_matchable(),
7381 ])
7382 .to_matchable(),
7383 );
7384
7385 postgres.replace_grammar(
7386 "ValuesClauseSegment",
7387 Sequence::new(vec![
7388 Ref::keyword("VALUES").to_matchable(),
7389 Delimited::new(vec![
7390 Bracketed::new(vec![
7391 Delimited::new(vec![
7392 Ref::new("ExpressionSegment").to_matchable(),
7393 Ref::keyword("DEFAULT").to_matchable(),
7394 ])
7395 .config(|this| this.parse_mode = ParseMode::Greedy)
7396 .to_matchable(),
7397 ])
7398 .to_matchable(),
7399 ])
7400 .to_matchable(),
7401 Ref::new("AliasExpressionSegment").optional().to_matchable(),
7402 Ref::new("OrderByClauseSegment").optional().to_matchable(),
7403 Ref::new("LimitClauseSegment").optional().to_matchable(),
7404 ])
7405 .to_matchable(),
7406 );
7407
7408 postgres.replace_grammar(
7409 "DeleteStatementSegment",
7410 Sequence::new(vec![
7411 Ref::keyword("DELETE").to_matchable(),
7412 Ref::keyword("FROM").to_matchable(),
7413 Ref::keyword("ONLY").optional().to_matchable(),
7414 Ref::new("TableReferenceSegment").to_matchable(),
7415 Ref::new("StarSegment").optional().to_matchable(),
7416 Ref::new("AliasExpressionSegment").optional().to_matchable(),
7417 Sequence::new(vec![
7418 Ref::keyword("USING").to_matchable(),
7419 MetaSegment::indent().to_matchable(),
7420 Delimited::new(vec![
7421 Sequence::new(vec![
7422 Ref::new("TableExpressionSegment").to_matchable(),
7423 Ref::new("AliasExpressionSegment").optional().to_matchable(),
7424 ])
7425 .to_matchable(),
7426 ])
7427 .to_matchable(),
7428 MetaSegment::dedent().to_matchable(),
7429 ])
7430 .config(|this| this.optional())
7431 .to_matchable(),
7432 one_of(vec![
7433 Sequence::new(vec![
7434 Ref::keyword("WHERE").to_matchable(),
7435 Ref::keyword("CURRENT").to_matchable(),
7436 Ref::keyword("OF").to_matchable(),
7437 Ref::new("ObjectReferenceSegment").to_matchable(),
7438 ])
7439 .to_matchable(),
7440 Ref::new("WhereClauseSegment").to_matchable(),
7441 ])
7442 .config(|this| this.optional())
7443 .to_matchable(),
7444 Sequence::new(vec![
7445 Ref::keyword("RETURNING").to_matchable(),
7446 MetaSegment::indent().to_matchable(),
7447 one_of(vec![
7448 Ref::new("StarSegment").to_matchable(),
7449 Delimited::new(vec![
7450 Sequence::new(vec![
7451 Ref::new("ExpressionSegment").to_matchable(),
7452 Ref::new("AliasExpressionSegment").optional().to_matchable(),
7453 ])
7454 .to_matchable(),
7455 ])
7456 .to_matchable(),
7457 ])
7458 .to_matchable(),
7459 MetaSegment::dedent().to_matchable(),
7460 ])
7461 .config(|this| this.optional())
7462 .to_matchable(),
7463 ])
7464 .to_matchable(),
7465 );
7466
7467 postgres.add([
7468 (
7469 "SetClauseSegment".into(),
7470 NodeMatcher::new(SyntaxKind::SetClause, |_| {
7471 Sequence::new(vec![
7472 one_of(vec![
7473 Sequence::new(vec![
7474 Ref::new("ColumnReferenceSegment").to_matchable(),
7475 Ref::new("ArrayAccessorSegment").optional().to_matchable(),
7476 Ref::new("EqualsSegment").to_matchable(),
7477 one_of(vec![
7478 Ref::new("LiteralGrammar").to_matchable(),
7479 Ref::new("BareFunctionSegment").to_matchable(),
7480 Ref::new("FunctionSegment").to_matchable(),
7481 Ref::new("ColumnReferenceSegment").to_matchable(),
7482 Ref::new("ExpressionSegment").to_matchable(),
7483 Ref::keyword("DEFAULT").to_matchable(),
7484 ])
7485 .to_matchable(),
7486 AnyNumberOf::new(vec![Ref::new("ShorthandCastSegment").to_matchable()])
7487 .to_matchable(),
7488 ])
7489 .to_matchable(),
7490 Sequence::new(vec![
7491 Bracketed::new(vec![
7492 Delimited::new(vec![
7493 Ref::new("ColumnReferenceSegment").to_matchable(),
7494 ])
7495 .to_matchable(),
7496 ])
7497 .to_matchable(),
7498 Ref::new("EqualsSegment").to_matchable(),
7499 Bracketed::new(vec![
7500 one_of(vec![
7501 Ref::new("SelectableGrammar").to_matchable(),
7502 Delimited::new(vec![
7503 Sequence::new(vec![
7504 one_of(vec![
7505 Ref::new("LiteralGrammar").to_matchable(),
7506 Ref::new("BareFunctionSegment").to_matchable(),
7507 Ref::new("FunctionSegment").to_matchable(),
7508 Ref::new("ColumnReferenceSegment").to_matchable(),
7509 Ref::new("ExpressionSegment").to_matchable(),
7510 Ref::keyword("DEFAULT").to_matchable(),
7511 ])
7512 .to_matchable(),
7513 AnyNumberOf::new(vec![
7514 Ref::new("ShorthandCastSegment").to_matchable(),
7515 ])
7516 .to_matchable(),
7517 ])
7518 .to_matchable(),
7519 ])
7520 .to_matchable(),
7521 ])
7522 .to_matchable(),
7523 ])
7524 .to_matchable(),
7525 ])
7526 .to_matchable(),
7527 ])
7528 .to_matchable(),
7529 ])
7530 .to_matchable()
7531 })
7532 .to_matchable()
7533 .into(),
7534 ),
7535 (
7536 "UpdateStatementSegment".into(),
7537 NodeMatcher::new(SyntaxKind::UpdateStatement, |_| {
7538 Sequence::new(vec![
7539 Ref::keyword("UPDATE").to_matchable(),
7540 Ref::keyword("ONLY").optional().to_matchable(),
7541 Ref::new("TableReferenceSegment").to_matchable(),
7542 Ref::new("AliasExpressionSegment")
7543 .exclude(Ref::keyword("SET"))
7544 .optional()
7545 .to_matchable(),
7546 Ref::new("SetClauseListSegment").to_matchable(),
7547 Ref::new("FromClauseSegment").optional().to_matchable(),
7548 one_of(vec![
7549 Sequence::new(vec![
7550 Ref::keyword("WHERE").to_matchable(),
7551 Ref::keyword("CURRENT").to_matchable(),
7552 Ref::keyword("OF").to_matchable(),
7553 Ref::new("ObjectReferenceSegment").to_matchable(),
7554 ])
7555 .to_matchable(),
7556 Ref::new("WhereClauseSegment").to_matchable(),
7557 ])
7558 .config(|this| this.optional())
7559 .to_matchable(),
7560 Sequence::new(vec![
7561 Ref::keyword("RETURNING").to_matchable(),
7562 MetaSegment::indent().to_matchable(),
7563 one_of(vec![
7564 Ref::new("StarSegment").to_matchable(),
7565 Delimited::new(vec![
7566 Sequence::new(vec![
7567 Ref::new("ExpressionSegment").to_matchable(),
7568 Ref::new("AliasExpressionSegment").optional().to_matchable(),
7569 ])
7570 .to_matchable(),
7571 ])
7572 .to_matchable(),
7573 ])
7574 .to_matchable(),
7575 MetaSegment::dedent().to_matchable(),
7576 ])
7577 .config(|this| this.optional())
7578 .to_matchable(),
7579 ])
7580 .to_matchable()
7581 })
7582 .to_matchable()
7583 .into(),
7584 ),
7585 (
7586 "CreateTypeStatementSegment".into(),
7587 NodeMatcher::new(SyntaxKind::CreateTypeStatement, |_| {
7588 Sequence::new(vec![
7589 Ref::keyword("CREATE").to_matchable(),
7590 Ref::keyword("TYPE").to_matchable(),
7591 Ref::new("ObjectReferenceSegment").to_matchable(),
7592 Sequence::new(vec![
7593 Ref::keyword("AS").to_matchable(),
7594 one_of(vec![
7595 Ref::keyword("ENUM").to_matchable(),
7596 Ref::keyword("RANGE").to_matchable(),
7597 ])
7598 .config(|this| this.optional())
7599 .to_matchable(),
7600 ])
7601 .config(|this| this.optional())
7602 .to_matchable(),
7603 Bracketed::new(vec![
7604 Delimited::new(vec![
7605 one_of(vec![
7606 Sequence::new(vec![
7607 Ref::new("ColumnReferenceSegment").to_matchable(),
7608 Ref::new("DatatypeSegment").to_matchable(),
7609 Sequence::new(vec![
7610 Ref::keyword("COLLATE").to_matchable(),
7611 Ref::new("CollationReferenceSegment").to_matchable(),
7612 ])
7613 .config(|this| this.optional())
7614 .to_matchable(),
7615 ])
7616 .to_matchable(),
7617 Anything::new().to_matchable(),
7618 ])
7619 .to_matchable(),
7620 ])
7621 .config(|this| this.optional())
7622 .to_matchable(),
7623 ])
7624 .config(|this| this.optional())
7625 .to_matchable(),
7626 ])
7627 .to_matchable()
7628 })
7629 .to_matchable()
7630 .into(),
7631 ),
7632 (
7633 "AlterTypeStatementSegment".into(),
7634 NodeMatcher::new(SyntaxKind::AlterTypeStatement, |_| {
7635 Sequence::new(vec![
7636 Ref::keyword("ALTER").to_matchable(),
7637 Ref::keyword("TYPE").to_matchable(),
7638 Ref::new("ObjectReferenceSegment").to_matchable(),
7639 one_of(vec![
7640 Sequence::new(vec![
7641 Ref::keyword("OWNER").to_matchable(),
7642 Ref::keyword("TO").to_matchable(),
7643 one_of(vec![
7644 Ref::keyword("CURRENT_USER").to_matchable(),
7645 Ref::keyword("SESSION_USER").to_matchable(),
7646 Ref::keyword("CURRENT_ROLE").to_matchable(),
7647 Ref::new("ObjectReferenceSegment").to_matchable(),
7648 ])
7649 .to_matchable(),
7650 ])
7651 .to_matchable(),
7652 Sequence::new(vec![
7653 Ref::keyword("RENAME").to_matchable(),
7654 Ref::keyword("VALUE").to_matchable(),
7655 Ref::new("QuotedLiteralSegment").to_matchable(),
7656 Ref::keyword("TO").to_matchable(),
7657 Ref::new("QuotedLiteralSegment").to_matchable(),
7658 ])
7659 .to_matchable(),
7660 Sequence::new(vec![
7661 Ref::keyword("RENAME").to_matchable(),
7662 Ref::keyword("TO").to_matchable(),
7663 Ref::new("ObjectReferenceSegment").to_matchable(),
7664 ])
7665 .to_matchable(),
7666 Sequence::new(vec![
7667 Ref::keyword("SET").to_matchable(),
7668 Ref::keyword("SCHEMA").to_matchable(),
7669 Ref::new("SchemaReferenceSegment").to_matchable(),
7670 ])
7671 .to_matchable(),
7672 Delimited::new(vec![
7673 Sequence::new(vec![
7674 Ref::keyword("ADD").to_matchable(),
7675 Ref::keyword("ATTRIBUTE").to_matchable(),
7676 Ref::new("ColumnReferenceSegment").to_matchable(),
7677 Ref::new("DatatypeSegment").to_matchable(),
7678 Sequence::new(vec![
7679 Ref::keyword("COLLATE").to_matchable(),
7680 Ref::new("CollationReferenceSegment").to_matchable(),
7681 ])
7682 .config(|this| this.optional())
7683 .to_matchable(),
7684 Ref::new("CascadeRestrictGrammar").optional().to_matchable(),
7685 ])
7686 .to_matchable(),
7687 Sequence::new(vec![
7688 Ref::keyword("ALTER").to_matchable(),
7689 Ref::keyword("ATTRIBUTE").to_matchable(),
7690 Ref::new("ColumnReferenceSegment").to_matchable(),
7691 Sequence::new(vec![
7692 Ref::keyword("SET").to_matchable(),
7693 Ref::keyword("DATA").to_matchable(),
7694 ])
7695 .config(|this| this.optional())
7696 .to_matchable(),
7697 Ref::keyword("TYPE").to_matchable(),
7698 Ref::new("DatatypeSegment").to_matchable(),
7699 Sequence::new(vec![
7700 Ref::keyword("COLLATE").to_matchable(),
7701 Ref::new("CollationReferenceSegment").to_matchable(),
7702 ])
7703 .config(|this| this.optional())
7704 .to_matchable(),
7705 Ref::new("CascadeRestrictGrammar").optional().to_matchable(),
7706 ])
7707 .to_matchable(),
7708 Sequence::new(vec![
7709 Ref::keyword("DROP").to_matchable(),
7710 Ref::keyword("ATTRIBUTE").to_matchable(),
7711 Ref::new("IfExistsGrammar").optional().to_matchable(),
7712 Ref::new("ColumnReferenceSegment").to_matchable(),
7713 Ref::new("CascadeRestrictGrammar").optional().to_matchable(),
7714 ])
7715 .to_matchable(),
7716 Sequence::new(vec![
7717 Ref::keyword("RENAME").to_matchable(),
7718 Ref::keyword("ATTRIBUTE").to_matchable(),
7719 Ref::new("ColumnReferenceSegment").to_matchable(),
7720 Ref::keyword("TO").to_matchable(),
7721 Ref::new("ColumnReferenceSegment").to_matchable(),
7722 Ref::new("CascadeRestrictGrammar").optional().to_matchable(),
7723 ])
7724 .to_matchable(),
7725 ])
7726 .to_matchable(),
7727 Sequence::new(vec![
7728 Ref::keyword("ADD").to_matchable(),
7729 Ref::keyword("VALUE").to_matchable(),
7730 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
7731 Ref::new("QuotedLiteralSegment").to_matchable(),
7732 Sequence::new(vec![
7733 one_of(vec![
7734 Ref::keyword("BEFORE").to_matchable(),
7735 Ref::keyword("AFTER").to_matchable(),
7736 ])
7737 .to_matchable(),
7738 Ref::new("QuotedLiteralSegment").to_matchable(),
7739 ])
7740 .config(|this| this.optional())
7741 .to_matchable(),
7742 ])
7743 .to_matchable(),
7744 ])
7745 .to_matchable(),
7746 ])
7747 .to_matchable()
7748 })
7749 .to_matchable()
7750 .into(),
7751 ),
7752 (
7753 "CreateCollationStatementSegment".into(),
7754 NodeMatcher::new(SyntaxKind::CreateCollationStatement, |_| {
7755 Sequence::new(vec![
7756 Ref::keyword("CREATE").to_matchable(),
7757 Ref::keyword("COLLATION").to_matchable(),
7758 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
7759 Ref::new("ObjectReferenceSegment").to_matchable(),
7760 one_of(vec![
7761 Bracketed::new(vec![
7762 Delimited::new(vec![
7763 Sequence::new(vec![
7764 Ref::keyword("LOCALE").to_matchable(),
7765 Ref::new("EqualsSegment").to_matchable(),
7766 Ref::new("QuotedLiteralSegment").to_matchable(),
7767 ])
7768 .to_matchable(),
7769 Sequence::new(vec![
7770 Ref::keyword("LC_COLLATE").to_matchable(),
7771 Ref::new("EqualsSegment").to_matchable(),
7772 Ref::new("QuotedLiteralSegment").to_matchable(),
7773 ])
7774 .to_matchable(),
7775 Sequence::new(vec![
7776 Ref::keyword("LC_CTYPE").to_matchable(),
7777 Ref::new("EqualsSegment").to_matchable(),
7778 Ref::new("QuotedLiteralSegment").to_matchable(),
7779 ])
7780 .to_matchable(),
7781 Sequence::new(vec![
7782 Ref::keyword("PROVIDER").to_matchable(),
7783 Ref::new("EqualsSegment").to_matchable(),
7784 one_of(vec![
7785 Ref::keyword("ICU").to_matchable(),
7786 Ref::keyword("LIBC").to_matchable(),
7787 ])
7788 .to_matchable(),
7789 ])
7790 .to_matchable(),
7791 Sequence::new(vec![
7792 Ref::keyword("DETERMINISTIC").to_matchable(),
7793 Ref::new("EqualsSegment").to_matchable(),
7794 Ref::new("BooleanLiteralGrammar").to_matchable(),
7795 ])
7796 .to_matchable(),
7797 Sequence::new(vec![
7798 Ref::keyword("VERSION").to_matchable(),
7799 Ref::new("EqualsSegment").to_matchable(),
7800 Ref::new("QuotedLiteralSegment").to_matchable(),
7801 ])
7802 .to_matchable(),
7803 ])
7804 .to_matchable(),
7805 ])
7806 .to_matchable(),
7807 Sequence::new(vec![
7808 Ref::keyword("FROM").to_matchable(),
7809 Ref::new("ObjectReferenceSegment").to_matchable(),
7810 ])
7811 .to_matchable(),
7812 ])
7813 .to_matchable(),
7814 ])
7815 .to_matchable()
7816 })
7817 .to_matchable()
7818 .into(),
7819 ),
7820 ]);
7821
7822 postgres.replace_grammar(
7823 "ColumnReferenceSegment",
7824 Sequence::new(vec![
7825 Ref::new("SingleIdentifierGrammar").to_matchable(),
7826 Sequence::new(vec![
7827 one_of(vec![
7828 Ref::new("DotSegment").to_matchable(),
7829 Sequence::new(vec![
7830 Ref::new("DotSegment").to_matchable(),
7831 Ref::new("DotSegment").to_matchable(),
7832 ])
7833 .to_matchable(),
7834 ])
7835 .to_matchable(),
7836 Delimited::new(vec![Ref::new("SingleIdentifierFullGrammar").to_matchable()])
7837 .config(|this| {
7838 this.delimiter(one_of(vec![
7839 Ref::new("DotSegment").to_matchable(),
7840 Sequence::new(vec![
7841 Ref::new("DotSegment").to_matchable(),
7842 Ref::new("DotSegment").to_matchable(),
7843 ])
7844 .to_matchable(),
7845 ]));
7846 this.terminators = vec![
7847 Ref::keyword("ON").to_matchable(),
7848 Ref::keyword("AS").to_matchable(),
7849 Ref::keyword("USING").to_matchable(),
7850 Ref::new("CommaSegment").to_matchable(),
7851 Ref::new("CastOperatorSegment").to_matchable(),
7852 Ref::new("StartSquareBracketSegment").to_matchable(),
7853 Ref::new("StartBracketSegment").to_matchable(),
7854 Ref::new("BinaryOperatorGrammar").to_matchable(),
7855 Ref::new("ColonSegment").to_matchable(),
7856 Ref::new("DelimiterGrammar").to_matchable(),
7857 Ref::new("JoinLikeClauseGrammar").to_matchable(),
7858 Bracketed::new(vec![]).to_matchable(),
7859 ];
7860 this.allow_gaps = false;
7861 })
7862 .to_matchable(),
7863 ])
7864 .config(|this| {
7865 this.optional();
7866 this.allow_gaps = false
7867 })
7868 .to_matchable(),
7869 ])
7870 .config(|this| this.allow_gaps = false)
7871 .to_matchable(),
7872 );
7873
7874 postgres.add([(
7875 "NamedArgumentSegment".into(),
7876 NodeMatcher::new(SyntaxKind::NamedArgument, |_| {
7877 Sequence::new(vec![
7878 Ref::new("NakedIdentifierSegment").to_matchable(),
7879 Ref::new("RightArrowSegment").to_matchable(),
7880 Ref::new("ExpressionSegment").to_matchable(),
7881 ])
7882 .to_matchable()
7883 })
7884 .to_matchable()
7885 .into(),
7886 )]);
7887
7888 postgres.replace_grammar(
7889 "TableExpressionSegment",
7890 one_of(vec![
7891 Ref::new("ValuesClauseSegment").to_matchable(),
7892 Ref::new("BareFunctionSegment").to_matchable(),
7893 Sequence::new(vec![
7894 Ref::new("FunctionSegment").to_matchable(),
7895 Sequence::new(vec![
7896 Ref::keyword("WITH").to_matchable(),
7897 Ref::keyword("ORDINALITY").to_matchable(),
7898 ])
7899 .config(|this| this.optional())
7900 .to_matchable(),
7901 ])
7902 .to_matchable(),
7903 Ref::new("TableReferenceSegment").to_matchable(),
7904 Bracketed::new(vec![Ref::new("SelectableGrammar").to_matchable()]).to_matchable(),
7905 Bracketed::new(vec![Ref::new("MergeStatementSegment").to_matchable()]).to_matchable(),
7906 ])
7907 .to_matchable(),
7908 );
7909
7910 postgres.add([(
7911 "ServerReferenceSegment".into(),
7912 NodeMatcher::new(SyntaxKind::ServerReference, |postgres| {
7913 postgres
7914 .grammar("ObjectReferenceSegment")
7915 .match_grammar(postgres)
7916 .unwrap()
7917 })
7918 .to_matchable()
7919 .into(),
7920 )]);
7921
7922 postgres.add([
7923 (
7924 "CreateServerStatementSegment".into(),
7925 NodeMatcher::new(SyntaxKind::CreateServerStatement, |_| {
7926 Sequence::new(vec![
7927 Ref::keyword("CREATE").to_matchable(),
7928 Ref::keyword("SERVER").to_matchable(),
7929 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
7930 Ref::new("ServerReferenceSegment").to_matchable(),
7931 Sequence::new(vec![
7932 Ref::keyword("TYPE").to_matchable(),
7933 Ref::new("QuotedLiteralSegment").to_matchable(),
7934 ])
7935 .config(|this| this.optional())
7936 .to_matchable(),
7937 Sequence::new(vec![
7938 Ref::keyword("VERSION").to_matchable(),
7939 Ref::new("VersionIdentifierSegment").to_matchable(),
7940 ])
7941 .config(|this| this.optional())
7942 .to_matchable(),
7943 Ref::new("ForeignDataWrapperGrammar").to_matchable(),
7944 Ref::new("ObjectReferenceSegment").to_matchable(),
7945 Ref::new("OptionsGrammar").optional().to_matchable(),
7946 ])
7947 .to_matchable()
7948 })
7949 .to_matchable()
7950 .into(),
7951 ),
7952 (
7953 "CreateUserMappingStatementSegment".into(),
7954 NodeMatcher::new(SyntaxKind::CreateUserMappingStatement, |_| {
7955 Sequence::new(vec![
7956 Ref::new("CreateUserMappingGrammar").to_matchable(),
7957 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
7958 Ref::keyword("FOR").to_matchable(),
7959 one_of(vec![
7960 Ref::new("SingleIdentifierGrammar").to_matchable(),
7961 Ref::new("SessionInformationUserFunctionsGrammar").to_matchable(),
7962 Ref::keyword("PUBLIC").to_matchable(),
7963 ])
7964 .to_matchable(),
7965 Ref::keyword("SERVER").to_matchable(),
7966 Ref::new("ServerReferenceSegment").to_matchable(),
7967 Ref::new("OptionsGrammar").optional().to_matchable(),
7968 ])
7969 .to_matchable()
7970 })
7971 .to_matchable()
7972 .into(),
7973 ),
7974 (
7975 "ImportForeignSchemaStatementSegment".into(),
7976 NodeMatcher::new(SyntaxKind::ImportForeignSchemaStatement, |_| {
7977 Sequence::new(vec![
7978 Ref::new("ImportForeignSchemaGrammar").to_matchable(),
7979 Ref::new("SchemaReferenceSegment").to_matchable(),
7980 Sequence::new(vec![
7981 one_of(vec![
7982 Sequence::new(vec![
7983 Ref::keyword("LIMIT").to_matchable(),
7984 Ref::keyword("TO").to_matchable(),
7985 ])
7986 .to_matchable(),
7987 Ref::keyword("EXCEPT").to_matchable(),
7988 ])
7989 .to_matchable(),
7990 Bracketed::new(vec![
7991 Delimited::new(vec![
7992 Ref::new("NakedIdentifierFullSegment").to_matchable(),
7993 ])
7994 .to_matchable(),
7995 ])
7996 .to_matchable(),
7997 ])
7998 .config(|this| this.optional())
7999 .to_matchable(),
8000 Ref::keyword("FROM").to_matchable(),
8001 Ref::keyword("SERVER").to_matchable(),
8002 Ref::new("ServerReferenceSegment").to_matchable(),
8003 Ref::keyword("INTO").to_matchable(),
8004 Ref::new("SchemaReferenceSegment").to_matchable(),
8005 Ref::new("OptionsGrammar").optional().to_matchable(),
8006 ])
8007 .to_matchable()
8008 })
8009 .to_matchable()
8010 .into(),
8011 ),
8012 (
8013 "StatisticsReferenceSegment".into(),
8015 Ref::new("ObjectReferenceSegment").to_matchable().into(),
8016 ),
8017 (
8018 "CreateStatisticsStatementSegment".into(),
8021 Sequence::new(vec![
8022 Ref::keyword("CREATE").to_matchable(),
8023 Ref::keyword("STATISTICS").to_matchable(),
8024 Sequence::new(vec![
8025 Ref::new("IfNotExistsGrammar").optional().to_matchable(),
8026 Ref::new("StatisticsReferenceSegment").to_matchable(),
8027 ])
8028 .config(|this| this.optional())
8029 .to_matchable(),
8030 Bracketed::new(vec![
8031 Delimited::new(vec![
8032 Ref::keyword("DEPENDENCIES").to_matchable(),
8033 Ref::keyword("MCV").to_matchable(),
8034 Ref::keyword("NDISTINCT").to_matchable(),
8035 ])
8036 .to_matchable(),
8037 ])
8038 .config(|this| this.optional())
8039 .to_matchable(),
8040 Ref::keyword("ON").to_matchable(),
8041 Delimited::new(vec![
8042 Ref::new("ColumnReferenceSegment").to_matchable(),
8043 Ref::new("ExpressionSegment").to_matchable(),
8044 ])
8045 .to_matchable(),
8046 Ref::keyword("FROM").to_matchable(),
8047 Ref::new("TableReferenceSegment").to_matchable(),
8048 ])
8049 .to_matchable()
8050 .into(),
8051 ),
8052 (
8053 "AlterStatisticsStatementSegment".into(),
8056 Sequence::new(vec![
8057 Ref::keyword("ALTER").to_matchable(),
8058 Ref::keyword("STATISTICS").to_matchable(),
8059 Ref::new("StatisticsReferenceSegment").to_matchable(),
8060 one_of(vec![
8061 Sequence::new(vec![
8062 Ref::keyword("OWNER").to_matchable(),
8063 Ref::keyword("TO").to_matchable(),
8064 one_of(vec![
8065 one_of(vec![
8066 Ref::new("ParameterNameSegment").to_matchable(),
8067 Ref::new("QuotedIdentifierSegment").to_matchable(),
8068 ])
8069 .to_matchable(),
8070 Ref::keyword("CURRENT_ROLE").to_matchable(),
8071 Ref::keyword("CURRENT_USER").to_matchable(),
8072 Ref::keyword("SESSION_USER").to_matchable(),
8073 ])
8074 .to_matchable(),
8075 ])
8076 .to_matchable(),
8077 Sequence::new(vec![
8078 Ref::keyword("RENAME").to_matchable(),
8079 Ref::keyword("TO").to_matchable(),
8080 Ref::new("StatisticsReferenceSegment").to_matchable(),
8081 ])
8082 .to_matchable(),
8083 Sequence::new(vec![
8084 Ref::keyword("SET").to_matchable(),
8085 one_of(vec![
8086 Sequence::new(vec![
8087 Ref::keyword("SCHEMA").to_matchable(),
8088 Ref::new("SchemaReferenceSegment").to_matchable(),
8089 ])
8090 .to_matchable(),
8091 Sequence::new(vec![
8092 Ref::keyword("STATISTICS").to_matchable(),
8093 Ref::new("NumericLiteralSegment").to_matchable(),
8094 ])
8095 .to_matchable(),
8096 ])
8097 .to_matchable(),
8098 ])
8099 .to_matchable(),
8100 ])
8101 .to_matchable(),
8102 ])
8103 .to_matchable()
8104 .into(),
8105 ),
8106 (
8107 "DropStatisticsStatementSegment".into(),
8110 Sequence::new(vec![
8111 Ref::keyword("DROP").to_matchable(),
8112 Ref::keyword("STATISTICS").to_matchable(),
8113 Ref::new("IfExistsGrammar").optional().to_matchable(),
8114 Delimited::new(vec![Ref::new("StatisticsReferenceSegment").to_matchable()])
8115 .to_matchable(),
8116 one_of(vec![
8117 Ref::keyword("CASCADE").to_matchable(),
8118 Ref::keyword("RESTRICT").to_matchable(),
8119 ])
8120 .config(|this| this.optional())
8121 .to_matchable(),
8122 ])
8123 .to_matchable()
8124 .into(),
8125 ),
8126 (
8127 "AccessStatementSegmentGrantRoleWithOptionGrammar".into(),
8128 one_of(vec![
8129 Sequence::new(vec![
8130 Ref::keyword("WITH").to_matchable(),
8131 Ref::keyword("GRANT").to_matchable(),
8132 Ref::keyword("OPTION").to_matchable(),
8133 ])
8134 .to_matchable(),
8135 Sequence::new(vec![
8136 Ref::keyword("WITH").to_matchable(),
8137 Ref::keyword("ADMIN").to_matchable(),
8138 Ref::keyword("OPTION").to_matchable(),
8139 ])
8140 .to_matchable(),
8141 Sequence::new(vec![
8142 Ref::keyword("WITH").to_matchable(),
8143 Ref::keyword("ADMIN").to_matchable(),
8144 Ref::new("BooleanLiteralGrammar").to_matchable(),
8145 ])
8146 .to_matchable(),
8147 Sequence::new(vec![
8148 Ref::keyword("COPY").to_matchable(),
8149 Ref::keyword("CURRENT").to_matchable(),
8150 Ref::keyword("GRANTS").to_matchable(),
8151 ])
8152 .to_matchable(),
8153 ])
8154 .to_matchable()
8155 .into(),
8156 ),
8157 ]);
8158
8159 postgres
8160}
8161
8162pub fn statement_segment() -> Matchable {
8163 ansi::statement_segment().copy(
8164 Some(vec![
8165 Ref::new("CreateStatisticsStatementSegment").to_matchable(),
8166 Ref::new("AlterStatisticsStatementSegment").to_matchable(),
8167 Ref::new("DropStatisticsStatementSegment").to_matchable(),
8168 Ref::new("AlterDefaultPrivilegesStatementSegment").to_matchable(),
8169 Ref::new("DropOwnedStatementSegment").to_matchable(),
8170 Ref::new("ReassignOwnedStatementSegment").to_matchable(),
8171 Ref::new("CommentOnStatementSegment").to_matchable(),
8172 Ref::new("AnalyzeStatementSegment").to_matchable(),
8173 Ref::new("CreateTableAsStatementSegment").to_matchable(),
8174 Ref::new("AlterTriggerStatementSegment").to_matchable(),
8175 Ref::new("AlterAggregateStatementSegment").to_matchable(),
8176 Ref::new("SetStatementSegment").to_matchable(),
8177 Ref::new("AlterPolicyStatementSegment").to_matchable(),
8178 Ref::new("CreatePolicyStatementSegment").to_matchable(),
8179 Ref::new("DropPolicyStatementSegment").to_matchable(),
8180 Ref::new("CreateDomainStatementSegment").to_matchable(),
8181 Ref::new("AlterDomainStatementSegment").to_matchable(),
8182 Ref::new("DropDomainStatementSegment").to_matchable(),
8183 Ref::new("CreateMaterializedViewStatementSegment").to_matchable(),
8184 Ref::new("AlterMaterializedViewStatementSegment").to_matchable(),
8185 Ref::new("DropMaterializedViewStatementSegment").to_matchable(),
8186 Ref::new("RefreshMaterializedViewStatementSegment").to_matchable(),
8187 Ref::new("AlterDatabaseStatementSegment").to_matchable(),
8188 Ref::new("DropDatabaseStatementSegment").to_matchable(),
8189 Ref::new("VacuumStatementSegment").to_matchable(),
8190 Ref::new("AlterFunctionStatementSegment").to_matchable(),
8191 Ref::new("CreateViewStatementSegment").to_matchable(),
8192 Ref::new("AlterViewStatementSegment").to_matchable(),
8193 Ref::new("ListenStatementSegment").to_matchable(),
8194 Ref::new("NotifyStatementSegment").to_matchable(),
8195 Ref::new("UnlistenStatementSegment").to_matchable(),
8196 Ref::new("LoadStatementSegment").to_matchable(),
8197 Ref::new("ResetStatementSegment").to_matchable(),
8198 Ref::new("DiscardStatementSegment").to_matchable(),
8199 Ref::new("AlterProcedureStatementSegment").to_matchable(),
8200 Ref::new("CreateProcedureStatementSegment").to_matchable(),
8201 Ref::new("DropProcedureStatementSegment").to_matchable(),
8202 Ref::new("CopyStatementSegment").to_matchable(),
8203 Ref::new("DoStatementSegment").to_matchable(),
8204 Ref::new("AlterIndexStatementSegment").to_matchable(),
8205 Ref::new("ReindexStatementSegment").to_matchable(),
8206 Ref::new("AlterRoleStatementSegment").to_matchable(),
8207 Ref::new("CreateExtensionStatementSegment").to_matchable(),
8208 Ref::new("DropExtensionStatementSegment").to_matchable(),
8209 Ref::new("CreatePublicationStatementSegment").to_matchable(),
8210 Ref::new("AlterPublicationStatementSegment").to_matchable(),
8211 Ref::new("DropPublicationStatementSegment").to_matchable(),
8212 Ref::new("CreateTypeStatementSegment").to_matchable(),
8213 Ref::new("AlterTypeStatementSegment").to_matchable(),
8214 Ref::new("AlterSchemaStatementSegment").to_matchable(),
8215 Ref::new("LockTableStatementSegment").to_matchable(),
8216 Ref::new("ClusterStatementSegment").to_matchable(),
8217 Ref::new("CreateCollationStatementSegment").to_matchable(),
8218 Ref::new("CallStoredProcedureSegment").to_matchable(),
8219 Ref::new("CreateServerStatementSegment").to_matchable(),
8220 Ref::new("CreateUserMappingStatementSegment").to_matchable(),
8221 Ref::new("ImportForeignSchemaStatementSegment").to_matchable(),
8222 ]),
8223 None,
8224 None,
8225 None,
8226 vec![],
8227 false,
8228 )
8229}