Skip to content

Commit 5ef622d

Browse files
committed
add alter column ast
1 parent 1b9f4a3 commit 5ef622d

File tree

4 files changed

+440
-98
lines changed

4 files changed

+440
-98
lines changed

ast/base.go

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,51 @@ type Collation struct {
1313
Name *element.Identifier
1414
}
1515

16-
type SortProp bool
16+
type ColumnProp int
1717

1818
const (
19-
InvisiblePropInvisible = iota
20-
InvisiblePropVisible
19+
ColumnPropEmpty ColumnProp = iota
20+
ColumnPropSort // for add column
21+
ColumnPropInvisible
22+
ColumnPropVisible
23+
ColumnPropSubstitutable // for modify column
24+
ColumnPropNotSubstitutable // for modify column
25+
ColumnPropSubstitutableForce // for modify column
26+
ColumnPropNotSubstitutableForce // for modify column
2127
)
2228

23-
type InvisibleProp struct {
24-
Type int
29+
type ColumnDefault struct {
30+
OnNull bool
31+
Value interface{}
32+
}
33+
34+
type ConstraintType int
35+
36+
const (
37+
ConstraintTypeNull ConstraintType = iota
38+
ConstraintTypeNotNull
39+
ConstraintTypeUnique
40+
ConstraintTypePK
41+
ConstraintTypeReferences
42+
)
43+
44+
type ConstraintState int
45+
46+
const (
47+
ConstraintStateDeferrable ConstraintState = iota
48+
ConstraintStateNotDeferrable
49+
ConstraintStateInitiallyDeferred
50+
ConstraintStateInitiallyImmediate
51+
ConstraintStateRely
52+
ConstraintStateNorely
53+
)
54+
55+
type InlineConstraint struct {
56+
Name *element.Identifier
57+
Type ConstraintState
58+
States []ConstraintState
59+
}
60+
61+
type InlineReferences struct {
62+
Scope TableName
2563
}

ast/ddl.go

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,54 @@ type columnClause struct{}
1818

1919
func (c *columnClause) IsColumnClause() {}
2020

21+
type ColumnDef struct {
22+
ColumnName *element.Identifier
23+
Datatype element.Datatype
24+
Collation *Collation
25+
Props []ColumnProp
26+
Default *ColumnDefault
27+
}
28+
2129
type AddColumnClause struct {
2230
columnClause
2331
Columns []*ColumnDef
2432
}
2533

26-
type ColumnDef struct {
27-
ColumnName *element.Identifier
28-
Datatype element.Datatype
29-
Collation *Collation
30-
Sort SortProp
31-
InvisibleProp *InvisibleProp
32-
}
33-
3434
type ModifyColumnClause struct {
3535
columnClause
36+
Columns []*ColumnDef
3637
}
3738

39+
type DropColumnType int
40+
41+
const (
42+
DropColumnTypeDrop DropColumnType = iota
43+
DropColumnTypeSetUnused
44+
DropColumnTypeDropUnusedColumns
45+
DropColumnTypeDropColumnsContinue
46+
)
47+
48+
type DropColumnProp int
49+
50+
const (
51+
DropColumnPropEmpty DropColumnProp = iota
52+
DropColumnPropCascade
53+
DropColumnPropInvalidate
54+
DropColumnPropOnline
55+
)
56+
3857
type DropColumnClause struct {
3958
columnClause
59+
Type DropColumnType
60+
Columns []*element.Identifier
61+
Props []DropColumnProp
62+
CheckPoint *int
4063
}
4164

4265
type RenameColumnClause struct {
4366
columnClause
67+
OldName *element.Identifier
68+
NewName *element.Identifier
4469
}
4570

4671
type CreateTableStmt struct {

0 commit comments

Comments
 (0)