Repository navigation
Represent ALTER ... MODIFY SETTING name = DEFAULT as a reset - #119475
Algunenano merged 11 commits into
Conversation
The parser keeps `name = DEFAULT` entries apart from the changes, and `AlterCommand::parse` stored them in `settings_resets` of a command whose type stayed `MODIFY_SETTING`. Every engine-side check is keyed on `RESET_SETTING`, or inspects only `settings_changes` for `MODIFY_SETTING`, so none of them saw the reset: `TimeSeries` let an immutable setting be dropped and the table became unwritable, `Memory` dropped a setting from the stored definition while the running table kept enforcing the old value, and `MergeTree` accepted a setting name that does not exist. Move the resets out of the `MODIFY_SETTING` command instead: a command that only resets becomes `RESET_SETTING`, and one that also changes settings is split into a `MODIFY_SETTING` and a `RESET_SETTING`. All the existing checks then apply unchanged. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [dcfbbf7] Summary: ❌
AI ReviewSummaryThis PR makes Findings
Tests
Final VerdictChanges requested. LLVM Coverage ReportMeasured on commit dcfbbf7.
Changed lines: Changed C/C++ lines covered: 96/97 (98.97%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units153 translation units recompiled, 1504 s compile time in total, 153 of them have a recent master baseline. |
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`MODIFY SETTING table_readonly = DEFAULT` now becomes a `RESET_SETTING` command, which the engine guard did not inspect, so the setting could be reset silently. Check `settings_resets` too, which also covers plain `RESET SETTING table_readonly`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ault-engine-guards
Moving a `MODIFY SETTING name = DEFAULT` onto a `RESET_SETTING` command lost the rebuild of the implicit minmax indices, which only the `MODIFY_SETTING` branch performed. Both branches now call one helper, seeded from the engine's config defaults so that a setting dropped from the definition falls back to the configured value rather than the compiled one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: Release-transition baseline: compared against the most recent available 26.9 masters at or before the trusted base-commit anchor because no 26.10 master baseline exists there. no significant changes detected. K_source=6 K_base=30 flagged=0/65 clickbench🟢 No significant changes tpch_adapted_1_official🟢 No significant changes Debug info
|
Both parsers (`ParserAlterCommandList` and `ASTAlterQuery::readJSON`) now turn the entry into a `RESET SETTING` command, splitting the command in two when it changes other settings as well, so engines see the command type they key their checks on. `AlterCommand::parse` keeps the check for a contradictory command and throws a `LOGICAL_ERROR` when a parser leaves the modify syntax behind. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
| removeImplicitStatistics(new_metadata.columns); | ||
| commands.apply(new_metadata, local_context, share_nested_offsets); | ||
| auto settings_defaults = getDefaultSettings(); | ||
| commands.apply(new_metadata, local_context, share_nested_offsets, settings_defaults.get()); |
There was a problem hiding this comment.
Threading settings_defaults into the main commands.apply() path fixes the final metadata, but the mutation-planning path still replays earlier non-mutating setting alters without it.
checkAlterEligibility() calls getMutationCommands() before this, and AlterCommand::tryConvertToMutationCommand() still does apply(metadata, ...) with a null settings_defaults. That means mixed ALTERs still plan against stale implicit-index state. For example,
ALTER TABLE t
MODIFY SETTING enable_block_number_column = DEFAULT,
DROP INDEX IF EXISTS auto_minmax_index__block_numberstill produces a DROP INDEX mutation (and can be rejected by allow_non_metadata_alters = 0) even though the real commands.apply() path has already removed that implicit index after the reset.
getMutationCommands() / tryConvertToMutationCommand() need the same defaults threading as the real apply path.
There was a problem hiding this comment.
🕵 The code observation is right, but the symptom does not reproduce: the DROP INDEX mutation here never depends on the replayed metadata.
getMutationStageDecision sets requires_mutation = true for DROP_INDEX unconditionally, and AlterCommands::prepare sets ignore only for a missing column, never for DROP INDEX IF EXISTS. So the mutation is planned whether or not the implicit index is still present in the metadata the planning replays:
CREATE TABLE di (a UInt64) ENGINE = MergeTree ORDER BY a;
ALTER TABLE di DROP INDEX IF EXISTS never_existed; -- one mutation, no settings command involvedThat produces one mutation both on this branch and on a pre-branch master binary. The same holds for the example above: (MODIFY SETTING enable_block_number_column = DEFAULT), (DROP INDEX IF EXISTS auto_minmax_index__block_number) plans the DROP INDEX mutation with and without settings_defaults threaded into getMutationCommands, and allow_non_metadata_alters = 0 rejects it in both cases, so the threading changes nothing observable.
I also went looking for a planning decision which does read the settings-derived metadata: getMutationStageDecision only inspects metadata.columns and the TTL definitions, and the metadata getMutationCommands replays into is a by-value copy used solely for planning, while the metadata that gets stored comes from the real commands.apply which is given the defaults. Since I could not construct a case where the missing defaults change an outcome, I am leaving the mutation-planning path untouched instead of adding threading this change does not need, the more so as it is meant to be backported.
There was a problem hiding this comment.
On a table created with SETTINGS add_minmax_index_for_numeric_columns = 1, ALTER TABLE ... MODIFY SETTING add_minmax_index_for_numeric_columns = DEFAULT, ADD INDEX auto_minmax_index__a a TYPE minmax GRANULARITY 1 should succeed after the reset removes the implicit auto_minmax_index__a, but planning still sees that index and rejects the later ADD INDEX as duplicate / reserved before execution. The same settings_defaults threading needs to reach the metadata replay in tryConvertToMutationCommand, and the regression test should combine a reset with a later command that inspects secondary_indices, not just DROP INDEX IF EXISTS.
add_minmax_index_for_numeric_columns cannot be modified as of today (and has never been)
…ault-engine-guards
Rewriting the entry in the parsers dropped the check for a setting which is both modified and reset in one command: resolving the aliases of a setting needs the storage settings, which a parser cannot reach, so the contradiction was split into two commands and silently accepted. The split goes back to `InterpreterAlterQuery`, which both query paths pass through, as the added test shows. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
An engine which maps a compatibility name of a setting onto its canonical one, such as the `s3queue_` prefix of `ObjectStorageQueue`, can have the change and the reset of one command land on the same setting. A single command applies its resets first, so the change wins; the split command has to keep that order. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
f16ef19
Backport #119475 to 26.9: Represent `ALTER ... MODIFY SETTING name = DEFAULT` as a reset
…NG name = DEFAULT` as a reset
Closes: #119132
Related: #118526
MODIFY SETTING name = DEFAULTresets the setting, but the reset was carried inside aMODIFY_SETTINGalter command. Every engine-side check is keyed onRESET_SETTING, or inspects onlysettings_changeswhen the type isMODIFY_SETTING, so none of them saw it:TimeSerieslet an immutable setting be dropped and the table became unwritable,Memorydropped a setting from the stored definition while the running table kept enforcing the old value, andMergeTreeaccepted a setting name that does not exist.The reset is now taken out of the
MODIFY_SETTINGcommand by the parsers, inParserAlterCommandListand inASTAlterQuery::readJSON: a command which only resets becomesRESET_SETTING, and one which also changes settings is split into aMODIFY_SETTINGand aRESET_SETTING. The same holds forMODIFY COLUMN ... MODIFY SETTING, and a= DEFAULTwritten in theSETTINGS (...)clause of a column declaration is no longer ignored. All the existing checks then apply unchanged, including ones added later, andAlterCommand::parsethrows aLOGICAL_ERRORwhen a command still carries the modify syntax of a reset, so a parser cannot skip the rewrite unnoticed.A command which modifies and resets the same setting keeps its error.
ALTER DATABASE ... MODIFY SETTING name = DEFAULTis rejected, because a database engine applies only the changes and has no reset. Resetting aMergeTreesetting rebuilds the metadata derived from the settings, such as the implicit minmax indices, which onlyMODIFY SETTINGdid before.ReplicatedMergeTreerejects a reset oftable_readonlythe same way it rejects setting it.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
ALTER TABLE ... MODIFY SETTING name = DEFAULTskipping the checks an engine makes on a setting reset:TimeSeriesallowed an immutable setting to be dropped, leaving the table unwritable,Memoryremoved a setting from the table definition while the table kept enforcing the old value, andMergeTreeaccepted a name which is not a setting.Workflow [PR]
Sync PR [sync-upstream/pr/119475]
Version info
26.10.1.388-master(included in26.10and later)26.9.2.3