Skip to content

Commit 1671df3

Browse files
committed
add more fields to parameter/columns
1 parent 486e221 commit 1671df3

File tree

2 files changed

+117
-52
lines changed

2 files changed

+117
-52
lines changed

v2/data_type_nego.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,12 @@ func buildTypeNego(nego *TCPNego, session *network.Session) *DataTypeNego {
329329
result.addTypeRep(583, 583, TNS_TYPE_REP_UNIVERSAL)
330330
result.addTypeRep(584, 584, TNS_TYPE_REP_UNIVERSAL)
331331
result.addTypeRep(585, 585, TNS_TYPE_REP_UNIVERSAL)
332-
result.addTypeRep(3, 2, TNS_TYPE_REP_ORACLE)
333-
result.addTypeRep(4, 2, TNS_TYPE_REP_ORACLE)
334-
result.addTypeRep(5, 1, TNS_TYPE_REP_UNIVERSAL)
335-
result.addTypeRep(6, 2, TNS_TYPE_REP_ORACLE)
336-
result.addTypeRep(7, 2, TNS_TYPE_REP_ORACLE)
337-
result.addTypeRep(9, 1, TNS_TYPE_REP_UNIVERSAL)
332+
result.addTypeRep(int16(BInteger), int16(NUMBER), TNS_TYPE_REP_ORACLE)
333+
result.addTypeRep(int16(FLOAT), int16(NUMBER), TNS_TYPE_REP_ORACLE)
334+
result.addTypeRep(int16(NullStr), int16(NCHAR), TNS_TYPE_REP_UNIVERSAL)
335+
result.addTypeRep(int16(VarNum), int16(NUMBER), TNS_TYPE_REP_ORACLE)
336+
result.addTypeRep(int16(PDN), int16(NUMBER), TNS_TYPE_REP_ORACLE)
337+
result.addTypeRep(int16(VARCHAR), int16(NCHAR), TNS_TYPE_REP_UNIVERSAL)
338338
result.addTypeRep(13, 0, TNS_TYPE_REP_NATIVE)
339339
result.addTypeRep(14, 0, TNS_TYPE_REP_NATIVE)
340340
result.addTypeRep(15, 23, TNS_TYPE_REP_UNIVERSAL)
@@ -373,7 +373,7 @@ func buildTypeNego(nego *TCPNego, session *network.Session) *DataTypeNego {
373373
result.addTypeRep(115, 115, TNS_TYPE_REP_UNIVERSAL)
374374
result.addTypeRep(116, 102, TNS_TYPE_REP_UNIVERSAL)
375375
result.addTypeRep(118, 0, TNS_TYPE_REP_NATIVE)
376-
result.addTypeRep(119, 0, TNS_TYPE_REP_NATIVE)
376+
result.addTypeRep(int16(JSON), int16(JSON), TNS_TYPE_REP_NATIVE)
377377
result.addTypeRep(121, 0, TNS_TYPE_REP_NATIVE)
378378
result.addTypeRep(122, 0, TNS_TYPE_REP_NATIVE)
379379
result.addTypeRep(123, 0, TNS_TYPE_REP_NATIVE)

v2/parameter.go

Lines changed: 110 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -51,48 +51,54 @@ const (
5151
//SB1 TNSType = 3
5252
//SB2 TNSType = 3
5353
//SB4 TNSType = 3
54-
FLOAT TNSType = 4
55-
NullStr TNSType = 5
56-
VarNum TNSType = 6
57-
LONG TNSType = 8
58-
VARCHAR TNSType = 9
59-
ROWID TNSType = 11
60-
DATE TNSType = 12
61-
VarRaw TNSType = 15
62-
BFloat TNSType = 21
63-
BDouble TNSType = 22
64-
RAW TNSType = 23
65-
LongRaw TNSType = 24
66-
UINT TNSType = 68
67-
LongVarChar TNSType = 94
68-
LongVarRaw TNSType = 95
69-
CHAR TNSType = 96
70-
CHARZ TNSType = 97
71-
IBFloat TNSType = 100
72-
IBDouble TNSType = 101
73-
REFCURSOR TNSType = 102
74-
OCIXMLType TNSType = 108
75-
XMLType TNSType = 109
76-
OCIRef TNSType = 110
77-
OCIClobLocator TNSType = 112
78-
OCIBlobLocator TNSType = 113
79-
OCIFileLocator TNSType = 114
80-
ResultSet TNSType = 116
81-
OCIString TNSType = 155
82-
OCIDate TNSType = 156
83-
TimeStampDTY TNSType = 180
84-
TimeStampTZ_DTY TNSType = 181
85-
IntervalYM_DTY TNSType = 182
86-
IntervalDS_DTY TNSType = 183
87-
TimeTZ TNSType = 186
88-
TIMESTAMP TNSType = 187
89-
TIMESTAMPTZ TNSType = 188
90-
IntervalYM TNSType = 189
91-
IntervalDS TNSType = 190
92-
UROWID TNSType = 208
93-
TimeStampLTZ_DTY TNSType = 231
94-
TimeStampeLTZ TNSType = 232
95-
Boolean TNSType = 0xFC
54+
FLOAT TNSType = 4
55+
NullStr TNSType = 5
56+
VarNum TNSType = 6
57+
PDN TNSType = 7
58+
LONG TNSType = 8
59+
VARCHAR TNSType = 9
60+
ROWID TNSType = 11
61+
DATE TNSType = 12
62+
VarRaw TNSType = 15
63+
BFloat TNSType = 21
64+
BDouble TNSType = 22
65+
RAW TNSType = 23
66+
LongRaw TNSType = 24
67+
TNS_JSON_TYPE_DATE TNSType = 60
68+
TNS_JSON_TYPE_INTERVAL_YM TNSType = 61
69+
TNS_JSON_TYPE_INTERVAL_DS TNSType = 62
70+
UINT TNSType = 68
71+
LongVarChar TNSType = 94
72+
LongVarRaw TNSType = 95
73+
CHAR TNSType = 96
74+
CHARZ TNSType = 97
75+
IBFloat TNSType = 100
76+
IBDouble TNSType = 101
77+
REFCURSOR TNSType = 102
78+
OCIXMLType TNSType = 108
79+
XMLType TNSType = 109
80+
OCIRef TNSType = 110
81+
OCIClobLocator TNSType = 112
82+
OCIBlobLocator TNSType = 113
83+
OCIFileLocator TNSType = 114
84+
ResultSet TNSType = 116
85+
JSON TNSType = 119
86+
TNS_DATA_TYPE_OAC122 TNSType = 120
87+
OCIString TNSType = 155
88+
OCIDate TNSType = 156
89+
TimeStampDTY TNSType = 180
90+
TimeStampTZ_DTY TNSType = 181
91+
IntervalYM_DTY TNSType = 182
92+
IntervalDS_DTY TNSType = 183
93+
TimeTZ TNSType = 186
94+
TIMESTAMP TNSType = 187
95+
TIMESTAMPTZ TNSType = 188
96+
IntervalYM TNSType = 189
97+
IntervalDS TNSType = 190
98+
UROWID TNSType = 208
99+
TimeStampLTZ_DTY TNSType = 231
100+
TimeStampeLTZ TNSType = 232
101+
Boolean TNSType = 0xFC
96102
)
97103

98104
type ParameterType int
@@ -105,9 +111,13 @@ const (
105111
type ParameterInfo struct {
106112
Name string
107113
TypeName string
114+
SchemaName string
115+
DomainSchema string
116+
DomainName string
108117
Direction ParameterDirection
109118
IsNull bool
110119
AllowNull bool
120+
IsJson bool
111121
ColAlias string
112122
DataType TNSType
113123
IsXmlType bool
@@ -130,6 +140,7 @@ type ParameterInfo struct {
130140
getDataFromServer bool
131141
oaccollid int
132142
cusType *customType
143+
Annotations map[string]string
133144
}
134145

135146
// load get parameter information form network session
@@ -251,7 +262,7 @@ func (par *ParameterInfo) load(conn *Connection) error {
251262
return err
252263
}
253264
par.AllowNull = num1 > 0
254-
_, err = session.GetByte() // session.GetInt(1, false, false)
265+
_, err = session.GetByte() // v7 length of name
255266
if err != nil {
256267
return err
257268
}
@@ -260,7 +271,11 @@ func (par *ParameterInfo) load(conn *Connection) error {
260271
return err
261272
}
262273
par.Name = session.StrConv.Decode(bName)
263-
_, err = session.GetDlc()
274+
bName, err = session.GetDlc() // schema name
275+
if err != nil {
276+
return err
277+
}
278+
par.SchemaName = strings.ToUpper(session.StrConv.Decode(bName))
264279
bName, err = session.GetDlc()
265280
if err != nil {
266281
return err
@@ -285,7 +300,57 @@ func (par *ParameterInfo) load(conn *Connection) error {
285300
if session.TTCVersion < 6 {
286301
return nil
287302
}
288-
_, err = session.GetInt(4, true, true)
303+
var uds_flags int
304+
uds_flags, err = session.GetInt(4, true, true)
305+
par.IsJson = (uds_flags & 0x100) > 0
306+
if session.TTCVersion < 17 {
307+
return nil
308+
}
309+
bName, err = session.GetDlc()
310+
if err != nil {
311+
return err
312+
}
313+
par.DomainSchema = strings.ToUpper(session.StrConv.Decode(bName))
314+
bName, err = session.GetDlc()
315+
if err != nil {
316+
return err
317+
}
318+
par.DomainName = strings.ToUpper(session.StrConv.Decode(bName))
319+
if session.TTCVersion < 20 {
320+
return nil
321+
}
322+
numAnnotations, err := session.GetInt(4, true, true)
323+
if err != nil {
324+
return err
325+
}
326+
if numAnnotations > 0 {
327+
par.Annotations = make(map[string]string)
328+
_, err = session.GetByte()
329+
if err != nil {
330+
return err
331+
}
332+
numAnnotations, err = session.GetInt(4, true, true)
333+
if err != nil {
334+
return err
335+
}
336+
_, err = session.GetByte()
337+
if err != nil {
338+
return err
339+
}
340+
for i := 0; i < numAnnotations; i++ {
341+
bKey, bValue, _, err := session.GetKeyVal()
342+
if err != nil {
343+
return err
344+
}
345+
key := session.StrConv.Decode(bKey)
346+
value := session.StrConv.Decode(bValue)
347+
par.Annotations[key] = value
348+
}
349+
_, err = session.GetInt(4, true, true)
350+
if err != nil {
351+
return err
352+
}
353+
}
289354
return nil
290355
}
291356

0 commit comments

Comments
 (0)