Skip to content
Merged
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
14 changes: 9 additions & 5 deletions go/vt/vttablet/tabletserver/planbuilder/dml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
34 changes: 34 additions & 0 deletions go/vt/vttablet/tabletserver/planbuilder/testdata/exec_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
{
Expand All @@ -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')"
{
Expand Down