*: Support the statement of "create table ... like" (#2707)

This commit is contained in:
Lynn
2017-02-22 23:57:04 +08:00
committed by Ewan Chou
parent f7c95f3f42
commit 61868f44dc
9 changed files with 130 additions and 3 deletions

View File

@ -146,7 +146,13 @@ func (e *DDLExec) executeCreateDatabase(s *ast.CreateDatabaseStmt) error {
func (e *DDLExec) executeCreateTable(s *ast.CreateTableStmt) error {
ident := ast.Ident{Schema: s.Table.Schema, Name: s.Table.Name}
err := sessionctx.GetDomain(e.ctx).DDL().CreateTable(e.ctx, ident, s.Cols, s.Constraints, s.Options)
var err error
if s.ReferTable == nil {
err = sessionctx.GetDomain(e.ctx).DDL().CreateTable(e.ctx, ident, s.Cols, s.Constraints, s.Options)
} else {
referIdent := ast.Ident{Schema: s.ReferTable.Schema, Name: s.ReferTable.Name}
err = sessionctx.GetDomain(e.ctx).DDL().CreateTableWithLike(e.ctx, ident, referIdent)
}
if terror.ErrorEqual(err, infoschema.ErrTableExists) {
if s.IfNotExists {
return nil