diff --git a/go/vt/vttablet/endtoend/rpc_test.go b/go/vt/vttablet/endtoend/rpc_test.go index a186d444f8d..d0fb7db2893 100644 --- a/go/vt/vttablet/endtoend/rpc_test.go +++ b/go/vt/vttablet/endtoend/rpc_test.go @@ -169,6 +169,25 @@ func TestGetSchemaRPC(t *testing.T) { }, getSchemaQueryType: querypb.SchemaTableType_ALL, getSchemaTables: []string{"vitess_temp1", "vitess_temp3", "unknown_table", "vitess_view3", "vitess_view1", "unknown_view"}, + }, { + name: "Create some internal tables", + queries: []string{ + "create table _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410 (eid int);", + "create table vitess_temp1 (eid int);", + "create view vitess_view1 as select eid from vitess_a", + }, + deferQueries: []string{ + "drop table _vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410", + "drop table vitess_temp1", + "drop view vitess_view1", + }, + mapToExpect: map[string]string{ + "vitess_view1": "CREATE ALGORITHM=UNDEFINED DEFINER=`vt_dba`@`localhost` SQL SECURITY DEFINER VIEW `vitess_view1` AS select `vitess_a`.`eid` AS `eid` from `vitess_a`", + "vitess_temp1": "CREATE TABLE `vitess_temp1` (\n `eid` int DEFAULT NULL\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci", + // These shouldn't be part of the result, so we verify it is empty. + "_vt_HOLD_6ace8bcef73211ea87e9f875a4d24e90_20200915120410": "", + }, + getSchemaQueryType: querypb.SchemaTableType_ALL, }, } diff --git a/go/vt/vttablet/tabletserver/query_executor.go b/go/vt/vttablet/tabletserver/query_executor.go index b4e377e7d80..844ce753152 100644 --- a/go/vt/vttablet/tabletserver/query_executor.go +++ b/go/vt/vttablet/tabletserver/query_executor.go @@ -1182,7 +1182,12 @@ func (qre *QueryExecutor) executeGetSchemaQuery(query string, callback func(sche return qre.execStreamSQL(conn, false /* isTransaction */, query, func(result *sqltypes.Result) error { schemaDef := make(map[string]string) for _, row := range result.Rows { - schemaDef[row[0].ToString()] = row[1].ToString() + tableName := row[0].ToString() + // Schema RPC should ignore the internal table in the response. + if schema.IsInternalOperationTableName(tableName) { + continue + } + schemaDef[tableName] = row[1].ToString() } return callback(&querypb.GetSchemaResponse{TableDefinition: schemaDef}) })