Skip to content

Commit

Permalink
support multiple like tables (#375)
Browse files Browse the repository at this point in the history
jycor authored Nov 11, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 860772b commit a20a5ab
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
@@ -2679,19 +2679,20 @@ const (

// OptLike works for create table xxx like xxx
type OptLike struct {
LikeTable TableName
// MySQL only allows single table in LIKE clause, but Postgres allows multiple tables in their `INHERIT` clause
LikeTables []TableName
}

// Format formats the node.
func (node *OptLike) Format(buf *TrackedBuffer) {
buf.Myprintf("like %v", node.LikeTable)
buf.Myprintf("like %v", node.LikeTables[0])
}

func (node *OptLike) walkSubtree(visit Visit) error {
if node == nil {
return nil
}
return Walk(visit, node.LikeTable)
return Walk(visit, node.LikeTables[0])
}

type OptSelect struct {
2 changes: 1 addition & 1 deletion go/vt/sqlparser/sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/vt/sqlparser/sql.y
Original file line number Diff line number Diff line change
@@ -1192,7 +1192,7 @@ create_statement:
}
| create_table_prefix LIKE table_name
{
$1.(*DDL).OptLike = &OptLike{LikeTable: $3.(TableName)}
$1.(*DDL).OptLike = &OptLike{LikeTables: []TableName{$3.(TableName)}}
$$ = $1.(*DDL)
}
| CREATE key_type_opt INDEX sql_id using_opt ON table_name '(' index_column_list ')' index_option_list_opt

0 comments on commit a20a5ab

Please sign in to comment.