Skip to content
Open
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
53 changes: 53 additions & 0 deletions go/vt/vtexplain/vtexplain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,59 @@ func TestExplain(t *testing.T) {
}
}

func TestExplainSequenceTableCommentCase(t *testing.T) {
const (
vSchema = `{
"commerce": {
"sharded": false,
"tables": {
"customer": {
"auto_increment": {
"column": "id",
"sequence": "commerce.customer_seq"
}
},
"customer_seq": {
"type": "sequence"
}
}
}
}`
schema = `create table customer (
id bigint not null,
email varchar(128),
primary key(id)
);
create table customer_seq (
id bigint not null,
next_id bigint,
cache bigint,
primary key(id)
) %s 'vitess_sequence';`
query = "insert into customer(email) values ('alice@example.com')"
)

for _, keyword := range []string{"comment", "COMMENT", "CoMmEnT"} {
t.Run(keyword, func(t *testing.T) {
ctx := utils.LeakCheckContext(t)
ts := memorytopo.NewServer(ctx, Cell)
opts := defaultTestOpts()
opts.ExecutionMode = ModeMulti
srvTopoCounts := stats.NewCountersWithSingleLabel("", "Resilient srvtopo server operations", "type")
vte, err := Init(ctx, vtenv.NewTestEnv(), ts, vSchema, fmt.Sprintf(schema, keyword), "", opts, srvTopoCounts)
require.NoError(t, err)
t.Cleanup(vte.Stop)

explains, err := vte.Run(query)
require.NoError(t, err)

explainText, err := vte.ExplainsAsText(explains)
require.NoError(t, err)
require.Contains(t, explainText, "select next_id, cache from customer_seq where id = 0 for update")
})
}
}

func TestErrors(t *testing.T) {
ctx := utils.LeakCheckContext(t)
ts := memorytopo.NewServer(ctx, Cell)
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vtexplain/vtexplain_vttablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ func newTabletEnvironment(ddls []sqlparser.DDLStatement, opts *Options, collatio
spec := ddl.GetTableSpec()
if spec != nil {
for _, option := range spec.Options {
if option.Name == "comment" && string(option.Value.Val) == "vitess_sequence" {
if strings.EqualFold(option.Name, "comment") && string(option.Value.Val) == "vitess_sequence" {
options = "vitess_sequence"
}
}
Expand Down
Loading