From fd871a8e800e4a09279fc4bcc3c05f3d97f907bd Mon Sep 17 00:00:00 2001 From: James Cor Date: Thu, 7 Nov 2024 16:47:26 -0800 Subject: [PATCH] support multiple like tables --- go/vt/sqlparser/ast.go | 6 +++--- go/vt/sqlparser/sql.go | 2 +- go/vt/sqlparser/sql.y | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go/vt/sqlparser/ast.go b/go/vt/sqlparser/ast.go index 958719bbc92..3787ecb1aff 100644 --- a/go/vt/sqlparser/ast.go +++ b/go/vt/sqlparser/ast.go @@ -2679,19 +2679,19 @@ const ( // OptLike works for create table xxx like xxx type OptLike struct { - LikeTable TableName + 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 { diff --git a/go/vt/sqlparser/sql.go b/go/vt/sqlparser/sql.go index 2fb543cc12b..6f7e5f89792 100755 --- a/go/vt/sqlparser/sql.go +++ b/go/vt/sqlparser/sql.go @@ -13169,7 +13169,7 @@ yydefault: yyDollar = yyS[yypt-3 : yypt+1] //line sql.y:1194 { - yyDollar[1].val.(*DDL).OptLike = &OptLike{LikeTable: yyDollar[3].val.(TableName)} + yyDollar[1].val.(*DDL).OptLike = &OptLike{LikeTables: []TableName{yyDollar[3].val.(TableName)}} yyVAL.val = yyDollar[1].val.(*DDL) } case 123: diff --git a/go/vt/sqlparser/sql.y b/go/vt/sqlparser/sql.y index 3003526b13a..c37e38ba070 100644 --- a/go/vt/sqlparser/sql.y +++ b/go/vt/sqlparser/sql.y @@ -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