Skip to content

Commit

Permalink
[opt](binlog) Support modify comment binlog (apache#39783)
Browse files Browse the repository at this point in the history
Co-authored-by: walter <[email protected]>
  • Loading branch information
smallx and w41ter authored Oct 18, 2024
1 parent 3c7b799 commit 2468619
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.doris.persist.BatchModifyPartitionsInfo;
import org.apache.doris.persist.BinlogGcInfo;
import org.apache.doris.persist.DropPartitionInfo;
import org.apache.doris.persist.ModifyCommentOperationLog;
import org.apache.doris.persist.ModifyTablePropertyOperationLog;
import org.apache.doris.persist.ReplacePartitionOperationLog;
import org.apache.doris.persist.TableAddOrDropColumnsInfo;
Expand Down Expand Up @@ -331,6 +332,17 @@ public void addTableRename(TableInfo info, long commitSeq) {
addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false, info);
}

public void addModifyComment(ModifyCommentOperationLog info, long commitSeq) {
long dbId = info.getDbId();
List<Long> tableIds = Lists.newArrayList();
tableIds.add(info.getTblId());
long timestamp = -1;
TBinlogType type = TBinlogType.MODIFY_COMMENT;
String data = info.toJson();

addBinlog(dbId, tableIds, commitSeq, timestamp, type, data, false, info);
}

public void addColumnRename(TableRenameColumnInfo info, long commitSeq) {
long dbId = info.getDbId();
List<Long> tableIds = Lists.newArrayList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,9 @@ public void logSetTableStatus(SetTableStatusOperationLog log) {
}

public void logModifyComment(ModifyCommentOperationLog op) {
logEdit(OperationType.OP_MODIFY_COMMENT, op);
long logId = logEdit(OperationType.OP_MODIFY_COMMENT, op);
LOG.info("log modify comment, logId : {}, infos: {}", logId, op);
Env.getCurrentEnv().getBinlogManager().addModifyComment(op, logId);
}

public void logCreateSqlBlockRule(SqlBlockRule rule) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,8 @@ public static ModifyCommentOperationLog read(DataInput in) throws IOException {
String json = Text.readString(in);
return GsonUtils.GSON.fromJson(json, ModifyCommentOperationLog.class);
}

public String toJson() {
return GsonUtils.GSON.toJson(this);
}
}
1 change: 1 addition & 0 deletions gensrc/thrift/FrontendService.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,7 @@ enum TBinlogType {
TRUNCATE_TABLE = 13,
RENAME_TABLE = 14,
RENAME_COLUMN = 15,
MODIFY_COMMENT = 16,
}

struct TBinlog {
Expand Down

0 comments on commit 2468619

Please sign in to comment.