diff options
author | yenlin.lai <yenlin.lai@cobinhood.com> | 2019-02-25 16:16:31 +0800 |
---|---|---|
committer | yenlinlai <38415072+yenlinlai@users.noreply.github.com> | 2019-02-26 18:28:26 +0800 |
commit | 6aac168bc279c995867321abad3b76e120be15ed (patch) | |
tree | cdf5e8b62c5fa0ad12ae998adcd43aca43d9dd88 | |
parent | 67f6ecd4de40ee66acb6b2eb23df6cd645ff5852 (diff) | |
download | dexon-wasm-vm.tar.gz dexon-wasm-vm.tar.zst dexon-wasm-vm.zip |
core: sqlvm: schema: define type for table/column/index/sequence sizewasm-vm
The size of table in db and column/index/sequence in a table is bounded
by uint8. Define types for better readability.
-rw-r--r-- | core/vm/sqlvm/schema/schema.go | 20 | ||||
-rw-r--r-- | core/vm/sqlvm/schema/schema_test.go | 2 |
2 files changed, 17 insertions, 5 deletions
diff --git a/core/vm/sqlvm/schema/schema.go b/core/vm/sqlvm/schema/schema.go index 4529fd7d5..76c843387 100644 --- a/core/vm/sqlvm/schema/schema.go +++ b/core/vm/sqlvm/schema/schema.go @@ -27,6 +27,18 @@ const ( ColumnAttrHasForeignKey ) +// TableRef defines the type for table index in Schema. +type TableRef uint8 + +// ColumnRef defines the type for column index in Table.Columns. +type ColumnRef uint8 + +// IndexRef defines the type for array index of Column.Indices. +type IndexRef uint8 + +// SequenceRef defines the type for sequence index in Table. +type SequenceRef uint8 + // IndexAttr defines bit flags for describing index attribute. type IndexAttr uint16 @@ -49,16 +61,16 @@ type Table struct { type Index struct { Name []byte Attr IndexAttr - Columns []uint8 + Columns []ColumnRef } type column struct { Name []byte Type ast.DataType Attr ColumnAttr - Sequence uint8 - ForeignTable uint8 - ForeignColumn uint8 + Sequence SequenceRef + ForeignTable TableRef + ForeignColumn ColumnRef Rest interface{} } diff --git a/core/vm/sqlvm/schema/schema_test.go b/core/vm/sqlvm/schema/schema_test.go index 92bfa6c91..5d252ef85 100644 --- a/core/vm/sqlvm/schema/schema_test.go +++ b/core/vm/sqlvm/schema/schema_test.go @@ -82,7 +82,7 @@ func (s *SchemaTestSuite) TestEncodeAndDecodeSchema() { { Name: []byte("idx"), Attr: IndexAttrUnique, - Columns: []uint8{0}, + Columns: []ColumnRef{0}, }, }, }, |