aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <tingwei.lan@cobinhood.com>2019-03-13 17:10:09 +0800
committerJhih-Ming Huang <jm.huang@cobinhood.com>2019-05-06 10:44:04 +0800
commit5ff5adc8cab2386c744bc69782cade71222b51b9 (patch)
tree2b3fb6b987410ff844ed6c9364e4f6f153f1ed5d
parent2c61a14511bb9d2f85b7c6621f5a177fdd241fc0 (diff)
downloaddexon-5ff5adc8cab2386c744bc69782cade71222b51b9.tar.gz
dexon-5ff5adc8cab2386c744bc69782cade71222b51b9.tar.zst
dexon-5ff5adc8cab2386c744bc69782cade71222b51b9.zip
core: vm: sqlvm: schema: reorder fields and enums
Reorder fields and enums according to the grammar file to make it easier to check whether all features supported by the grammar are implemented.
-rw-r--r--core/vm/sqlvm/schema/schema.go25
1 files changed, 19 insertions, 6 deletions
diff --git a/core/vm/sqlvm/schema/schema.go b/core/vm/sqlvm/schema/schema.go
index 993843105..638b85817 100644
--- a/core/vm/sqlvm/schema/schema.go
+++ b/core/vm/sqlvm/schema/schema.go
@@ -19,12 +19,25 @@ var (
// ColumnAttr defines bit flags for describing column attribute.
type ColumnAttr uint16
-// ColumnAttr enums.
const (
- ColumnAttrHasDefault ColumnAttr = 1 << iota
+ // ColumnAttrPrimaryKey is a no-op. Primary key constraints are converted
+ // to a unique index during contract creation.
+ ColumnAttrPrimaryKey ColumnAttr = 1 << iota
+ // ColumnAttrNotNull is a no-op. We have not supported NULL values so all
+ // columns are implicitly non-null.
ColumnAttrNotNull
- ColumnAttrHasSequence
+ // ColumnAttrUnique is a no-op. Unique constraints are converted to unique
+ // indices during contract creation.
+ ColumnAttrUnique
+ // ColumnAttrHasDefault indicates whether a column has a default value. The
+ // default value does not affect the starting value of AUTOINCREMENT.
+ ColumnAttrHasDefault
+ // ColumnAttrHasForeignKey indicates whether a column references a column
+ // on a different table.
ColumnAttrHasForeignKey
+ // ColumnAttrHasSequence indicates whether a column is declared with
+ // AUTOINCREMENT. It is only valid on integer fields.
+ ColumnAttrHasSequence
)
// TableRef defines the type for table index in Schema.
@@ -42,8 +55,8 @@ type SequenceRef uint8
// IndexAttr defines bit flags for describing index attribute.
type IndexAttr uint16
-// IndexAttr enums.
const (
+ // IndexAttrUnique indicates whether an index is unique.
IndexAttrUnique IndexAttr = 1 << iota
)
@@ -61,16 +74,16 @@ type Table struct {
type Index struct {
Name []byte
Attr IndexAttr
- Columns []ColumnRef
+ Columns []ColumnRef // Columns must be sorted in ascending order.
}
type column struct {
Name []byte
Type ast.DataType
Attr ColumnAttr
- Sequence SequenceRef
ForeignTable TableRef
ForeignColumn ColumnRef
+ Sequence SequenceRef
Rest interface{}
}