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

implement single table inherits #929

Closed
wants to merge 4 commits into from
Closed
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
25 changes: 25 additions & 0 deletions server/ast/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,29 @@ func nodeCreateTable(node *tree.CreateTable) (*vitess.DDL, error) {
Select: selectStmt,
}
}
var optLike *vitess.OptLike
if len(node.Inherits) > 0 {
// TODO: we should error here, but correctness test are silently passing
//if len(node.Defs) > 0 {
// return nil, fmt.Errorf("INHERITS with TableDefs is not yet supported")
//}
for i, table := range node.Inherits {
if i > 0 {
// TODO: we should error here, but correctness test are silently passing
//return nil, fmt.Errorf("Multiple INHERITS is not yet supported")
break
}
// TODO: until we can support multiple tables in LIKE statements, this will only run once
likeTable, err := nodeTableName(&table)
if err != nil {
return nil, err
}
optLike = &vitess.OptLike{
LikeTable: likeTable,
}
}
}

if node.WithNoData {
return nil, fmt.Errorf("WITH NO DATA is not yet supported")
}
Expand All @@ -73,10 +96,12 @@ func nodeCreateTable(node *tree.CreateTable) (*vitess.DDL, error) {
IfNotExists: node.IfNotExists,
Temporary: isTemporary,
OptSelect: optSelect,
OptLike: optLike,
}
if err = assignTableDefs(node.Defs, ddl); err != nil {
return nil, err
}

if node.PartitionBy != nil {
switch node.PartitionBy.Type {
case tree.PartitionByList:
Expand Down
Loading