@@ -3629,6 +3629,108 @@ fn parse_drop_function() {
36293629 ) ;
36303630}
36313631
3632+ #[ test]
3633+ fn parse_drop_procedure ( ) {
3634+ let sql = "DROP PROCEDURE IF EXISTS test_proc" ;
3635+ assert_eq ! (
3636+ pg( ) . verified_stmt( sql) ,
3637+ Statement :: DropProcedure {
3638+ if_exists: true ,
3639+ proc_desc: vec![ DropFunctionDesc {
3640+ name: ObjectName ( vec![ Ident {
3641+ value: "test_proc" . to_string( ) ,
3642+ quote_style: None
3643+ } ] ) ,
3644+ args: None
3645+ } ] ,
3646+ option: None
3647+ }
3648+ ) ;
3649+
3650+ let sql = "DROP PROCEDURE IF EXISTS test_proc(a INTEGER, IN b INTEGER = 1)" ;
3651+ assert_eq ! (
3652+ pg( ) . verified_stmt( sql) ,
3653+ Statement :: DropProcedure {
3654+ if_exists: true ,
3655+ proc_desc: vec![ DropFunctionDesc {
3656+ name: ObjectName ( vec![ Ident {
3657+ value: "test_proc" . to_string( ) ,
3658+ quote_style: None
3659+ } ] ) ,
3660+ args: Some ( vec![
3661+ OperateFunctionArg :: with_name( "a" , DataType :: Integer ( None ) ) ,
3662+ OperateFunctionArg {
3663+ mode: Some ( ArgMode :: In ) ,
3664+ name: Some ( "b" . into( ) ) ,
3665+ data_type: DataType :: Integer ( None ) ,
3666+ default_expr: Some ( Expr :: Value ( Value :: Number ( "1" . parse( ) . unwrap( ) , false ) ) ) ,
3667+ }
3668+ ] ) ,
3669+ } ] ,
3670+ option: None
3671+ }
3672+ ) ;
3673+
3674+ let sql = "DROP PROCEDURE IF EXISTS test_proc1(a INTEGER, IN b INTEGER = 1), test_proc2(a VARCHAR, IN b INTEGER = 1)" ;
3675+ assert_eq ! (
3676+ pg( ) . verified_stmt( sql) ,
3677+ Statement :: DropProcedure {
3678+ if_exists: true ,
3679+ proc_desc: vec![
3680+ DropFunctionDesc {
3681+ name: ObjectName ( vec![ Ident {
3682+ value: "test_proc1" . to_string( ) ,
3683+ quote_style: None
3684+ } ] ) ,
3685+ args: Some ( vec![
3686+ OperateFunctionArg :: with_name( "a" , DataType :: Integer ( None ) ) ,
3687+ OperateFunctionArg {
3688+ mode: Some ( ArgMode :: In ) ,
3689+ name: Some ( "b" . into( ) ) ,
3690+ data_type: DataType :: Integer ( None ) ,
3691+ default_expr: Some ( Expr :: Value ( Value :: Number (
3692+ "1" . parse( ) . unwrap( ) ,
3693+ false
3694+ ) ) ) ,
3695+ }
3696+ ] ) ,
3697+ } ,
3698+ DropFunctionDesc {
3699+ name: ObjectName ( vec![ Ident {
3700+ value: "test_proc2" . to_string( ) ,
3701+ quote_style: None
3702+ } ] ) ,
3703+ args: Some ( vec![
3704+ OperateFunctionArg :: with_name( "a" , DataType :: Varchar ( None ) ) ,
3705+ OperateFunctionArg {
3706+ mode: Some ( ArgMode :: In ) ,
3707+ name: Some ( "b" . into( ) ) ,
3708+ data_type: DataType :: Integer ( None ) ,
3709+ default_expr: Some ( Expr :: Value ( Value :: Number (
3710+ "1" . parse( ) . unwrap( ) ,
3711+ false
3712+ ) ) ) ,
3713+ }
3714+ ] ) ,
3715+ }
3716+ ] ,
3717+ option: None
3718+ }
3719+ ) ;
3720+
3721+ let res = pg ( ) . parse_sql_statements ( "DROP PROCEDURE testproc DROP" ) ;
3722+ assert_eq ! (
3723+ ParserError :: ParserError ( "Expected: end of statement, found: DROP" . to_string( ) ) ,
3724+ res. unwrap_err( )
3725+ ) ;
3726+
3727+ let res = pg ( ) . parse_sql_statements ( "DROP PROCEDURE testproc SET NULL" ) ;
3728+ assert_eq ! (
3729+ ParserError :: ParserError ( "Expected: end of statement, found: SET" . to_string( ) ) ,
3730+ res. unwrap_err( )
3731+ ) ;
3732+ }
3733+
36323734#[ test]
36333735fn parse_dollar_quoted_string ( ) {
36343736 let sql = "SELECT $$hello$$, $tag_name$world$tag_name$, $$Foo$Bar$$, $$Foo$Bar$$col_name, $$$$, $tag_name$$tag_name$" ;
0 commit comments