Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ public boolean checkBinlogConfigChange(List<AlterOp> alterOps) {
).anyMatch(clause -> clause.getProperties().containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_ENABLE)
|| clause.getProperties().containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_TTL_SECONDS)
|| clause.getProperties().containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_MAX_BYTES)
|| clause.getProperties().containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_MAX_HISTORY_NUMS));
|| clause.getProperties().containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_MAX_HISTORY_NUMS)
|| clause.getProperties().containsKey(PropertyAnalyzer.PROPERTIES_BINLOG_FORMAT));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

binlog.need_historical_value seems to have the same routing gap as binlog.format. ModifyTablePropertiesOp.validate() treats it as a binlog property, and BinlogConfig.mergeFromProperties(..., false) explicitly rejects changing it, but checkBinlogConfigChange() still routes it through the generic schema-change path. Could we include PROPERTIES_BINLOG_NEED_HISTORICAL_VALUE here and add the parallel test?

}

public boolean isBeingSynced(List<AlterOp> alterOps) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package org.apache.doris.alter;

import org.apache.doris.common.util.PropertyAnalyzer;
import org.apache.doris.nereids.trees.plans.commands.info.AlterOp;
import org.apache.doris.nereids.trees.plans.commands.info.ModifyTablePropertiesOp;

import org.junit.Assert;
import org.junit.Test;

import java.util.Collections;
import java.util.List;
import java.util.Map;

public class AlterOperationsTest {

@Test
public void testBinlogFormatUsesBinlogConfigChangePath() {
Map<String, String> properties = Collections.singletonMap(
PropertyAnalyzer.PROPERTIES_BINLOG_FORMAT, "STATEMENT_AND_SNAPSHOT");
List<AlterOp> alterOps = Collections.singletonList(new ModifyTablePropertiesOp(properties));

Assert.assertTrue(new AlterOperations().checkBinlogConfigChange(alterOps));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.info.ColumnPosition;
import org.apache.doris.catalog.info.IndexType;
import org.apache.doris.common.Config;
import org.apache.doris.common.FeConstants;
import org.apache.doris.common.jmockit.Deencapsulation;
import org.apache.doris.nereids.StatementContext;
Expand Down Expand Up @@ -165,6 +166,24 @@ private void expectException(String alterStmt, String expectedErrorMsg) {
}
}

@Test
public void testChangeBinlogFormatReportsBinlogError() throws Exception {
boolean originalEnableFeatureBinlog = Config.enable_feature_binlog;
try {
Config.enable_feature_binlog = true;
String tableName = "binlog_format_change";
createTable("CREATE TABLE test." + tableName + " (k1 INT NOT NULL) "
+ "DUPLICATE KEY(k1) DISTRIBUTED BY HASH(k1) BUCKETS 1 "
+ "PROPERTIES('replication_num'='1','binlog.enable'='true','binlog.format'='ROW')");

expectException("ALTER TABLE test." + tableName
+ " SET ('binlog.format'='STATEMENT_AND_SNAPSHOT')",
"not support change binlog format from ROW to STATEMENT_AND_SNAPSHOT");
} finally {
Config.enable_feature_binlog = originalEnableFeatureBinlog;
}
}

@Test
public void testWithRowBinlogSchemaChangeNoHistoricalValue() throws Exception {
String tableName = "binlog_no_hist";
Expand Down
Loading