Bug #109022 Contribution by Tencent: BISON_TARGET should use full path as <YaccInput>
Submitted: 8 Nov 2022 2:57 Modified: 22 Nov 2022 20:55
Reporter: Xiaodong Huang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S6 (Debug Builds)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: CMakeLists.txt

[8 Nov 2022 2:57] Xiaodong Huang
Description:
In sql/CMakeLists.txt, the following command BISON_TARGET is used to generated yacc files(sql_yacc.cc and sql_yacc.h). 

BISON_TARGET(mysql_parser
  sql_yacc.yy
  ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
  COMPILE_FLAGS
  "--name-prefix=MYSQL --yacc ${BISON_FLAGS_WARNINGS} ${BISON_NO_LINE_OPT}"
  DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
  )

Because the second parameter <YaccInput> of BISON_TARGET use a relative path "sql_yacc.yy", the #line macro also use <YaccInput> as filename parameter in the sql_yacc.cc, for example: #line 2299 "sql_yacc.yy".It may result that gdb fail to  find sql_yacc.yy. As a result, the <YaccInput> should be "${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy" instead of "sql_yacc.yy".

How to repeat:
1. complie the source code;
2. gdb target mysqld and set a breakpoint at label "drop_table_stmt:" in sql_yacc.yy;
3. execute drop table statement, gdb stop at the yacc entry "MYSQLparse" function in sql/sql_class.cc but it should actually stop at "drop_table_stmt:";

Suggested fix:
As mentioned above.
[8 Nov 2022 5:23] MySQL Verification Team
Hello Xiaodong,

Thank you for the report and contribution.

regards,
Umesh
[22 Nov 2022 20:55] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Server 8.0.32 release, and here's the proposed changelog entry from the documentation team:

Now use full file paths for the Bison and Flex source files to help
simplify debugging and gcov reports.

Thank you for the bug report.