github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/testutils/testcat/create_sequence.go (about)

     1  // Copyright 2018 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  package testcat
    12  
    13  import "github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
    14  
    15  // CreateSequence creates a test sequence from a parsed DDL statement and adds it
    16  // the catalog. This is intended for testing, and is not a complete (and
    17  // probably not fully correct) implementation. It just has to be "good enough".
    18  func (tc *Catalog) CreateSequence(stmt *tree.CreateSequence) *Sequence {
    19  	tc.qualifyTableName(&stmt.Name)
    20  
    21  	seq := &Sequence{
    22  		SeqID:   tc.nextStableID(),
    23  		SeqName: stmt.Name,
    24  		Catalog: tc,
    25  	}
    26  
    27  	tc.AddSequence(seq)
    28  	return seq
    29  }