Skip to content

Commit

Permalink
Merge branch 'main' into zachmu/prepared
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmu committed Jan 10, 2024
2 parents 132bf6a + 4b296d3 commit 0ecd224
Show file tree
Hide file tree
Showing 5 changed files with 11,227 additions and 11,388 deletions.
42 changes: 15 additions & 27 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,11 @@ func (ts *TableSpec) Format(buf *TrackedBuffer) {
// AddColumn appends the given column to the list in the spec
func (ts *TableSpec) AddColumn(cd *ColumnDefinition) {
ts.Columns = append(ts.Columns, cd)

// Move any inline check constraints up from the column definition to the table spec
if cd.Type.Constraint != nil {
ts.Constraints = append(ts.Constraints, cd.Type.Constraint)
}
}

// AddIndex appends the given index to the list in the spec
Expand Down Expand Up @@ -2621,6 +2626,9 @@ type ColumnType struct {
// Foreign key specification
ForeignKeyDef *ForeignKeyDefinition

// Check constraint specification
Constraint *ConstraintDefinition

// Generated columns
GeneratedExpr Expr // The expression used to generate this column
Stored BoolVal // Default is Virtual (not stored)
Expand Down Expand Up @@ -2672,6 +2680,13 @@ func (ct *ColumnType) merge(other ColumnType) error {
ct.ForeignKeyDef = other.ForeignKeyDef
}

if other.Constraint != nil {
if ct.Constraint != nil {
return errors.New("cannot include more than one check constraint in a column definition")
}
ct.Constraint = other.Constraint
}

if other.Comment != nil {
if ct.Comment != nil {
return errors.New("cannot include more than one comment for a column definition")
Expand Down Expand Up @@ -4741,7 +4756,6 @@ func (*CollateExpr) iExpr() {}
func (*FuncExpr) iExpr() {}
func (*TimestampFuncExpr) iExpr() {}
func (*ExtractFuncExpr) iExpr() {}
func (*CurTimeFuncExpr) iExpr() {}
func (*CaseExpr) iExpr() {}
func (*ValuesFuncExpr) iExpr() {}
func (*ConvertExpr) iExpr() {}
Expand Down Expand Up @@ -5579,32 +5593,6 @@ func (node *TimestampFuncExpr) replace(from, to Expr) bool {
return false
}

// CurTimeFuncExpr represents the function and arguments for CURRENT DATE/TIME functions
// supported functions are documented in the grammar
type CurTimeFuncExpr struct {
Name ColIdent
Fsp Expr // fractional seconds precision, integer from 0 to 6
}

// Format formats the node.
func (node *CurTimeFuncExpr) Format(buf *TrackedBuffer) {
buf.Myprintf("%s(%v)", node.Name.String(), node.Fsp)
}

func (node *CurTimeFuncExpr) walkSubtree(visit Visit) error {
if node == nil {
return nil
}
return Walk(
visit,
node.Fsp,
)
}

func (node *CurTimeFuncExpr) replace(from, to Expr) bool {
return replaceExprs(from, to, &node.Fsp)
}

// CollateExpr represents dynamic collate operator.
type CollateExpr struct {
Expr Expr
Expand Down
Loading

0 comments on commit 0ecd224

Please sign in to comment.