Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-21110

Unify turn_parser_debug_on() in sql_yacc.yy and sql_yacc_ora.yy

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Fix Version/s: 10.5.0
    • Component/s: Parser
    • Labels:
      None

      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(););
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              bar Alexander Barkov
              Reporter:
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: