Bug #74520 Circular include dependency between sql_lex.h and sql_class.h
Submitted: 23 Oct 2014 7:43 Modified: 20 Nov 2014 16:31
Reporter: Martin Hansson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Parser Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[23 Oct 2014 7:43] Martin Hansson
Description:
This is an internal refactoring.

Problem: The header files sql_lex.h is not self-sufficient and requires sql_class.h to be included before it, always. Meanwhile, sql_class.h is including sql_lex.h in the middle of the file. The reason is a design flaw: sql_class.h is defining enums that are needed by the parser and InnoDB. These enums are

- enum Key::Keytype
- enum enum_ha_read_modes
- enum enum_filetype
- enum Foreign_key::fk_match_opt
- enum Foreign_key::fk_option

How to repeat:
Try to do #include "sql_lex.h"

Suggested fix:
The fix is to move the enums to sql_class.h and make the include dependency one-way: sql_class.h depends on sql_lex.h. This is consistent with the overall architecture of the server: the parser and storage engines are separate from the optimizer and should not need to know about it. But the optimizer needs to know about the structures that the parser produces.

The enums that are class members are moved out of their classes. This makes sense as they are used in both the parser and storage engines, neither of which need - or should - know about the structures that contain them.
[20 Nov 2014 16:31] Paul DuBois
Fixed in 5.7.6. Code cleanup. No changelog entry needed.