diff --git a/go/vt/vttablet/tabletserver/planbuilder/dml.go b/go/vt/vttablet/tabletserver/planbuilder/dml.go index c1cadcc4d73..5e67140fa72 100644 --- a/go/vt/vttablet/tabletserver/planbuilder/dml.go +++ b/go/vt/vttablet/tabletserver/planbuilder/dml.go @@ -323,13 +323,17 @@ func analyzeInsert(ins *sqlparser.Insert, tables map[string]*schema.Table) (plan } table, tableErr := plan.setTable(tableName, tables) - // In passthrough dml mode, allow the operation even if the - // table is unknown in the schema. - if PassthroughDMLs { + switch { + case tableErr == nil && table.Type == schema.Message: + // message inserts need to continue being strict, even in passthrough dml mode, + // because field defaults are set here + + case PassthroughDMLs: + // In passthrough dml mode, allow the operation even if the + // table is unknown in the schema. return plan, nil - } - if tableErr != nil { + case tableErr != nil: return nil, tableErr } diff --git a/go/vt/vttablet/tabletserver/planbuilder/testdata/exec_cases.txt b/go/vt/vttablet/tabletserver/planbuilder/testdata/exec_cases.txt index 9a60c082c79..b23e26fa529 100644 --- a/go/vt/vttablet/tabletserver/planbuilder/testdata/exec_cases.txt +++ b/go/vt/vttablet/tabletserver/planbuilder/testdata/exec_cases.txt @@ -974,6 +974,23 @@ options:PassthroughDMLs "PKValues": [[1], [2]] } +# message insert with time_scheduled specified with PassthroughDMLs +options:PassthroughDMLs +"insert into msg(time_scheduled, id, message) values(1, 2, 'aa')" +{ + "PlanID": "INSERT_MESSAGE", + "TableName": "msg", + "Permissions": [ + { + "TableName": "msg", + "Role": 1 + } + ], + "FullQuery": "insert into msg(time_scheduled, id, message) values (1, 2, 'aa')", + "OuterQuery": "insert into msg(time_scheduled, id, message, time_next, time_created, epoch) values (1, 2, 'aa', 1, :#time_now, 0)", + "PKValues": [[1], [2]] +} + # message insert with no time_schedule "insert into msg(id, message) values(2, 'aa')" { @@ -990,6 +1007,23 @@ options:PassthroughDMLs "PKValues": [[":#time_now"], [2]] } +# message insert with no time_schedule with PassthroughDMLs +options:PassthroughDMLs +"insert into msg(id, message) values(2, 'aa')" +{ + "PlanID": "INSERT_MESSAGE", + "TableName": "msg", + "Permissions": [ + { + "TableName": "msg", + "Role": 1 + } + ], + "FullQuery": "insert into msg(id, message) values (2, 'aa')", + "OuterQuery": "insert into msg(id, message, time_scheduled, time_next, time_created, epoch) values (2, 'aa', :#time_now, :#time_now, :#time_now, 0)", + "PKValues": [[":#time_now"], [2]] +} + # message multi-value insert "insert into msg(time_scheduled, id, message) values(1, 2, 'aa'), (3, 4, 'bb')" {