Skip to content

[Enhancement]: Add dynamic configuration for lower_case_table_names i… #239

@hnwyllmm

Description

@hnwyllmm

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

  1. 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)

  2. 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

  3. Support environment variable configuration: Added support for setting lower_case_table_names via the LOWER_CASE_TABLE_NAMES environment variable in main.cpp

  4. 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
image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions