@@ -200,25 +200,47 @@ impl Statement {
200
200
is_insert,
201
201
} )
202
202
}
203
+
204
+ // Workaround for CREATE FUNCTION.
205
+ // FIXME: this should be handled by the parser (or *at least* trimmed + case insensitive)
206
+ let is_create_function = s. starts_with ( "CREATE FUNCTION" ) ;
207
+ let mut maybe_create_function_stmt = is_create_function. then ( || {
208
+ Ok ( Statement {
209
+ stmt : s. to_string ( ) ,
210
+ kind : StmtKind :: Other ,
211
+ is_iud : false ,
212
+ is_insert : false ,
213
+ } )
214
+ } ) ;
215
+
203
216
// The parser needs to be boxed because it's large, and you don't want it on the stack.
204
217
// There's upstream work to make it smaller, but in the meantime the parser should remain
205
218
// on the heap:
206
219
// - https://github.com/gwenn/lemon-rs/issues/8
207
220
// - https://github.com/gwenn/lemon-rs/pull/19
208
221
let mut parser = Box :: new ( Parser :: new ( s. as_bytes ( ) ) ) ;
209
- std:: iter:: from_fn ( move || match parser. next ( ) {
210
- Ok ( Some ( cmd) ) => Some ( parse_inner ( s, cmd) ) ,
211
- Ok ( None ) => None ,
212
- Err ( sqlite3_parser:: lexer:: sql:: Error :: ParserError (
213
- ParserError :: SyntaxError {
214
- token_type : _,
215
- found : Some ( found) ,
216
- } ,
217
- Some ( ( line, col) ) ,
218
- ) ) => Some ( Err ( anyhow:: anyhow!(
219
- "syntax error around L{line}:{col}: `{found}`"
220
- ) ) ) ,
221
- Err ( e) => Some ( Err ( e. into ( ) ) ) ,
222
+ std:: iter:: from_fn ( move || {
223
+ if is_create_function {
224
+ let ret = maybe_create_function_stmt. take ( ) ;
225
+ println ! ( "Ret {ret:?}" ) ;
226
+ return ret;
227
+ //return maybe_create_function_stmt.take();
228
+ }
229
+
230
+ match parser. next ( ) {
231
+ Ok ( Some ( cmd) ) => Some ( parse_inner ( s, cmd) ) ,
232
+ Ok ( None ) => None ,
233
+ Err ( sqlite3_parser:: lexer:: sql:: Error :: ParserError (
234
+ ParserError :: SyntaxError {
235
+ token_type : _,
236
+ found : Some ( found) ,
237
+ } ,
238
+ Some ( ( line, col) ) ,
239
+ ) ) => Some ( Err ( anyhow:: anyhow!(
240
+ "syntax error around L{line}:{col}: `{found}`"
241
+ ) ) ) ,
242
+ Err ( e) => Some ( Err ( e. into ( ) ) ) ,
243
+ }
222
244
} )
223
245
}
224
246
0 commit comments