Re: 025ca90e5df: MDEV-32101 CREATE PACKAGE [BODY] for sql_mode=DEFAULT
Hi, Alexander, On Sep 15, Alexander Barkov wrote:
revision-id: 025ca90e5df (mariadb-11.0.1-231-g025ca90e5df) parent(s): 8ad1e26b1ba author: Alexander Barkov committer: Alexander Barkov timestamp: 2023-09-05 17:33:27 +0400 message:
MDEV-32101 CREATE PACKAGE [BODY] for sql_mode=DEFAULT
This patch adds PACKAGE support with SQL/PSM dialect for sql_mode=DEFAULT:
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7452f6a083a..22c60bd4277 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -18454,6 +18518,22 @@ drop_routine: if (Lex->stmt_drop_procedure($3, $4)) MYSQL_YYABORT; } + | DROP PACKAGE_MARIADB_SYM opt_if_exists sp_name + { + LEX *lex= Lex; + lex->set_command(SQLCOM_DROP_PACKAGE, $3); + if (unlikely(lex->sphead)) + my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PACKAGE")); + lex->spname= $4; + } + | DROP PACKAGE_MARIADB_SYM BODY_MARIADB_SYM opt_if_exists sp_name + { + LEX *lex= Lex; + lex->set_command(SQLCOM_DROP_PACKAGE_BODY, $4); + if (unlikely(lex->sphead)) + my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PACKAGE BODY")); + lex->spname= $5; + } ;
at least here and in SHOW you can use package: PACKAGE_MARIADB_SYM | PACKAGE_ORACLE_SYM ; and then move drop_routine out of ifdef
@@ -18498,6 +18578,248 @@ create_routine: (Item_result) $8, $10)) MYSQL_YYABORT; } + + | create_or_replace definer_opt PACKAGE_MARIADB_SYM + opt_if_not_exists sp_name opt_create_package_chistics_init + remember_name + { + sp_package *pkg; + if (unlikely(!(pkg= Lex-> + create_package_start(thd, + SQLCOM_CREATE_PACKAGE, + &sp_handler_package_spec, + $5, $1 | $4)))) + MYSQL_YYABORT; + pkg->set_c_chistics(Lex->sp_chistics); + } + opt_sqlpsm_package_specification_element_list END + remember_end_opt + { + if (unlikely(Lex->create_package_finalize(thd, $5, NULL, $7, $11))) + MYSQL_YYABORT; + } + | create_or_replace definer_opt PACKAGE_MARIADB_SYM BODY_MARIADB_SYM + opt_if_not_exists sp_name opt_create_package_chistics_init + remember_name + { + sp_package *pkg; + if (unlikely(!(pkg= Lex-> + create_package_start(thd, + SQLCOM_CREATE_PACKAGE_BODY, + &sp_handler_package_body, + $6, $1 | $5)))) + MYSQL_YYABORT; + pkg->set_c_chistics(Lex->sp_chistics); + Lex->sp_block_init(thd); + } + sqlpsm_package_implementation_declare_section + { + if (unlikely(Lex->sp_block_with_exceptions_finalize_declarations(thd))) + MYSQL_YYABORT; + } + sqlpsm_package_implementation_executable_section + { + $10.hndlrs+= $12.hndlrs; + if (unlikely(Lex->sp_block_finalize(thd, $10))) + MYSQL_YYABORT; + } + remember_end_opt + { + if (unlikely(Lex->create_package_finalize(thd, $6, NULL, $8, $14))) + MYSQL_YYABORT; + }
this can also use `package` rule as above and be moved outside of %ifdef. you'll only need %ifdef MARIADB sp_tail_is: _empty ; opt_sp_name: _empty { $$= NULL; } ; %else sp_tail_is: IS | AS ; opt_sp_name: _empty { $$= NULL; } | sp_name { $$= $1; } ; %endif
+ ; + + +opt_sqlpsm_package_specification_element_list: + _empty + | sqlpsm_package_specification_element_list + ;
and so on, this can be called simply opt_package_specification_element_list if placed under %ifdef MARIADB
+ +sqlpsm_package_specification_element_list: + sqlpsm_package_specification_element + | sqlpsm_package_specification_element_list + sqlpsm_package_specification_element + ; ...
Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org
Hello Sergei, Thanks for your review. I have unified the grammar and removed the second copy of the entire "create_routine:" rule and its complex subrules. Please find a new patch version here: https://github.com/MariaDB/server/commit/28deba0a6119c64020970e48b0994804d88... In order to unify, I had to add about 20 "proxy" rules which are defined differently for sql_mode=DEFAULT and sql_mode=ORACLE. But all these proxy rules are very simple, mostly one liners. The cool thing is that the *complex* rules now have only one copy. Pasting two examples from the simple proxy rules: sp_tail_is: /*empty*/ { } ; sp_tail_is: IS | AS ; sp_parameters: sp_parenthesized_pdparam_list ; sp_parameters: opt_sp_parenthesized_pdparam_list ; On 9/15/23 6:03 PM, Sergei Golubchik wrote:
Hi, Alexander,
On Sep 15, Alexander Barkov wrote:
revision-id: 025ca90e5df (mariadb-11.0.1-231-g025ca90e5df) parent(s): 8ad1e26b1ba author: Alexander Barkov committer: Alexander Barkov timestamp: 2023-09-05 17:33:27 +0400 message:
MDEV-32101 CREATE PACKAGE [BODY] for sql_mode=DEFAULT
This patch adds PACKAGE support with SQL/PSM dialect for sql_mode=DEFAULT:
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 7452f6a083a..22c60bd4277 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -18454,6 +18518,22 @@ drop_routine: if (Lex->stmt_drop_procedure($3, $4)) MYSQL_YYABORT; } + | DROP PACKAGE_MARIADB_SYM opt_if_exists sp_name + { + LEX *lex= Lex; + lex->set_command(SQLCOM_DROP_PACKAGE, $3); + if (unlikely(lex->sphead)) + my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PACKAGE")); + lex->spname= $4; + } + | DROP PACKAGE_MARIADB_SYM BODY_MARIADB_SYM opt_if_exists sp_name + { + LEX *lex= Lex; + lex->set_command(SQLCOM_DROP_PACKAGE_BODY, $4); + if (unlikely(lex->sphead)) + my_yyabort_error((ER_SP_NO_DROP_SP, MYF(0), "PACKAGE BODY")); + lex->spname= $5; + } ;
at least here and in SHOW you can use
package: PACKAGE_MARIADB_SYM | PACKAGE_ORACLE_SYM ;
and then move drop_routine out of ifdef
@@ -18498,6 +18578,248 @@ create_routine: (Item_result) $8, $10)) MYSQL_YYABORT; } + + | create_or_replace definer_opt PACKAGE_MARIADB_SYM + opt_if_not_exists sp_name opt_create_package_chistics_init + remember_name + { + sp_package *pkg; + if (unlikely(!(pkg= Lex-> + create_package_start(thd, + SQLCOM_CREATE_PACKAGE, + &sp_handler_package_spec, + $5, $1 | $4)))) + MYSQL_YYABORT; + pkg->set_c_chistics(Lex->sp_chistics); + } + opt_sqlpsm_package_specification_element_list END + remember_end_opt + { + if (unlikely(Lex->create_package_finalize(thd, $5, NULL, $7, $11))) + MYSQL_YYABORT; + } + | create_or_replace definer_opt PACKAGE_MARIADB_SYM BODY_MARIADB_SYM + opt_if_not_exists sp_name opt_create_package_chistics_init + remember_name + { + sp_package *pkg; + if (unlikely(!(pkg= Lex-> + create_package_start(thd, + SQLCOM_CREATE_PACKAGE_BODY, + &sp_handler_package_body, + $6, $1 | $5)))) + MYSQL_YYABORT; + pkg->set_c_chistics(Lex->sp_chistics); + Lex->sp_block_init(thd); + } + sqlpsm_package_implementation_declare_section + { + if (unlikely(Lex->sp_block_with_exceptions_finalize_declarations(thd))) + MYSQL_YYABORT; + } + sqlpsm_package_implementation_executable_section + { + $10.hndlrs+= $12.hndlrs; + if (unlikely(Lex->sp_block_finalize(thd, $10))) + MYSQL_YYABORT; + } + remember_end_opt + { + if (unlikely(Lex->create_package_finalize(thd, $6, NULL, $8, $14))) + MYSQL_YYABORT; + }
this can also use `package` rule as above and be moved outside of %ifdef.
you'll only need
%ifdef MARIADB sp_tail_is: _empty ; opt_sp_name: _empty { $$= NULL; } ; %else sp_tail_is: IS | AS ; opt_sp_name: _empty { $$= NULL; } | sp_name { $$= $1; } ; %endif
+ ; + + +opt_sqlpsm_package_specification_element_list: + _empty + | sqlpsm_package_specification_element_list + ;
and so on, this can be called simply opt_package_specification_element_list if placed under %ifdef MARIADB
+ +sqlpsm_package_specification_element_list: + sqlpsm_package_specification_element + | sqlpsm_package_specification_element_list + sqlpsm_package_specification_element + ; ...
Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org
participants (2)
-
Alexander Barkov
-
Sergei Golubchik