aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/vm/sqlvm/checker/checker.go31
1 files changed, 15 insertions, 16 deletions
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)
}