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
15 changes: 14 additions & 1 deletion go/test/endtoend/preparestmt/stmt_methods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"vitess.io/vitess/go/test/endtoend/cluster"
"vitess.io/vitess/go/vt/vtgate/engine"
)

Expand Down Expand Up @@ -564,13 +565,25 @@ func validateJoinSpecializedPlan(t *testing.T, p map[string]any) {

func validateBaselineErrSpecializedPlan(t *testing.T, p map[string]any) {
t.Helper()

vtgateVer, err := cluster.GetMajorVersion("vtgate")
require.NoError(t, err)

// v24+ uses the following error message due to the work in:
// https://github.com/vitessio/vitess/pull/18903
expectedErr := "VT12001: unsupported: window functions are only supported for single-shard queries"
if vtgateVer < 24 {
// v23 and earlier uses the old error which reflected the limitation before that work.
expectedErr = "VT12001: unsupported: OVER CLAUSE with sharded keyspace"
}

plan, exist := p["Instructions"]
require.True(t, exist, "plan Instructions not found")

pm, ok := plan.(map[string]any)
require.True(t, ok, "plan is not of type map[string]any")
require.EqualValues(t, "PlanSwitcher", pm["OperatorType"])
require.EqualValues(t, "VT12001: unsupported: OVER CLAUSE with sharded keyspace", pm["BaselineErr"])
require.EqualValues(t, expectedErr, pm["BaselineErr"])

pd, err := engine.PrimitiveDescriptionFromMap(plan.(map[string]any))
require.NoError(t, err)
Expand Down
7 changes: 7 additions & 0 deletions go/vt/vttablet/tabletmanager/vdiff/table_differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,13 @@ func (td *tableDiffer) getSourcePKCols() error {
return vterrors.Wrapf(err, "failed to get the schema for table %s from source tablet %s",
td.table.Name, topoproto.TabletAliasString(sourceTablet.Tablet.Alias))
}
if len(sourceSchema.TableDefinitions) == 0 {
// The table no longer exists on the source. Any rows that exist on the target will be
// reported as extra rows.
log.Warningf("The %s table was not found on source tablet %s during VDiff for the %s workflow; any rows on the target will be reported as extra",
td.table.Name, topoproto.TabletAliasString(sourceTablet.Tablet.Alias), td.wd.ct.workflow)
return nil
}
sourceTable := sourceSchema.TableDefinitions[0]
if len(sourceTable.PrimaryKeyColumns) == 0 {
// We use the columns from a PKE if there is one.
Expand Down
32 changes: 32 additions & 0 deletions go/vt/vttablet/tabletmanager/vdiff/table_differ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,35 @@ func TestUpdateTableProgress(t *testing.T) {
})
}
}

func TestGetSourcePKCols_TableDroppedOnSource(t *testing.T) {
tvde := newTestVDiffEnv(t)
defer tvde.close()

ct := tvde.createController(t, 1)

table := &tabletmanagerdatapb.TableDefinition{
Name: "dropped_table",
Columns: []string{"c1", "c2"},
PrimaryKeyColumns: []string{"c1"},
Fields: sqltypes.MakeTestFields("c1|c2", "int64|varchar"),
}

tvde.tmc.schema = &tabletmanagerdatapb.SchemaDefinition{
TableDefinitions: []*tabletmanagerdatapb.TableDefinition{},
}

td := &tableDiffer{
wd: &workflowDiffer{
ct: ct,
},
table: table,
tablePlan: &tablePlan{
table: table,
},
}

err := td.getSourcePKCols()
require.NoError(t, err)
require.Nil(t, td.tablePlan.sourcePkCols)
}
Loading