Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add sequence table support for vtexplain #7186

Merged
merged 1 commit into from
Dec 15, 2020
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
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