Added planning tests for Alter Vschema

Signed-off-by: GuptaManan100 <manan@planetscale.com>
This commit is contained in:
GuptaManan100 2020-12-14 18:28:39 +05:30
Родитель 2d1b007cf2
Коммит e1a35c6860
3 изменённых файлов: 136 добавлений и 1 удалений

Просмотреть файл

@ -76,7 +76,7 @@ func ASTToStatementType(stmt Statement) StatementType {
return StmtSet
case *Show:
return StmtShow
case DDLStatement, DBDDLStatement:
case DDLStatement, DBDDLStatement, *AlterVschema:
return StmtDDL
case *Use:
return StmtUse

Просмотреть файл

@ -233,6 +233,7 @@ func TestWithDefaultKeyspaceFromFile(t *testing.T) {
tabletType: topodatapb.TabletType_MASTER,
}
testFile(t, "alterVschema_cases.txt", testOutputTempDir, vschema)
testFile(t, "ddl_cases.txt", testOutputTempDir, vschema)
testFile(t, "show_cases.txt", testOutputTempDir, vschema)
}

134
go/vt/vtgate/planbuilder/testdata/alterVschema_cases.txt поставляемый Normal file
Просмотреть файл

@ -0,0 +1,134 @@
# Create vindex
"alter vschema create vindex hash_vdx using hash"
{
"QueryType": "DDL",
"Original": "alter vschema create vindex hash_vdx using hash",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"query": "alter vschema create vindex hash_vdx using hash"
}
}
# Create vindex with qualifier
"alter vschema create vindex user.hash_vdx using hash"
{
"QueryType": "DDL",
"Original": "alter vschema create vindex user.hash_vdx using hash",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"query": "alter vschema create vindex user.hash_vdx using hash"
}
}
# Drop vindex
"alter vschema drop vindex hash_vdx"
{
"QueryType": "DDL",
"Original": "alter vschema drop vindex hash_vdx",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"query": "alter vschema drop vindex hash_vdx"
}
}
# Add table
"alter vschema add table a"
{
"QueryType": "DDL",
"Original": "alter vschema add table a",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"query": "alter vschema add table a"
}
}
# Add sequence
"alter vschema add sequence a_seq"
{
"QueryType": "DDL",
"Original": "alter vschema add sequence a_seq",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"query": "alter vschema add sequence a_seq"
}
}
# Add auto_increment with qualifier
"alter vschema on user.a add auto_increment id using a_seq"
{
"QueryType": "DDL",
"Original": "alter vschema on user.a add auto_increment id using a_seq",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "user",
"Sharded": true
},
"query": "alter vschema on user.a add auto_increment id using a_seq"
}
}
# Drop table
"alter vschema drop table a"
{
"QueryType": "DDL",
"Original": "alter vschema drop table a",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"query": "alter vschema drop table a"
}
}
# Add Vindex
"alter vschema on a add vindex hash (id)"
{
"QueryType": "DDL",
"Original": "alter vschema on a add vindex hash (id)",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"query": "alter vschema on a add vindex hash (id)"
}
}
# Drop Vindex
"alter vschema on a drop vindex hash"
{
"QueryType": "DDL",
"Original": "alter vschema on a drop vindex hash",
"Instructions": {
"OperatorType": "AlterVSchema",
"Keyspace": {
"Name": "main",
"Sharded": false
},
"query": "alter vschema on a drop vindex hash"
}
}