@@ -37,7 +37,7 @@ pub trait ExprVisitor {
3737 fn visit_ident ( & mut self , ident : & mut p:: Ident ) -> Result < ( ) , ( ) > ;
3838 /// Visit a function name. Must return `Err` if the function is not
3939 /// allowed
40- fn visit_func_name ( & mut self , func : & mut p:: Ident ) -> Result < ( ) , ( ) > ;
40+ fn visit_func_name ( & mut self , func : & mut p:: ObjectNamePart ) -> Result < ( ) , ( ) > ;
4141 /// Called when we encounter a construct that is not supported like a
4242 /// subquery
4343 fn not_supported ( & mut self , msg : String ) ;
@@ -112,17 +112,16 @@ impl<'a> VisitExpr<'a> {
112112 Case {
113113 operand,
114114 conditions,
115- results,
116115 else_result,
116+ case_token : _,
117+ end_token : _,
117118 } => {
118119 if let Some ( operand) = operand {
119120 self . visit_expr ( operand) ?;
120121 }
121122 for condition in conditions {
122- self . visit_expr ( condition) ?;
123- }
124- for result in results {
125- self . visit_expr ( result) ?;
123+ self . visit_expr ( & mut condition. condition ) ?;
124+ self . visit_expr ( & mut condition. result ) ?;
126125 }
127126 if let Some ( else_result) = else_result {
128127 self . visit_expr ( else_result) ?;
@@ -152,7 +151,6 @@ impl<'a> VisitExpr<'a> {
152151 }
153152 CompoundIdentifier ( _) => self . nope ( "CompoundIdentifier" ) ,
154153 JsonAccess { .. } => self . nope ( "JsonAccess" ) ,
155- CompositeAccess { .. } => self . nope ( "CompositeAccess" ) ,
156154 IsUnknown ( _) => self . nope ( "IsUnknown" ) ,
157155 IsNotUnknown ( _) => self . nope ( "IsNotUnknown" ) ,
158156 InList { .. } => self . nope ( "InList" ) ,
@@ -175,9 +173,7 @@ impl<'a> VisitExpr<'a> {
175173 Trim { .. } => self . nope ( "Trim" ) ,
176174 Overlay { .. } => self . nope ( "Overlay" ) ,
177175 Collate { .. } => self . nope ( "Collate" ) ,
178- IntroducedString { .. } => self . nope ( "IntroducedString" ) ,
179176 TypedString { .. } => self . nope ( "TypedString" ) ,
180- MapAccess { .. } => self . nope ( "MapAccess" ) ,
181177 Exists { .. } => self . nope ( "Exists" ) ,
182178 Subquery ( _) => self . nope ( "Subquery" ) ,
183179 GroupingSets ( _) => self . nope ( "GroupingSets" ) ,
@@ -186,32 +182,41 @@ impl<'a> VisitExpr<'a> {
186182 Tuple ( _) => self . nope ( "Tuple" ) ,
187183 Struct { .. } => self . nope ( "Struct" ) ,
188184 Named { .. } => self . nope ( "Named" ) ,
189- ArrayIndex { .. } => self . nope ( "ArrayIndex" ) ,
190185 Array ( _) => self . nope ( "Array" ) ,
191186 Interval ( _) => self . nope ( "Interval" ) ,
192187 MatchAgainst { .. } => self . nope ( "MatchAgainst" ) ,
193- Wildcard => self . nope ( "Wildcard" ) ,
194- QualifiedWildcard ( _) => self . nope ( "QualifiedWildcard" ) ,
188+ Wildcard ( _ ) => self . nope ( "Wildcard" ) ,
189+ QualifiedWildcard ( _, _ ) => self . nope ( "QualifiedWildcard" ) ,
195190 Dictionary ( _) => self . nope ( "Dictionary" ) ,
196191 OuterJoin ( _) => self . nope ( "OuterJoin" ) ,
197192 Prior ( _) => self . nope ( "Prior" ) ,
193+ CompoundFieldAccess { .. } => self . nope ( "CompoundFieldAccess" ) ,
194+ IsNormalized { .. } => self . nope ( "IsNormalized" ) ,
195+ Prefixed { .. } => self . nope ( "Prefixed" ) ,
196+ Map ( _) => self . nope ( "Map" ) ,
197+ Lambda ( _) => self . nope ( "Lambda" ) ,
198+ MemberOf ( _) => self . nope ( "MemberOf" ) ,
198199 }
199200 }
200201
201202 fn visit_func ( & mut self , func : & mut p:: Function ) -> Result < ( ) , ( ) > {
202203 let p:: Function {
203204 name,
205+ parameters,
204206 args : pargs,
205207 filter,
206208 null_treatment,
207209 over,
208210 within_group,
211+ uses_odbc_syntax,
209212 } = func;
210213
211214 if filter. is_some ( )
212215 || null_treatment. is_some ( )
213216 || over. is_some ( )
214217 || !within_group. is_empty ( )
218+ || * uses_odbc_syntax
219+ || !matches ! ( parameters, p:: FunctionArguments :: None )
215220 {
216221 return self . illegal_function ( format ! ( "call to {name} uses an illegal feature" ) ) ;
217222 }
@@ -259,6 +264,15 @@ impl<'a> VisitExpr<'a> {
259264 ) ) ;
260265 }
261266 } ,
267+ ExprNamed {
268+ name : expr_name,
269+ arg : _,
270+ operator : _,
271+ } => {
272+ return self . illegal_function ( format ! (
273+ "call to {name} uses illegal ExprNamed {expr_name}"
274+ ) ) ;
275+ }
262276 } ;
263277 }
264278 }
@@ -304,7 +318,27 @@ impl<'a> VisitExpr<'a> {
304318 | AtQuestion
305319 | Question
306320 | QuestionAnd
307- | QuestionPipe => self . not_supported ( format ! ( "binary operator {op} is not supported" ) ) ,
321+ | QuestionPipe
322+ | Match
323+ | Regexp
324+ | Overlaps
325+ | DoubleHash
326+ | LtDashGt
327+ | AndLt
328+ | AndGt
329+ | LtLtPipe
330+ | PipeGtGt
331+ | AndLtPipe
332+ | PipeAndGt
333+ | LtCaret
334+ | GtCaret
335+ | QuestionHash
336+ | QuestionDash
337+ | QuestionDashPipe
338+ | QuestionDoublePipe
339+ | At
340+ | TildeEq
341+ | Assignment => self . not_supported ( format ! ( "binary operator {op} is not supported" ) ) ,
308342 }
309343 }
310344
@@ -313,7 +347,9 @@ impl<'a> VisitExpr<'a> {
313347 match op {
314348 Plus | Minus | Not => Ok ( ( ) ) ,
315349 PGBitwiseNot | PGSquareRoot | PGCubeRoot | PGPostfixFactorial | PGPrefixFactorial
316- | PGAbs => self . not_supported ( format ! ( "unary operator {op} is not supported" ) ) ,
350+ | PGAbs | BangNot | Hash | AtDashAt | DoubleAt | QuestionDash | QuestionPipe => {
351+ self . not_supported ( format ! ( "unary operator {op} is not supported" ) )
352+ }
317353 }
318354 }
319355}
@@ -346,8 +382,19 @@ impl<F: CheckIdentFn> ExprVisitor for Validator<F> {
346382 }
347383 }
348384
349- fn visit_func_name ( & mut self , func : & mut p:: Ident ) -> Result < ( ) , ( ) > {
350- let p:: Ident { value, quote_style } = & func;
385+ fn visit_func_name ( & mut self , func : & mut p:: ObjectNamePart ) -> Result < ( ) , ( ) > {
386+ let func = match func {
387+ p:: ObjectNamePart :: Identifier ( ident) => ident,
388+ p:: ObjectNamePart :: Function ( p:: ObjectNamePartFunction { name, args : _ } ) => {
389+ self . not_supported ( format ! ( "function {name} is an object naming function" ) ) ;
390+ return Err ( ( ) ) ;
391+ }
392+ } ;
393+ let p:: Ident {
394+ value,
395+ quote_style,
396+ span : _,
397+ } = & func;
351398 let whitelisted = match quote_style {
352399 Some ( _) => FN_WHITELIST . contains ( & value. as_str ( ) ) ,
353400 None => FN_WHITELIST
0 commit comments