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
Allow adding sequence table to the vschema via ALTER VSCHEMA ADD SEQU… #5080
Allow adding sequence table to the vschema via ALTER VSCHEMA ADD SEQU… #5080
Conversation
go/vt/sqlparser/ast.go
Outdated
@@ -734,6 +734,9 @@ type DDL struct { | |||
OptLike *OptLike | |||
PartitionSpec *PartitionSpec | |||
|
|||
// IsVitessSequence is set for AddVschemaTableStr and refers to whether the table is a sequence table. | |||
IsVitessSequence bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just call it “IsSequence”. We know it’s Vitess. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can have SQL sequences as well. For instance MariaDB allows "CREATE SEQUENCE" (https://mariadb.com/kb/en/library/create-sequence/). Initially wanted to differentiate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I think we don't need to support MariaDB sequences. Wdyt @sougou ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we don't need a special bit for this -- you can just re-use the VindexSpec and make the vindex "type" equal to "sequence.
FYI @demmer if you have an opinion on syntax |
I'll take a look a this later, but here's an old document to use as reference: https://vitess.io/docs/reference/vitess-sequences/ |
Thanks @sougou I'll update PR to reflect the sequence document instead of going via "alter vschema" |
I think we need an For the future we could also add a
We won't ever be able to use such a statement though because the way we run DDL against our databases is completely different from how we insert data into them which is completely different from how we change the vschema. Because SOX. So we still need an |
3221b1e
to
fe4daac
Compare
go/vt/sqlparser/sql.y
Outdated
@@ -1325,6 +1326,10 @@ alter_statement: | |||
{ | |||
$$ = &DDL{Action: AddVschemaTableStr, Table: $5} | |||
} | |||
| ALTER VSCHEMA ADD SEQUENCE TABLE table_name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syntactically since we eventually want to support CREATE SEQUENCE
and not CREATE SEQUENCE TABLE
, I think this should be ALTER VSCHEMA ADD SEQUENCE table_name
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
…ENCE TABLE statement Signed-off-by: Karel Alfonso Sague <kalfonso@squareup.com>
fe4daac
to
77089db
Compare
Currently we can add a table to the vschema via "ALTER VSCHEMA", create a hash, lookup vindex, etc but there is no way to add a sequence table. A second PR will address referencing a sequence table from a sharded keyspace
Signed-off-by: Karel Alfonso Sague kalfonso@squareup.com