Skip to content

Bug Report: vtexplain with sequence does not work when the vitess_sequence is used with uppercase COMMENT #14941

Description

@aquarapid

Overview of the Issue

If you have a sequence definition like:

CREATE TABLE t1_seq (
        id bigint unsigned NOT NULL,
        next_id bigint unsigned,
        cache bigint unsigned,
        PRIMARY KEY (id)
) COMMENT 'vitess_sequence';

and the associated vschema to use it, when you try and plan an INSERT query using the sequence via vtexplain, you will get an error like:

target: unsharded.-.primary: t1_seq is not a sequence

Scratched my head about this for a bit, but if you look at the code for checking the sequence comment, the problem becomes clearer:

https://github.com/vitessio/vitess/blob/release-18.0/go/vt/vtexplain/vtexplain_vttablet.go#L426

We check for comment (lowercase); and the option.Name values are not normalized. The problem is therefore the capitalization. Using the following sequence definition therefore works:

CREATE TABLE t1_seq (
        id bigint unsigned NOT NULL,
        next_id bigint unsigned,
        cache bigint unsigned,
        PRIMARY KEY (id)
) comment 'vitess_sequence';

Reproduction Steps

See above.

Binary Version

release-18.0 main branch;  but this affects all Vitess versions since the support was merged from https://github.com/vitessio/vitess/pull/7186

Operating System and Environment details

Linux x86_64

Log Fragments

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions