ALTER SHARDING KEY GENERATE STRATEGY checks the strategy name instead of the generated key generator name for duplicates

Author: thswlsqlsCreated Sep 29, 2026Updated Sep 29, 2026

Bug Report

Which version of ShardingSphere did you use?

master @ 5cc2dff1000

Which project did you use? ShardingSphere-JDBC or ShardingSphere-Proxy?

Both (DistSQL, mainly Proxy)

Expected behavior

When ALTER with TYPE(...) generates the key generator <strategy>_<type>, the duplicate check uses that generated name, as CREATE does.

Actual behavior

  • ALTER is rejected when an unrelated generator is named like the strategy, although nothing conflicts.
  • ALTER is accepted when the generated name belongs to a generator used by another strategy, which is then silently overwritten.

Reason analyze (If you can)

AlterShardingKeyGenerateStrategyExecutor.checkDuplicateGeneratedKeyGenerator() computes keyGeneratorName but checks and reports sqlStatement.getName() (the strategy name). The CREATE executor checks the generated name.

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

  1. CREATE SHARDING KEY GENERATOR uuid_generator (TYPE(NAME='uuid'))
  2. CREATE SHARDING KEY GENERATE STRATEGY order_strategy (TABLE=t_order, COLUMN=order_id, GENERATOR=uuid_generator)
  3. CREATE SHARDING KEY GENERATOR order_strategy (TYPE(NAME='uuid'))
  4. ALTER SHARDING KEY GENERATE STRATEGY order_strategy (TABLE=t_order, COLUMN=order_id, TYPE(NAME='snowflake')) fails with a duplicate error for order_strategy.

Example codes for reproduce this issue (such as a github link).

N/A