@@ -312,13 +312,13 @@ impl Parser {
312312 let over = if self . parse_keyword ( Keyword :: OVER ) {
313313 // TBD: support window names (`OVER mywin`) in place of inline specification
314314 self . expect_token ( & Token :: LParen ) ?;
315- let partition_by = if self . parse_keywords ( vec ! [ Keyword :: PARTITION , Keyword :: BY ] ) {
315+ let partition_by = if self . parse_keywords ( & [ Keyword :: PARTITION , Keyword :: BY ] ) {
316316 // a list of possibly-qualified column names
317317 self . parse_comma_separated ( Parser :: parse_expr) ?
318318 } else {
319319 vec ! [ ]
320320 } ;
321- let order_by = if self . parse_keywords ( vec ! [ Keyword :: ORDER , Keyword :: BY ] ) {
321+ let order_by = if self . parse_keywords ( & [ Keyword :: ORDER , Keyword :: BY ] ) {
322322 self . parse_comma_separated ( Parser :: parse_order_by_expr) ?
323323 } else {
324324 vec ! [ ]
@@ -379,7 +379,7 @@ impl Parser {
379379
380380 /// Parse `CURRENT ROW` or `{ <positive number> | UNBOUNDED } { PRECEDING | FOLLOWING }`
381381 pub fn parse_window_frame_bound ( & mut self ) -> Result < WindowFrameBound , ParserError > {
382- if self . parse_keywords ( vec ! [ Keyword :: CURRENT , Keyword :: ROW ] ) {
382+ if self . parse_keywords ( & [ Keyword :: CURRENT , Keyword :: ROW ] ) {
383383 Ok ( WindowFrameBound :: CurrentRow )
384384 } else {
385385 let rows = if self . parse_keyword ( Keyword :: UNBOUNDED ) {
@@ -472,7 +472,7 @@ impl Parser {
472472 } else {
473473 None
474474 } ;
475- let on_overflow = if self . parse_keywords ( vec ! [ Keyword :: ON , Keyword :: OVERFLOW ] ) {
475+ let on_overflow = if self . parse_keywords ( & [ Keyword :: ON , Keyword :: OVERFLOW ] ) {
476476 if self . parse_keyword ( Keyword :: ERROR ) {
477477 Some ( ListAggOnOverflow :: Error )
478478 } else {
@@ -503,7 +503,7 @@ impl Parser {
503503 self . expect_token ( & Token :: RParen ) ?;
504504 // Once again ANSI SQL requires WITHIN GROUP, but Redshift does not. Again we choose the
505505 // more general implementation.
506- let within_group = if self . parse_keywords ( vec ! [ Keyword :: WITHIN , Keyword :: GROUP ] ) {
506+ let within_group = if self . parse_keywords ( & [ Keyword :: WITHIN , Keyword :: GROUP ] ) {
507507 self . expect_token ( & Token :: LParen ) ?;
508508 self . expect_keywords ( & [ Keyword :: ORDER , Keyword :: BY ] ) ?;
509509 let order_by_expr = self . parse_comma_separated ( Parser :: parse_order_by_expr) ?;
@@ -665,7 +665,7 @@ impl Parser {
665665 Keyword :: IS => {
666666 if self . parse_keyword ( Keyword :: NULL ) {
667667 Ok ( Expr :: IsNull ( Box :: new ( expr) ) )
668- } else if self . parse_keywords ( vec ! [ Keyword :: NOT , Keyword :: NULL ] ) {
668+ } else if self . parse_keywords ( & [ Keyword :: NOT , Keyword :: NULL ] ) {
669669 Ok ( Expr :: IsNotNull ( Box :: new ( expr) ) )
670670 } else {
671671 self . expected ( "NULL or NOT NULL after IS" , self . peek_token ( ) )
@@ -849,9 +849,9 @@ impl Parser {
849849
850850 /// Look for an expected sequence of keywords and consume them if they exist
851851 #[ must_use]
852- pub fn parse_keywords ( & mut self , keywords : Vec < Keyword > ) -> bool {
852+ pub fn parse_keywords ( & mut self , keywords : & [ Keyword ] ) -> bool {
853853 let index = self . index ;
854- for keyword in keywords {
854+ for & keyword in keywords {
855855 if !self . parse_keyword ( keyword) {
856856 //println!("parse_keywords aborting .. did not find {}", keyword);
857857 // reset index and return immediately
@@ -979,7 +979,7 @@ impl Parser {
979979 self . parse_create_table ( )
980980 } else if self . parse_keyword ( Keyword :: INDEX ) {
981981 self . parse_create_index ( false )
982- } else if self . parse_keywords ( vec ! [ Keyword :: UNIQUE , Keyword :: INDEX ] ) {
982+ } else if self . parse_keywords ( & [ Keyword :: UNIQUE , Keyword :: INDEX ] ) {
983983 self . parse_create_index ( true )
984984 } else if self . parse_keyword ( Keyword :: MATERIALIZED ) || self . parse_keyword ( Keyword :: VIEW ) {
985985 self . prev_token ( ) ;
@@ -1057,7 +1057,7 @@ impl Parser {
10571057 } ;
10581058 // Many dialects support the non standard `IF EXISTS` clause and allow
10591059 // specifying multiple objects to delete in a single statement
1060- let if_exists = self . parse_keywords ( vec ! [ Keyword :: IF , Keyword :: EXISTS ] ) ;
1060+ let if_exists = self . parse_keywords ( & [ Keyword :: IF , Keyword :: EXISTS ] ) ;
10611061 let names = self . parse_comma_separated ( Parser :: parse_object_name) ?;
10621062 let cascade = self . parse_keyword ( Keyword :: CASCADE ) ;
10631063 let restrict = self . parse_keyword ( Keyword :: RESTRICT ) ;
@@ -1073,7 +1073,7 @@ impl Parser {
10731073 }
10741074
10751075 pub fn parse_create_index ( & mut self , unique : bool ) -> Result < Statement , ParserError > {
1076- let if_not_exists = self . parse_keywords ( vec ! [ Keyword :: IF , Keyword :: NOT , Keyword :: EXISTS ] ) ;
1076+ let if_not_exists = self . parse_keywords ( & [ Keyword :: IF , Keyword :: NOT , Keyword :: EXISTS ] ) ;
10771077 let index_name = self . parse_object_name ( ) ?;
10781078 self . expect_keyword ( Keyword :: ON ) ?;
10791079 let table_name = self . parse_object_name ( ) ?;
@@ -1088,7 +1088,7 @@ impl Parser {
10881088 }
10891089
10901090 pub fn parse_create_table ( & mut self ) -> Result < Statement , ParserError > {
1091- let if_not_exists = self . parse_keywords ( vec ! [ Keyword :: IF , Keyword :: NOT , Keyword :: EXISTS ] ) ;
1091+ let if_not_exists = self . parse_keywords ( & [ Keyword :: IF , Keyword :: NOT , Keyword :: EXISTS ] ) ;
10921092 let table_name = self . parse_object_name ( ) ?;
10931093 // parse optional column list (schema)
10941094 let ( columns, constraints) = self . parse_columns ( ) ?;
@@ -1160,13 +1160,13 @@ impl Parser {
11601160 None
11611161 } ;
11621162
1163- let option = if self . parse_keywords ( vec ! [ Keyword :: NOT , Keyword :: NULL ] ) {
1163+ let option = if self . parse_keywords ( & [ Keyword :: NOT , Keyword :: NULL ] ) {
11641164 ColumnOption :: NotNull
11651165 } else if self . parse_keyword ( Keyword :: NULL ) {
11661166 ColumnOption :: Null
11671167 } else if self . parse_keyword ( Keyword :: DEFAULT ) {
11681168 ColumnOption :: Default ( self . parse_expr ( ) ?)
1169- } else if self . parse_keywords ( vec ! [ Keyword :: PRIMARY , Keyword :: KEY ] ) {
1169+ } else if self . parse_keywords ( & [ Keyword :: PRIMARY , Keyword :: KEY ] ) {
11701170 ColumnOption :: Unique { is_primary : true }
11711171 } else if self . parse_keyword ( Keyword :: UNIQUE ) {
11721172 ColumnOption :: Unique { is_primary : false }
@@ -1178,10 +1178,10 @@ impl Parser {
11781178 let mut on_delete = None ;
11791179 let mut on_update = None ;
11801180 loop {
1181- if on_delete. is_none ( ) && self . parse_keywords ( vec ! [ Keyword :: ON , Keyword :: DELETE ] ) {
1181+ if on_delete. is_none ( ) && self . parse_keywords ( & [ Keyword :: ON , Keyword :: DELETE ] ) {
11821182 on_delete = Some ( self . parse_referential_action ( ) ?) ;
11831183 } else if on_update. is_none ( )
1184- && self . parse_keywords ( vec ! [ Keyword :: ON , Keyword :: UPDATE ] )
1184+ && self . parse_keywords ( & [ Keyword :: ON , Keyword :: UPDATE ] )
11851185 {
11861186 on_update = Some ( self . parse_referential_action ( ) ?) ;
11871187 } else {
@@ -1211,11 +1211,11 @@ impl Parser {
12111211 Ok ( ReferentialAction :: Restrict )
12121212 } else if self . parse_keyword ( Keyword :: CASCADE ) {
12131213 Ok ( ReferentialAction :: Cascade )
1214- } else if self . parse_keywords ( vec ! [ Keyword :: SET , Keyword :: NULL ] ) {
1214+ } else if self . parse_keywords ( & [ Keyword :: SET , Keyword :: NULL ] ) {
12151215 Ok ( ReferentialAction :: SetNull )
1216- } else if self . parse_keywords ( vec ! [ Keyword :: NO , Keyword :: ACTION ] ) {
1216+ } else if self . parse_keywords ( & [ Keyword :: NO , Keyword :: ACTION ] ) {
12171217 Ok ( ReferentialAction :: NoAction )
1218- } else if self . parse_keywords ( vec ! [ Keyword :: SET , Keyword :: DEFAULT ] ) {
1218+ } else if self . parse_keywords ( & [ Keyword :: SET , Keyword :: DEFAULT ] ) {
12191219 Ok ( ReferentialAction :: SetDefault )
12201220 } else {
12211221 self . expected (
@@ -1633,7 +1633,7 @@ impl Parser {
16331633
16341634 let body = self . parse_query_body ( 0 ) ?;
16351635
1636- let order_by = if self . parse_keywords ( vec ! [ Keyword :: ORDER , Keyword :: BY ] ) {
1636+ let order_by = if self . parse_keywords ( & [ Keyword :: ORDER , Keyword :: BY ] ) {
16371637 self . parse_comma_separated ( Parser :: parse_order_by_expr) ?
16381638 } else {
16391639 vec ! [ ]
@@ -1772,7 +1772,7 @@ impl Parser {
17721772 None
17731773 } ;
17741774
1775- let group_by = if self . parse_keywords ( vec ! [ Keyword :: GROUP , Keyword :: BY ] ) {
1775+ let group_by = if self . parse_keywords ( & [ Keyword :: GROUP , Keyword :: BY ] ) {
17761776 self . parse_comma_separated ( Parser :: parse_expr) ?
17771777 } else {
17781778 vec ! [ ]
@@ -2124,9 +2124,9 @@ impl Parser {
21242124 None
21252125 } ;
21262126
2127- let nulls_first = if self . parse_keywords ( vec ! [ Keyword :: NULLS , Keyword :: FIRST ] ) {
2127+ let nulls_first = if self . parse_keywords ( & [ Keyword :: NULLS , Keyword :: FIRST ] ) {
21282128 Some ( true )
2129- } else if self . parse_keywords ( vec ! [ Keyword :: NULLS , Keyword :: LAST ] ) {
2129+ } else if self . parse_keywords ( & [ Keyword :: NULLS , Keyword :: LAST ] ) {
21302130 Some ( false )
21312131 } else {
21322132 None
@@ -2152,7 +2152,7 @@ impl Parser {
21522152
21532153 let percent = self . parse_keyword ( Keyword :: PERCENT ) ;
21542154
2155- let with_ties = self . parse_keywords ( vec ! [ Keyword :: WITH , Keyword :: TIES ] ) ;
2155+ let with_ties = self . parse_keywords ( & [ Keyword :: WITH , Keyword :: TIES ] ) ;
21562156
21572157 Ok ( Top {
21582158 with_ties,
@@ -2199,7 +2199,7 @@ impl Parser {
21992199 } ;
22002200 let with_ties = if self . parse_keyword ( Keyword :: ONLY ) {
22012201 false
2202- } else if self . parse_keywords ( vec ! [ Keyword :: WITH , Keyword :: TIES ] ) {
2202+ } else if self . parse_keywords ( & [ Keyword :: WITH , Keyword :: TIES ] ) {
22032203 true
22042204 } else {
22052205 return self . expected ( "one of ONLY or WITH TIES" , self . peek_token ( ) ) ;
@@ -2239,22 +2239,22 @@ impl Parser {
22392239 let mut modes = vec ! [ ] ;
22402240 let mut required = false ;
22412241 loop {
2242- let mode = if self . parse_keywords ( vec ! [ Keyword :: ISOLATION , Keyword :: LEVEL ] ) {
2243- let iso_level = if self . parse_keywords ( vec ! [ Keyword :: READ , Keyword :: UNCOMMITTED ] ) {
2242+ let mode = if self . parse_keywords ( & [ Keyword :: ISOLATION , Keyword :: LEVEL ] ) {
2243+ let iso_level = if self . parse_keywords ( & [ Keyword :: READ , Keyword :: UNCOMMITTED ] ) {
22442244 TransactionIsolationLevel :: ReadUncommitted
2245- } else if self . parse_keywords ( vec ! [ Keyword :: READ , Keyword :: COMMITTED ] ) {
2245+ } else if self . parse_keywords ( & [ Keyword :: READ , Keyword :: COMMITTED ] ) {
22462246 TransactionIsolationLevel :: ReadCommitted
2247- } else if self . parse_keywords ( vec ! [ Keyword :: REPEATABLE , Keyword :: READ ] ) {
2247+ } else if self . parse_keywords ( & [ Keyword :: REPEATABLE , Keyword :: READ ] ) {
22482248 TransactionIsolationLevel :: RepeatableRead
22492249 } else if self . parse_keyword ( Keyword :: SERIALIZABLE ) {
22502250 TransactionIsolationLevel :: Serializable
22512251 } else {
22522252 self . expected ( "isolation level" , self . peek_token ( ) ) ?
22532253 } ;
22542254 TransactionMode :: IsolationLevel ( iso_level)
2255- } else if self . parse_keywords ( vec ! [ Keyword :: READ , Keyword :: ONLY ] ) {
2255+ } else if self . parse_keywords ( & [ Keyword :: READ , Keyword :: ONLY ] ) {
22562256 TransactionMode :: AccessMode ( TransactionAccessMode :: ReadOnly )
2257- } else if self . parse_keywords ( vec ! [ Keyword :: READ , Keyword :: WRITE ] ) {
2257+ } else if self . parse_keywords ( & [ Keyword :: READ , Keyword :: WRITE ] ) {
22582258 TransactionMode :: AccessMode ( TransactionAccessMode :: ReadWrite )
22592259 } else if required {
22602260 self . expected ( "transaction mode" , self . peek_token ( ) ) ?
0 commit comments