Skip to content

Commit

Permalink
Merge pull request #7186 from csquared/sequence-tables-in-vtexplain
Browse files Browse the repository at this point in the history
add sequence table support for vtexplain
  • Loading branch information
deepthi authored Dec 15, 2020
2 parents 7796dae + 01143aa commit e4b5f65
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/vt/vtexplain/vtexplain_vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,12 @@ func initTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options) error {
showTableRows := make([][]sqltypes.Value, 0, 4)
for _, ddl := range ddls {
table := ddl.GetTable().Name.String()
showTableRows = append(showTableRows, mysql.BaseShowTablesRow(table, false, ""))
options := ""
spec := ddl.GetTableSpec()
if spec != nil && strings.Contains(spec.Options, "vitess_sequence") {
options = "vitess_sequence"
}
showTableRows = append(showTableRows, mysql.BaseShowTablesRow(table, false, options))
}
schemaQueries[mysql.BaseShowTables] = &sqltypes.Result{
Fields: mysql.BaseShowTablesFields,
Expand Down
14 changes: 14 additions & 0 deletions go/vt/vtexplain/vtexplain_vttablet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import (
"encoding/json"
"testing"

"vitess.io/vitess/go/vt/vttablet/tabletserver/schema"

topodatapb "vitess.io/vitess/go/vt/proto/topodata"
)

Expand All @@ -43,6 +45,13 @@ create table t4 like t3;
create table t5 (like t2);
create table t1_seq(
id int,
next_id bigint,
cache bigint,
primary key(id)
) comment 'vitess_sequence';
create table test_partitioned (
id bigint,
date_create int,
Expand Down Expand Up @@ -114,6 +123,11 @@ create table test_partitioned (
if t5.HasPrimary() || len(t5.PKColumns) != 0 {
t.Errorf("expected !HasPrimary && t5.PKColumns == [] got %v", t5.PKColumns)
}

seq := tables["t1_seq"]
if seq.Type != schema.Sequence {
t.Errorf("expected t1_seq to be a sequence table but is type %v", seq.Type)
}
}

func TestErrParseSchema(t *testing.T) {
Expand Down

0 comments on commit e4b5f65

Please sign in to comment.