gitee.com/curryzheng/dm@v0.0.1/zc.go (about) 1 /* 2 * Copyright (c) 2000-2018, 达梦数据库有限公司. 3 * All rights reserved. 4 */ 5 6 package dm 7 8 const ( 9 IGNORE_TARGET_LENGTH int32 = -1 10 11 IGNORE_TARGET_SCALE int32 = -1 12 13 IGNORE_TARGET_TYPE = INT32_MIN 14 15 TYPE_FLAG_UNKNOWN byte = 0 // 未知类型 16 17 TYPE_FLAG_EXACT byte = 1 // 精确类型 18 19 TYPE_FLAG_RECOMMEND byte = 2 // 推荐类型 20 21 IO_TYPE_IN byte = 0 22 23 IO_TYPE_OUT byte = 1 24 25 IO_TYPE_INOUT byte = 2 26 ) 27 28 type execRetInfo struct { 29 // param 30 outParamDatas [][]byte 31 32 // rs 33 hasResultSet bool 34 35 rsDatas [][][]byte 36 37 rsSizeof int // 结果集数据占用多少空间,(消息中结果集起始位置到 rsCacheOffset 38 // 的空间大小,这和实际的rsDatas占用空间大小有一定出入,这里粗略估算,用于结果集缓存时的空间管理) 39 40 rsCacheOffset int32 // 缓存信息,在响应消息体中的偏移,0表示不存在,仅结果集缓存中可以用 41 42 rsBdta bool 43 44 rsUpdatable bool 45 46 rsRowIds []int64 47 48 // rs cache 49 tbIds []int32 50 51 tbTss []int64 52 53 // print 54 printLen int32 55 56 printMsg string 57 58 // explain 59 explain string 60 61 // 影响行数 62 updateCount int64 // Insert/Update/Delet影响行数, select结果集的总行数 63 64 updateCounts []int64 // 批量影响行数 65 66 // 键 67 rowid int64 68 69 lastInsertId int64 70 71 // other 72 retSqlType int16 // 执行返回的语句类型 73 74 execId int32 75 } 76 77 type column struct { 78 typeName string 79 80 colType int32 81 82 prec int32 83 84 scale int32 85 86 name string 87 88 tableName string 89 90 schemaName string 91 92 nullable bool 93 94 identity bool 95 96 readonly bool // 是否只读 97 98 baseName string 99 100 // lob info 101 lob bool 102 103 lobTabId int32 104 105 lobColId int16 106 107 // 用于描述ARRAY、STRUCT类型的特有描述信息 108 typeDescriptor *TypeDescriptor 109 110 isBdta bool 111 } 112 113 type parameter struct { 114 column 115 116 typeFlag byte 117 118 ioType byte 119 120 outJType int32 121 122 outScale int32 123 124 outObjectName string 125 126 cursorStmt *DmStatement 127 } 128 129 func (column *column) InitColumn() *column { 130 column.typeName = "" 131 132 column.colType = 0 133 134 column.prec = 0 135 136 column.scale = 0 137 138 column.name = "" 139 140 column.tableName = "" 141 142 column.schemaName = "" 143 144 column.nullable = false 145 146 column.identity = false 147 148 column.readonly = false 149 150 column.baseName = "" 151 152 // lob info 153 column.lob = false 154 155 column.lobTabId = 0 156 157 column.lobColId = 0 158 159 // 用于描述ARRAY、STRUCT类型的特有描述信息 160 column.typeDescriptor = nil 161 162 column.isBdta = false 163 164 return column 165 } 166 167 func (parameter *parameter) InitParameter() *parameter { 168 parameter.InitColumn() 169 170 parameter.typeFlag = TYPE_FLAG_UNKNOWN 171 172 parameter.ioType = IO_TYPE_IN 173 174 parameter.outJType = IGNORE_TARGET_TYPE 175 176 parameter.outScale = IGNORE_TARGET_SCALE 177 178 parameter.outObjectName = "" 179 180 parameter.cursorStmt = nil 181 182 return parameter 183 } 184 185 func (execInfo *execRetInfo) union(other *execRetInfo, startRow int, count int) { 186 if count == 1 { 187 execInfo.updateCounts[startRow] = other.updateCount 188 } else if execInfo.updateCounts != nil { 189 copy(execInfo.updateCounts[startRow:startRow+count], other.updateCounts[0:count]) 190 } 191 if execInfo.outParamDatas != nil { 192 execInfo.outParamDatas = append(execInfo.outParamDatas, other.outParamDatas...) 193 } 194 } 195 196 func NewExceInfo() *execRetInfo { 197 198 execInfo := execRetInfo{} 199 200 execInfo.outParamDatas = nil 201 202 execInfo.hasResultSet = false 203 204 execInfo.rsDatas = nil 205 206 execInfo.rsSizeof = 0 207 208 execInfo.rsCacheOffset = 0 209 210 execInfo.rsBdta = false 211 212 execInfo.rsUpdatable = false 213 214 execInfo.rsRowIds = nil 215 216 execInfo.tbIds = nil 217 218 execInfo.tbTss = nil 219 220 execInfo.printLen = 0 221 222 execInfo.printMsg = "" 223 224 execInfo.explain = "" 225 226 execInfo.updateCount = 0 227 228 execInfo.updateCounts = nil 229 230 execInfo.rowid = -1 231 232 execInfo.lastInsertId = 0 233 // other 234 execInfo.retSqlType = -1 // 执行返回的语句类型 235 236 execInfo.execId = 0 237 238 return &execInfo 239 }