diff options
author | Ting-Wei Lan <tingwei.lan@cobinhood.com> | 2019-03-13 17:10:09 +0800 |
---|---|---|
committer | Jhih-Ming Huang <jm.huang@cobinhood.com> | 2019-03-26 17:48:22 +0800 |
commit | eaa030080d25d4fa0d91fd35daa8892f75f4d51d (patch) | |
tree | 6fafc3c59fe1d80839bfb8f01eb662da2095468b /core | |
parent | b0f778b53e7dfaf908b4c2e3f4e06399ab6701c3 (diff) | |
download | dexon-eaa030080d25d4fa0d91fd35daa8892f75f4d51d.tar dexon-eaa030080d25d4fa0d91fd35daa8892f75f4d51d.tar.gz dexon-eaa030080d25d4fa0d91fd35daa8892f75f4d51d.tar.bz2 dexon-eaa030080d25d4fa0d91fd35daa8892f75f4d51d.tar.lz dexon-eaa030080d25d4fa0d91fd35daa8892f75f4d51d.tar.xz dexon-eaa030080d25d4fa0d91fd35daa8892f75f4d51d.tar.zst dexon-eaa030080d25d4fa0d91fd35daa8892f75f4d51d.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.
Diffstat (limited to 'core')
-rw-r--r-- | core/vm/sqlvm/schema/schema.go | 25 |
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{} } |