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