Repository navigation
fix: report ALTER TABLE actions that delete rows as MODIFIES_DATA - #2894
Open
tanjiroK-coder wants to merge 1 commit into
Open
tanjiroK-coder wants to merge 1 commit into
tanjiroK-coder wants to merge 1 commit into
Conversation
StatementFeatureVisitor classified every ALTER TABLE as schema-only, so TRUNCATE PARTITION, DROP PARTITION, EXCHANGE PARTITION and DISCARD or IMPORT TABLESPACE passed a guard checking mayModifyData(), which is the guard TRUNCATE and DROP carry MODIFIES_DATA for. They now report it as certain, REPAIR PARTITION as possible like REPAIR TABLE, and an action the grammar keeps as raw tokens (e.g. ClickHouse ALTER TABLE t DELETE WHERE ..) as possible with the "unsupported" marker.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ALTER TABLE t TRUNCATE PARTITION ALLpasses themayModifyData()read-only guardStatementFeatureVisitor.visit(Alter)returned schema-only for everyALTER TABLE, whatever its actions.TRUNCATEandDROPcarryMODIFIES_DATAso that the guard in the docs,if (connection.isReadOnly() && features.mayModifyData()), still stops them (seedestructiveDdlAlsoModifiesData), but theALTER TABLEactions that destroy rows did not:ALTER TABLE t TRUNCATE PARTITION ALLempties a partitioned MySQL table and reportedcertain=[MODIFIES_SCHEMA], and so didDROP PARTITION,EXCHANGE PARTITION(it swaps the rows of the partition and the other table) andDISCARD/IMPORT TABLESPACE(they delete or replace the table's data file). An action the grammar does not model is kept as raw tokens underAlterOperation.UNSPECIFIC, so ClickHouse'sALTER TABLE t DELETE WHERE 1 = 1andALTER TABLE t UPDATE c = 0 WHERE 1 = 1also gavemayModifyData() == false.Those partition and tablespace actions now report
MODIFIES_DATAas certain,REPAIR PARTITIONreports it as possible likeREPAIR TABLEdoes, and an unmodelled action reports it as possible with theunsupportedmarker, the way anUnsupportedStatementor aCREATE FUNCTIONbody is treated. Of the 571ALTER TABLEliterals in the test suite, 17 now reportMODIFIES_DATAas certain, 39 as possible (35 of them unmodelled actions such as PostgreSQLOWNER TO,SET LOGGEDorENABLE TRIGGER, an over-report on statements that already modify the schema) and 515 are unchanged, sois(..)changes for those 17 only. The 12 newStatementFeatureVisitorTestcases fail before and pass after;./gradlew check(12439 tests) andmvn verify(12421 tests) pass.