github.com/matrixorigin/matrixone@v0.7.0/pkg/vm/engine/tae/catalog/model.go (about) 1 // Copyright 2021 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package catalog 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/catalog" 19 "github.com/matrixorigin/matrixone/pkg/container/types" 20 ) 21 22 var ( 23 PhyAddrColumnType types.Type 24 ) 25 26 const ( 27 PhyAddrColumnName = catalog.Row_ID 28 PhyAddrColumnComment = "Physical address" 29 SortKeyNamePrefx = "_SORT_" 30 31 AttrRowID = PhyAddrColumnName 32 AttrCommitTs = "commit_time" 33 AttrAborted = "aborted" 34 35 TenantSysID = uint32(0) 36 SystemSegment_DB_ID = uint64(101) 37 SystemSegment_Table_ID = uint64(102) 38 SystemSegment_Columns_ID = uint64(103) 39 SystemBlock_DB_ID = uint64(201) 40 SystemBlock_Table_ID = uint64(202) 41 SystemBlock_Columns_ID = uint64(203) 42 ) 43 44 var SystemDBSchema *Schema 45 var SystemTableSchema *Schema 46 var SystemColumnSchema *Schema 47 48 const ( 49 ModelSchemaName = "_ModelSchema" 50 ModelAttrET = "ET" 51 ModelAttrID = "ID" 52 ModelAttrName = "NAME" 53 ModelAttrTS = "TS" 54 ModelAttrOpT = "OPT" 55 ModelAttrLogIdx = "LOGIDX" 56 ModelAttrInfo = "INFO" 57 ModelAttrParentID = "PARENTID" 58 ) 59 60 func init() { 61 var err error 62 PhyAddrColumnType = types.T_Rowid.ToType() 63 64 SystemDBSchema = NewEmptySchema(catalog.MO_DATABASE) 65 for i, colname := range catalog.MoDatabaseSchema { 66 if i == 0 { 67 if err = SystemDBSchema.AppendPKCol(colname, catalog.MoDatabaseTypes[i], 0); err != nil { 68 panic(err) 69 } 70 } else { 71 if err = SystemDBSchema.AppendCol(colname, catalog.MoDatabaseTypes[i]); err != nil { 72 panic(err) 73 } 74 } 75 } 76 if err = SystemDBSchema.Finalize(true); err != nil { 77 panic(err) 78 } 79 80 SystemTableSchema = NewEmptySchema(catalog.MO_TABLES) 81 for i, colname := range catalog.MoTablesSchema { 82 if i == 0 { 83 if err = SystemTableSchema.AppendPKCol(colname, catalog.MoTablesTypes[i], 0); err != nil { 84 panic(err) 85 } 86 } else { 87 if err = SystemTableSchema.AppendCol(colname, catalog.MoTablesTypes[i]); err != nil { 88 panic(err) 89 } 90 } 91 } 92 if err = SystemTableSchema.Finalize(true); err != nil { 93 panic(err) 94 } 95 96 SystemColumnSchema = NewEmptySchema(catalog.MO_COLUMNS) 97 for i, colname := range catalog.MoColumnsSchema { 98 if i == 0 { 99 if err = SystemColumnSchema.AppendPKCol(colname, catalog.MoColumnsTypes[i], 0); err != nil { 100 panic(err) 101 } 102 } else { 103 if err = SystemColumnSchema.AppendCol(colname, catalog.MoColumnsTypes[i]); err != nil { 104 panic(err) 105 } 106 } 107 } 108 if err = SystemColumnSchema.Finalize(true); err != nil { 109 panic(err) 110 } 111 }