[MDEV-21110] Unify turn_parser_debug_on() in sql_yacc.yy and sql_yacc_ora.yy Created: 2019-11-21  Updated: 2020-01-23  Resolved: 2019-11-21

Status: Closed
Project: MariaDB Server
Component/s: Parser
Fix Version/s: 10.5.0

Type: Task Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-12518 Unify sql_yacc.yy and sql_yacc_ora.yy Closed

 Description   

This code block presents only in sql_yacc.yy and does not present in sql_yacc_ora.yy:

#ifndef DBUG_OFF
void turn_parser_debug_on()
{
  /*
     MYSQLdebug is in sql/sql_yacc.cc, in bison generated code.
     Turning this option on is **VERY** verbose, and should be
     used when investigating a syntax error problem only.
 
     The syntax to run with bison traces is as follows :
     - Starting a server manually :
       mysqld --debug-dbug="d,parser_debug" ...
     - Running a test :
       mysql-test-run.pl --mysqld="--debug-dbug=d,parser_debug" ...
 
     The result will be in the process stderr (var/log/master.err)
   */
 
  extern int yydebug;
  yydebug= 1;
}
#endif

The above function is used in mysql_parse() in sql_parse.cc, like this:

  DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on(););

Note, currently this code enables parser debug output in the code generated from sql_yacc.yy, but does not enable debug output in sql_yacc_ora.yy.

Let's unify this code and put the following block in both sql_yacc.yy and sql_yacc_ora.yy:

#ifndef DBUG_OFF
#define __CONCAT_UNDERSCORED(x,y) x ## _ ## y
#define _CONCAT_UNDERSCORED(x,y) __CONCAT_UNDERSCORED(x,y)
void _CONCAT_UNDERSCORED(turn_parser_debug_on,yyparse)()

{ /* MYSQLdebug is in sql/sql_yacc.cc, in bison generated code. Turning this option on is **VERY** verbose, and should be used when investigating a syntax error problem only. The syntax to run with bison traces is as follows : - Starting a server manually : mysqld --debug-dbug="d,parser_debug" ... - Running a test : mysql-test-run.pl --mysqld="--debug-dbug=d,parser_debug" ... The result will be in the process stderr (var/log/master.err) */ extern int yydebug; yydebug= 1; }

#endif

So:

  • sql_yacc.yy provides the function turn_parser_debug_on_MYSQLparse()
  • sql_yacc_ora.yy provides the function turn_parser_debug_on_ORAparse()
  • The code in sql_yacc.yy and sql_yacc_ora.yy look exactly the same.

The corresponding code in sql_parse.cc will change to:

  DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on_MYSQLparse(););
  DBUG_EXECUTE_IF("parser_debug", turn_parser_debug_on_ORAparse(););


Generated at Thu Feb 08 09:04:40 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.