hello-stephen commented on code in PR #70220:
URL: https://github.com/apache/doris/pull/70220#discussion_r4703131997
##########
fe/fe-catalog/src/main/java/org/apache/doris/catalog/Column.java:
##########
@@ -356,6 +362,9 @@ public Column(String name, Type type, boolean isKey,
AggregateType aggregateType
this.isAutoInc = autoIncInitValue != -1;
this.autoIncInitValue = autoIncInitValue;
this.defaultValue = defaultValue;
+ if (defaultValueExprDef == null && defaultValue != null &&
defaultValue.indexOf('\\') >= 0) {
+ this.decodedDefaultBackslashes = true;
Review Comment:
[P1] Keep newly persisted defaults readable by older FEs
During a rolling upgrade, a new leader stores `DEFAULT 'a\\b'` (two source
backslashes, `sql_mode=''`) as `615C62` plus this flag. An older follower
ignores the flag and its `Column.getDefaultValueSql()` reparses those bytes as
`6108` (a backspace). This can silently persist wrong rows: `BEGIN; INSERT INTO
t(k) VALUES (1); COMMIT` selects `BatchInsertIntoTableCommand`, whose
`NoForward` path binds the omitted column locally through `BindSink`; the
leader receives transaction RPCs rather than replanning the SQL. The replay
tests exercise both representations only through the new reader. Preserve an
older-readable persisted representation, or gate incompatible default creation
until every FE supports it, and cover follower transaction planning across
versions.
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -4279,7 +4279,8 @@ public ColumnDefinition visitColumnDef(ColumnDefContext
ctx) {
defaultValue = Optional.of(new DefaultValue("-" +
ctx.DECIMAL_VALUE().getText()));
}
} else if (ctx.stringValue != null) {
- defaultValue = Optional.of(new
DefaultValue(toStringValue(ctx.stringValue.getText())));
+ defaultValue = Optional.of(new DefaultValue(
+
SqlLiteralUtils.parseStringLiteral(ctx.stringValue.getText())));
Review Comment:
[P2] Account for legacy default encoding during MODIFY COLUMN
Existing columns retain their pre-upgrade SQL-source default, while this
parser now produces decoded bytes. For an old `v VARCHAR(10) NULL DEFAULT
'a\\b'` (two source backslashes, `sql_mode=''`), repeating that clause in
`ALTER TABLE t MODIFY COLUMN v VARCHAR(20) NULL DEFAULT 'a\\b'` now fails with
`Can not change default value`: `ModifyColumnOp.validate()` calls
`Column.checkSchemaChangeAllowed()`, which compares the old `615C5C62` and new
`615C62` strings directly. Copying the DEFAULT clause from SHOW CREATE has the
same failure. Make the comparison aware of both representations and preserve
the legacy default when unchanged; the new replay tests exercise INSERT
planning but do not cover this schema-change path.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]