@@ -312,13 +312,13 @@ impl Parser {
312
312
let over = if self . parse_keyword ( Keyword :: OVER ) {
313
313
// TBD: support window names (`OVER mywin`) in place of inline specification
314
314
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 ] ) {
316
316
// a list of possibly-qualified column names
317
317
self . parse_comma_separated ( Parser :: parse_expr) ?
318
318
} else {
319
319
vec ! [ ]
320
320
} ;
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 ] ) {
322
322
self . parse_comma_separated ( Parser :: parse_order_by_expr) ?
323
323
} else {
324
324
vec ! [ ]
@@ -379,7 +379,7 @@ impl Parser {
379
379
380
380
/// Parse `CURRENT ROW` or `{ <positive number> | UNBOUNDED } { PRECEDING | FOLLOWING }`
381
381
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 ] ) {
383
383
Ok ( WindowFrameBound :: CurrentRow )
384
384
} else {
385
385
let rows = if self . parse_keyword ( Keyword :: UNBOUNDED ) {
@@ -472,7 +472,7 @@ impl Parser {
472
472
} else {
473
473
None
474
474
} ;
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 ] ) {
476
476
if self . parse_keyword ( Keyword :: ERROR ) {
477
477
Some ( ListAggOnOverflow :: Error )
478
478
} else {
@@ -503,7 +503,7 @@ impl Parser {
503
503
self . expect_token ( & Token :: RParen ) ?;
504
504
// Once again ANSI SQL requires WITHIN GROUP, but Redshift does not. Again we choose the
505
505
// 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 ] ) {
507
507
self . expect_token ( & Token :: LParen ) ?;
508
508
self . expect_keywords ( & [ Keyword :: ORDER , Keyword :: BY ] ) ?;
509
509
let order_by_expr = self . parse_comma_separated ( Parser :: parse_order_by_expr) ?;
@@ -665,7 +665,7 @@ impl Parser {
665
665
Keyword :: IS => {
666
666
if self . parse_keyword ( Keyword :: NULL ) {
667
667
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 ] ) {
669
669
Ok ( Expr :: IsNotNull ( Box :: new ( expr) ) )
670
670
} else {
671
671
self . expected ( "NULL or NOT NULL after IS" , self . peek_token ( ) )
@@ -849,9 +849,9 @@ impl Parser {
849
849
850
850
/// Look for an expected sequence of keywords and consume them if they exist
851
851
#[ must_use]
852
- pub fn parse_keywords ( & mut self , keywords : Vec < Keyword > ) -> bool {
852
+ pub fn parse_keywords ( & mut self , keywords : & [ Keyword ] ) -> bool {
853
853
let index = self . index ;
854
- for keyword in keywords {
854
+ for & keyword in keywords {
855
855
if !self . parse_keyword ( keyword) {
856
856
//println!("parse_keywords aborting .. did not find {}", keyword);
857
857
// reset index and return immediately
@@ -979,7 +979,7 @@ impl Parser {
979
979
self . parse_create_table ( )
980
980
} else if self . parse_keyword ( Keyword :: INDEX ) {
981
981
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 ] ) {
983
983
self . parse_create_index ( true )
984
984
} else if self . parse_keyword ( Keyword :: MATERIALIZED ) || self . parse_keyword ( Keyword :: VIEW ) {
985
985
self . prev_token ( ) ;
@@ -1057,7 +1057,7 @@ impl Parser {
1057
1057
} ;
1058
1058
// Many dialects support the non standard `IF EXISTS` clause and allow
1059
1059
// 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 ] ) ;
1061
1061
let names = self . parse_comma_separated ( Parser :: parse_object_name) ?;
1062
1062
let cascade = self . parse_keyword ( Keyword :: CASCADE ) ;
1063
1063
let restrict = self . parse_keyword ( Keyword :: RESTRICT ) ;
@@ -1073,7 +1073,7 @@ impl Parser {
1073
1073
}
1074
1074
1075
1075
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 ] ) ;
1077
1077
let index_name = self . parse_object_name ( ) ?;
1078
1078
self . expect_keyword ( Keyword :: ON ) ?;
1079
1079
let table_name = self . parse_object_name ( ) ?;
@@ -1088,7 +1088,7 @@ impl Parser {
1088
1088
}
1089
1089
1090
1090
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 ] ) ;
1092
1092
let table_name = self . parse_object_name ( ) ?;
1093
1093
// parse optional column list (schema)
1094
1094
let ( columns, constraints) = self . parse_columns ( ) ?;
@@ -1160,13 +1160,13 @@ impl Parser {
1160
1160
None
1161
1161
} ;
1162
1162
1163
- let option = if self . parse_keywords ( vec ! [ Keyword :: NOT , Keyword :: NULL ] ) {
1163
+ let option = if self . parse_keywords ( & [ Keyword :: NOT , Keyword :: NULL ] ) {
1164
1164
ColumnOption :: NotNull
1165
1165
} else if self . parse_keyword ( Keyword :: NULL ) {
1166
1166
ColumnOption :: Null
1167
1167
} else if self . parse_keyword ( Keyword :: DEFAULT ) {
1168
1168
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 ] ) {
1170
1170
ColumnOption :: Unique { is_primary : true }
1171
1171
} else if self . parse_keyword ( Keyword :: UNIQUE ) {
1172
1172
ColumnOption :: Unique { is_primary : false }
@@ -1178,10 +1178,10 @@ impl Parser {
1178
1178
let mut on_delete = None ;
1179
1179
let mut on_update = None ;
1180
1180
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 ] ) {
1182
1182
on_delete = Some ( self . parse_referential_action ( ) ?) ;
1183
1183
} else if on_update. is_none ( )
1184
- && self . parse_keywords ( vec ! [ Keyword :: ON , Keyword :: UPDATE ] )
1184
+ && self . parse_keywords ( & [ Keyword :: ON , Keyword :: UPDATE ] )
1185
1185
{
1186
1186
on_update = Some ( self . parse_referential_action ( ) ?) ;
1187
1187
} else {
@@ -1211,11 +1211,11 @@ impl Parser {
1211
1211
Ok ( ReferentialAction :: Restrict )
1212
1212
} else if self . parse_keyword ( Keyword :: CASCADE ) {
1213
1213
Ok ( ReferentialAction :: Cascade )
1214
- } else if self . parse_keywords ( vec ! [ Keyword :: SET , Keyword :: NULL ] ) {
1214
+ } else if self . parse_keywords ( & [ Keyword :: SET , Keyword :: NULL ] ) {
1215
1215
Ok ( ReferentialAction :: SetNull )
1216
- } else if self . parse_keywords ( vec ! [ Keyword :: NO , Keyword :: ACTION ] ) {
1216
+ } else if self . parse_keywords ( & [ Keyword :: NO , Keyword :: ACTION ] ) {
1217
1217
Ok ( ReferentialAction :: NoAction )
1218
- } else if self . parse_keywords ( vec ! [ Keyword :: SET , Keyword :: DEFAULT ] ) {
1218
+ } else if self . parse_keywords ( & [ Keyword :: SET , Keyword :: DEFAULT ] ) {
1219
1219
Ok ( ReferentialAction :: SetDefault )
1220
1220
} else {
1221
1221
self . expected (
@@ -1633,7 +1633,7 @@ impl Parser {
1633
1633
1634
1634
let body = self . parse_query_body ( 0 ) ?;
1635
1635
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 ] ) {
1637
1637
self . parse_comma_separated ( Parser :: parse_order_by_expr) ?
1638
1638
} else {
1639
1639
vec ! [ ]
@@ -1772,7 +1772,7 @@ impl Parser {
1772
1772
None
1773
1773
} ;
1774
1774
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 ] ) {
1776
1776
self . parse_comma_separated ( Parser :: parse_expr) ?
1777
1777
} else {
1778
1778
vec ! [ ]
@@ -2124,9 +2124,9 @@ impl Parser {
2124
2124
None
2125
2125
} ;
2126
2126
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 ] ) {
2128
2128
Some ( true )
2129
- } else if self . parse_keywords ( vec ! [ Keyword :: NULLS , Keyword :: LAST ] ) {
2129
+ } else if self . parse_keywords ( & [ Keyword :: NULLS , Keyword :: LAST ] ) {
2130
2130
Some ( false )
2131
2131
} else {
2132
2132
None
@@ -2152,7 +2152,7 @@ impl Parser {
2152
2152
2153
2153
let percent = self . parse_keyword ( Keyword :: PERCENT ) ;
2154
2154
2155
- let with_ties = self . parse_keywords ( vec ! [ Keyword :: WITH , Keyword :: TIES ] ) ;
2155
+ let with_ties = self . parse_keywords ( & [ Keyword :: WITH , Keyword :: TIES ] ) ;
2156
2156
2157
2157
Ok ( Top {
2158
2158
with_ties,
@@ -2199,7 +2199,7 @@ impl Parser {
2199
2199
} ;
2200
2200
let with_ties = if self . parse_keyword ( Keyword :: ONLY ) {
2201
2201
false
2202
- } else if self . parse_keywords ( vec ! [ Keyword :: WITH , Keyword :: TIES ] ) {
2202
+ } else if self . parse_keywords ( & [ Keyword :: WITH , Keyword :: TIES ] ) {
2203
2203
true
2204
2204
} else {
2205
2205
return self . expected ( "one of ONLY or WITH TIES" , self . peek_token ( ) ) ;
@@ -2239,22 +2239,22 @@ impl Parser {
2239
2239
let mut modes = vec ! [ ] ;
2240
2240
let mut required = false ;
2241
2241
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 ] ) {
2244
2244
TransactionIsolationLevel :: ReadUncommitted
2245
- } else if self . parse_keywords ( vec ! [ Keyword :: READ , Keyword :: COMMITTED ] ) {
2245
+ } else if self . parse_keywords ( & [ Keyword :: READ , Keyword :: COMMITTED ] ) {
2246
2246
TransactionIsolationLevel :: ReadCommitted
2247
- } else if self . parse_keywords ( vec ! [ Keyword :: REPEATABLE , Keyword :: READ ] ) {
2247
+ } else if self . parse_keywords ( & [ Keyword :: REPEATABLE , Keyword :: READ ] ) {
2248
2248
TransactionIsolationLevel :: RepeatableRead
2249
2249
} else if self . parse_keyword ( Keyword :: SERIALIZABLE ) {
2250
2250
TransactionIsolationLevel :: Serializable
2251
2251
} else {
2252
2252
self . expected ( "isolation level" , self . peek_token ( ) ) ?
2253
2253
} ;
2254
2254
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 ] ) {
2256
2256
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 ] ) {
2258
2258
TransactionMode :: AccessMode ( TransactionAccessMode :: ReadWrite )
2259
2259
} else if required {
2260
2260
self . expected ( "transaction mode" , self . peek_token ( ) ) ?
0 commit comments