Skip to content

Commit

Permalink
Adding sf_return_type, improving sf_tail readability.
Browse files Browse the repository at this point in the history
1. The "sf_tail" rule had a lot of rules with part markers, e.g:

     /* $1 */

They make the grammar really hard to read.
Removing all these markers.

2. Moving the RETURNS clause into a separate sp_return_type rule,
to make sf_tail even more simpler. Note, sp_return_type will be needed
soon for packages anyway.
  • Loading branch information
Alexander Barkov committed Jul 3, 2017
1 parent 306bc90 commit 760127a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 36 deletions.
41 changes: 23 additions & 18 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -16640,36 +16640,41 @@ udf_tail:
}
;

sf_tail:
opt_if_not_exists /* $1 */
sp_name /* $2 */
{ /* $3 */
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
TYPE_ENUM_FUNCTION))
MYSQL_YYABORT;
Lex->spname= $2;
}
sp_parenthesized_fdparam_list /* $4 */
RETURNS_SYM /* $5 */
{ /* $6 */

sf_return_type:
RETURNS_SYM
{
LEX *lex= Lex;
lex->init_last_field(&lex->sphead->m_return_field_def,
&empty_clex_str,
&empty_clex_str,
thd->variables.collation_database);
}
type_with_opt_collate /* $7 */
{ /* $8 */
type_with_opt_collate
{
if (Lex->sphead->fill_field_definition(thd, Lex->last_field))
MYSQL_YYABORT;
}
sp_c_chistics /* $9 */
{ /* $10 */
;

sf_tail:
opt_if_not_exists
sp_name
{
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
TYPE_ENUM_FUNCTION))
MYSQL_YYABORT;
Lex->spname= $2;
}
sp_parenthesized_fdparam_list
sf_return_type
sp_c_chistics
{
LEX *lex= thd->lex;
Lex_input_stream *lip= YYLIP;

lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
}
sp_proc_stmt_in_returns_clause /* $11 */
sp_proc_stmt_in_returns_clause
{
LEX *lex= thd->lex;
sp_head *sp= lex->sphead;
Expand Down
41 changes: 23 additions & 18 deletions sql/sql_yacc_ora.yy
Original file line number Diff line number Diff line change
Expand Up @@ -16878,37 +16878,42 @@ udf_tail:
}
;

sf_tail:
opt_if_not_exists /* $1 */
sp_name /* $2 */
{ /* $3 */
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
TYPE_ENUM_FUNCTION))
MYSQL_YYABORT;
Lex->spname= $2;
}
opt_sp_parenthesized_fdparam_list /* $4 */
RETURN_SYM /* $5 */
{ /* $6 */

sf_return_type:
RETURN_SYM
{
LEX *lex= Lex;
lex->init_last_field(&lex->sphead->m_return_field_def,
&empty_clex_str,
thd->variables.collation_database);
}
sp_param_type_with_opt_collate /* $7 */
{ /* $8 */
sp_param_type_with_opt_collate
{
if (Lex->sphead->fill_field_definition(thd, Lex->last_field))
MYSQL_YYABORT;
}
sp_c_chistics /* $9 */
{ /* $10 */
;

sf_tail:
opt_if_not_exists
sp_name
{
if (!Lex->make_sp_head_no_recursive(thd, $1, $2,
TYPE_ENUM_FUNCTION))
MYSQL_YYABORT;
Lex->spname= $2;
}
opt_sp_parenthesized_fdparam_list
sf_return_type
sp_c_chistics
{
LEX *lex= thd->lex;
Lex_input_stream *lip= YYLIP;

lex->sphead->set_body_start(thd, lip->get_cpp_tok_start());
}
sp_tail_is /* $11 */
sp_body /* $12 */
sp_tail_is
sp_body
{
LEX *lex= thd->lex;
sp_head *sp= lex->sphead;
Expand Down

0 comments on commit 760127a

Please sign in to comment.