From ba0d231fbe274063a056e47d4e8c092adff0b5c0 Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Fri, 3 May 2019 10:10:19 +0800 Subject: code backup 27 --- core/vm/sqlvm/checker/checker.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'core') diff --git a/core/vm/sqlvm/checker/checker.go b/core/vm/sqlvm/checker/checker.go index f18f9bc3f..5a2832c50 100644 --- a/core/vm/sqlvm/checker/checker.go +++ b/core/vm/sqlvm/checker/checker.go @@ -722,22 +722,6 @@ func checkCreateIndexStmt(n *ast.CreateIndexStmtNode, s *schema.Schema, index := schema.Index{} index.Columns = columnRefs.columns - if len((*s)[td.Table].Indices) > schema.MaxIndexRef { - el.Append(errors.Error{ - Position: n.GetPosition(), - Length: n.GetLength(), - Category: errors.ErrorCategoryLimit, - Code: errors.ErrorCodeTooManyIndices, - Severity: errors.ErrorSeverityError, - Prefix: fn, - Message: fmt.Sprintf( - "cannot have more than %d indices in table %s", - schema.MaxIndexRef+1, - ast.QuoteIdentifier(tn)), - }, &hasError) - return - } - ir := schema.IndexRef(len((*s)[td.Table].Indices)) id := schema.IndexDescriptor{Table: td.Table, Index: ir} if n.Unique != nil { @@ -806,6 +790,21 @@ func checkCreateIndexStmt(n *ast.CreateIndexStmtNode, s *schema.Schema, if rename { (*s)[id.Table].Indices[id.Index].Name = n.Index.Name } else { + if len((*s)[td.Table].Indices) > schema.MaxIndexRef { + el.Append(errors.Error{ + Position: n.GetPosition(), + Length: n.GetLength(), + Category: errors.ErrorCategoryLimit, + Code: errors.ErrorCodeTooManyIndices, + Severity: errors.ErrorSeverityError, + Prefix: fn, + Message: fmt.Sprintf( + "cannot have more than %d indices in table %s", + schema.MaxIndexRef+1, + ast.QuoteIdentifier(tn)), + }, &hasError) + return + } index.Name = n.Index.Name (*s)[id.Table].Indices = append((*s)[id.Table].Indices, index) } -- cgit v1.2.3