Task Description
Fix hardcoded table names in SQL queries to support lower_case_table_names system variable. This resolves issues where system tables cannot be found when lower_case_table_names=0 (case-sensitive mode) is configured.
Related to case-sensitivity handling for MySQL compatibility.
Solution Description
-
Replace hardcoded table names with constants: Changed direct string literals like __all_server and __all_zone to use constants from ob_inner_table_schema_constants.h (e.g., OB_ALL_SERVER_TNAME, OB_ALL_ZONE_TNAME)
-
Read lower_case_table_names from system variables: Modified bootstrap and schema initialization code to dynamically read the lower_case_table_names setting instead of hardcoding OB_LOWERCASE_AND_INSENSITIVE
-
Support environment variable configuration: Added support for setting lower_case_table_names via the LOWER_CASE_TABLE_NAMES environment variable in main.cpp
-
Set proper name_case_mode for system tables: Ensured system tables always use case-sensitive mode (OB_ORIGIN_AND_SENSITIVE) regardless of tenant settings, while user tables respect the tenant's lower_case_table_names configuration
Modified files:
src/observer/main.cpp
src/rootserver/ob_bootstrap.cpp
src/share/ob_locality_table_operator.cpp
src/share/schema/ob_schema_mgr.cpp
src/share/schema/ob_schema_utils.cpp
src/share/schema/ob_server_schema_service.cpp
src/storage/tx/wrs/ob_tenant_weak_read_cluster_service.cpp
Passed Regressions
- Manually tested with
lower_case_table_names=0 configuration
- Verified system tables are accessible with case-sensitive mode
- Confirmed bootstrap process completes successfully
- Tested SQL queries against system tables work correctly
- After making the modifications, I rebuilt and mirrored the image for running. Then, I added an environment variable to the Docker configuration to pull up the container. After verifying the settings and querying the configuration, I found that the parameter was effective
Upgrade Compatibility
This change is backward compatible:
- Default behavior remains unchanged (defaults to
lower_case_table_names=1)
- Existing deployments will continue to work without modification
- New configuration option is opt-in via environment variable or command-line parameter
Other Information
This fix improves MySQL compatibility by properly supporting the lower_case_table_names system variable, which is important for:
- Cross-platform deployments (Linux/macOS/Windows)
- Migration from MySQL databases with case-sensitive table names
- Compliance with MySQL standard behavior
Release Note
Enhancement: Added proper support for lower_case_table_names system variable. System table names are now referenced using constants instead of hardcoded strings, enabling case-sensitive table name mode (lower_case_table_names=0) to work correctly. This improves MySQL compatibility and supports cross-platform deployments.
Task Description
Fix hardcoded table names in SQL queries to support
lower_case_table_namessystem variable. This resolves issues where system tables cannot be found whenlower_case_table_names=0(case-sensitive mode) is configured.Related to case-sensitivity handling for MySQL compatibility.
Solution Description
Replace hardcoded table names with constants: Changed direct string literals like
__all_serverand__all_zoneto use constants fromob_inner_table_schema_constants.h(e.g.,OB_ALL_SERVER_TNAME,OB_ALL_ZONE_TNAME)Read
lower_case_table_namesfrom system variables: Modified bootstrap and schema initialization code to dynamically read thelower_case_table_namessetting instead of hardcodingOB_LOWERCASE_AND_INSENSITIVESupport environment variable configuration: Added support for setting
lower_case_table_namesvia theLOWER_CASE_TABLE_NAMESenvironment variable inmain.cppSet proper
name_case_modefor system tables: Ensured system tables always use case-sensitive mode (OB_ORIGIN_AND_SENSITIVE) regardless of tenant settings, while user tables respect the tenant'slower_case_table_namesconfigurationModified files:
src/observer/main.cppsrc/rootserver/ob_bootstrap.cppsrc/share/ob_locality_table_operator.cppsrc/share/schema/ob_schema_mgr.cppsrc/share/schema/ob_schema_utils.cppsrc/share/schema/ob_server_schema_service.cppsrc/storage/tx/wrs/ob_tenant_weak_read_cluster_service.cppPassed Regressions
lower_case_table_names=0configurationUpgrade Compatibility
This change is backward compatible:
lower_case_table_names=1)Other Information
This fix improves MySQL compatibility by properly supporting the
lower_case_table_namessystem variable, which is important for:Release Note
Enhancement: Added proper support for
lower_case_table_namessystem variable. System table names are now referenced using constants instead of hardcoded strings, enabling case-sensitive table name mode (lower_case_table_names=0) to work correctly. This improves MySQL compatibility and supports cross-platform deployments.