Repository navigation
fix: parse MySQL ADD PARTITION PARTITIONS and partition binlog modifiers - #2848
Merged
manticore-projects merged 1 commit intoOct 23, 2026
Conversation
ALTER TABLE t ADD PARTITION PARTITIONS n, which adds partitions to a
HASH or KEY partitioned table, parsed as an ADD COLUMN named PARTITION
with PARTITIONS and n as column options. NO_WRITE_TO_BINLOG and LOCAL
(MySQL's opt_no_write_to_binlog) failed on every partition operation
that accepts them, and MODIFY or ALTER PARTITION (...) was accepted and
rewritten to ADD PARTITION.
Parse ADD PARTITION [NO_WRITE_TO_BINLOG | LOCAL] {(definitions) |
PARTITIONS n} only after ADD, and accept the modifier on COALESCE,
REORGANIZE, ANALYZE, OPTIMIZE, REBUILD and REPAIR PARTITION. The name
list operations share one alternative. Before a comma, INTO or the end
of the statement, LOCAL remains a partition name as before.
AlterExpressionPartition keeps the ADD and COALESCE count in one
partitionCount, reuses TableMaintenanceStatement.Modifier, and renders
these operations itself. The COALESCE accessors delegate to the shared
count.
Signed-off-by: minleejae <mmj9808@gmail.com>
Contributor
|
Thank you! |
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 clients ADD PARTITION PARTITIONS 6, which adds partitions to a HASH or KEY partitioned table, parsed as an ADD COLUMN namedPARTITIONwithPARTITIONS 6as column options.NO_WRITE_TO_BINLOGandLOCALfailed on every partition operation that accepts them.MODIFY PARTITION (...)andALTER PARTITION (...)were accepted and rewritten toADD PARTITION.ADD PARTITION [NO_WRITE_TO_BINLOG | LOCAL] {(definitions) | PARTITIONS n}is now parsed only after ADD. The modifier is accepted on COALESCE, REORGANIZE, ANALYZE, OPTIMIZE, REBUILD and REPAIR PARTITION, following MySQL'sopt_no_write_to_binlog. The six name-list operations share one alternative. Before a comma, INTO or the end of the statement,localremains a partition name as before.AlterExpressionPartitionstores the ADD and COALESCE count in onepartitionCountand exposes the modifier throughgetModifier(), reusingTableMaintenanceStatement.Modifier. It renders these operations itself. The COALESCE accessors delegate to the shared count.Public method signatures are retained.
MODIFY PARTITION (...)andALTER PARTITION (...)no longer parse; MySQL rejects them too.Syntax reference: MySQL 8.4 Management of HASH and KEY Partitions, ALTER TABLE Partition Operations, and
opt_no_write_to_binlogin sql_yacc.yy.Validation:
MySQLAlterTablePartitionTestadds 12 round-trip statements and tests for the count and modifier AST,localas a name, the ADD-only branch and the COALESCE accessors. On master, 11 of those statements fail to parse,ADD PARTITION PARTITIONS 6becomes a column, andMODIFY PARTITION (...)becomes ADD PARTITION.check: 12,095 tests, 0 failures, 25 skipped; grammar ambiguity, formatting (Spotless ratchet againstupstream/master), Checkstyle, PMD, SpotBugs and JaCoCo pass.MODIFY PARTITION (...)is a syntax error on the server.