oracledb 3.0.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +135 -8
- package/README.md +6 -4
- package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi48-linux-x64.node +0 -0
- package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi48-win32-x64.node +0 -0
- package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-linux-x64.node +0 -0
- package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-win32-x64.node +0 -0
- package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-linux-x64.node +0 -0
- package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-win32-x64.node +0 -0
- package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-linux-x64.node +0 -0
- package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-win32-x64.node +0 -0
- package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
- package/lib/connection.js +18 -4
- package/lib/oracledb.js +44 -92
- package/lib/pool.js +36 -2
- package/lib/sodaCollection.js +1 -1
- package/lib/sodaDatabase.js +1 -1
- package/lib/util.js +82 -5
- package/package/README.md +32 -101
- package/package/install.js +139 -0
- package/package/prunebinaries.js +51 -0
- package/package.json +4 -11
- package/binding.gyp +0 -162
- package/lib/rel.txt +0 -1
- package/odpi/.npmignore +0 -4
- package/odpi/LICENSE.md +0 -218
- package/odpi/README.md +0 -61
- package/odpi/embed/README.md +0 -4
- package/odpi/embed/dpi.c +0 -50
- package/odpi/include/dpi.h +0 -1748
- package/odpi/src/dpiConn.c +0 -2089
- package/odpi/src/dpiContext.c +0 -296
- package/odpi/src/dpiData.c +0 -797
- package/odpi/src/dpiDebug.c +0 -184
- package/odpi/src/dpiDeqOptions.c +0 -370
- package/odpi/src/dpiEnqOptions.c +0 -174
- package/odpi/src/dpiEnv.c +0 -189
- package/odpi/src/dpiError.c +0 -204
- package/odpi/src/dpiErrorMessages.h +0 -86
- package/odpi/src/dpiGen.c +0 -303
- package/odpi/src/dpiGlobal.c +0 -292
- package/odpi/src/dpiHandleList.c +0 -117
- package/odpi/src/dpiHandlePool.c +0 -118
- package/odpi/src/dpiImpl.h +0 -1707
- package/odpi/src/dpiLob.c +0 -506
- package/odpi/src/dpiMsgProps.c +0 -386
- package/odpi/src/dpiObject.c +0 -897
- package/odpi/src/dpiObjectAttr.c +0 -115
- package/odpi/src/dpiObjectType.c +0 -326
- package/odpi/src/dpiOci.c +0 -3527
- package/odpi/src/dpiOracleType.c +0 -492
- package/odpi/src/dpiPool.c +0 -549
- package/odpi/src/dpiRowid.c +0 -136
- package/odpi/src/dpiSodaColl.c +0 -685
- package/odpi/src/dpiSodaCollCursor.c +0 -143
- package/odpi/src/dpiSodaDb.c +0 -432
- package/odpi/src/dpiSodaDoc.c +0 -230
- package/odpi/src/dpiSodaDocCursor.c +0 -143
- package/odpi/src/dpiStmt.c +0 -1797
- package/odpi/src/dpiSubscr.c +0 -674
- package/odpi/src/dpiUtils.c +0 -410
- package/odpi/src/dpiVar.c +0 -1794
- package/package/MAKEPKG.BAT +0 -156
- package/package/Makefile +0 -85
- package/package/createpackage.js +0 -186
- package/package/extractpackage.js +0 -76
- package/package/getversion.js +0 -37
- package/package/oracledbinstall.js +0 -497
- package/package/package.json +0 -54
- package/package/util.js +0 -286
- package/src/njsCommon.cpp +0 -1055
- package/src/njsCommon.h +0 -484
- package/src/njsConnection.cpp +0 -2926
- package/src/njsConnection.h +0 -227
- package/src/njsIntLob.cpp +0 -618
- package/src/njsIntLob.h +0 -179
- package/src/njsMessages.cpp +0 -122
- package/src/njsMessages.h +0 -118
- package/src/njsOracle.cpp +0 -1274
- package/src/njsOracle.h +0 -237
- package/src/njsPool.cpp +0 -482
- package/src/njsPool.h +0 -132
- package/src/njsResultSet.cpp +0 -478
- package/src/njsResultSet.h +0 -120
- package/src/njsSodaCollection.cpp +0 -507
- package/src/njsSodaCollection.h +0 -128
- package/src/njsSodaDatabase.cpp +0 -335
- package/src/njsSodaDatabase.h +0 -108
- package/src/njsSodaDocCursor.cpp +0 -203
- package/src/njsSodaDocCursor.h +0 -94
- package/src/njsSodaDocument.cpp +0 -412
- package/src/njsSodaDocument.h +0 -105
- package/src/njsSodaOperation.cpp +0 -557
- package/src/njsSodaOperation.h +0 -123
- package/src/njsSubscription.cpp +0 -388
- package/src/njsSubscription.h +0 -111
- package/src/njsUtils.cpp +0 -158
- package/src/njsUtils.h +0 -68
package/odpi/src/dpiUtils.c
DELETED
|
@@ -1,410 +0,0 @@
|
|
|
1
|
-
//-----------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
|
3
|
-
// This program is free software: you can modify it and/or redistribute it
|
|
4
|
-
// under the terms of:
|
|
5
|
-
//
|
|
6
|
-
// (i) the Universal Permissive License v 1.0 or at your option, any
|
|
7
|
-
// later version (http://oss.oracle.com/licenses/upl); and/or
|
|
8
|
-
//
|
|
9
|
-
// (ii) the Apache License v 2.0. (http://www.apache.org/licenses/LICENSE-2.0)
|
|
10
|
-
//-----------------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
//-----------------------------------------------------------------------------
|
|
13
|
-
// dpiUtils.c
|
|
14
|
-
// Utility methods that aren't specific to a particular type.
|
|
15
|
-
//-----------------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
#include "dpiImpl.h"
|
|
18
|
-
|
|
19
|
-
//-----------------------------------------------------------------------------
|
|
20
|
-
// dpiUtils__allocateMemory() [INTERNAL]
|
|
21
|
-
// Method for allocating memory which permits tracing and populates the error
|
|
22
|
-
// structure in the event of a memory allocation failure.
|
|
23
|
-
//-----------------------------------------------------------------------------
|
|
24
|
-
int dpiUtils__allocateMemory(size_t numMembers, size_t memberSize,
|
|
25
|
-
int clearMemory, const char *action, void **ptr, dpiError *error)
|
|
26
|
-
{
|
|
27
|
-
if (clearMemory)
|
|
28
|
-
*ptr = calloc(numMembers, memberSize);
|
|
29
|
-
else *ptr = malloc(numMembers * memberSize);
|
|
30
|
-
if (!*ptr)
|
|
31
|
-
return dpiError__set(error, action, DPI_ERR_NO_MEMORY);
|
|
32
|
-
if (dpiDebugLevel & DPI_DEBUG_LEVEL_MEM)
|
|
33
|
-
dpiDebug__print("allocated %u bytes at %p (%s)\n",
|
|
34
|
-
numMembers * memberSize, *ptr, action);
|
|
35
|
-
return DPI_SUCCESS;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//-----------------------------------------------------------------------------
|
|
40
|
-
// dpiUtils__checkClientVersion() [INTERNAL]
|
|
41
|
-
// Check the Oracle Client version and verify that it is at least at the
|
|
42
|
-
// minimum version that is required.
|
|
43
|
-
//-----------------------------------------------------------------------------
|
|
44
|
-
int dpiUtils__checkClientVersion(dpiVersionInfo *versionInfo,
|
|
45
|
-
int minVersionNum, int minReleaseNum, dpiError *error)
|
|
46
|
-
{
|
|
47
|
-
if (versionInfo->versionNum < minVersionNum ||
|
|
48
|
-
(versionInfo->versionNum == minVersionNum &&
|
|
49
|
-
versionInfo->releaseNum < minReleaseNum))
|
|
50
|
-
return dpiError__set(error, "check Oracle Client version",
|
|
51
|
-
DPI_ERR_ORACLE_CLIENT_TOO_OLD, versionInfo->versionNum,
|
|
52
|
-
versionInfo->releaseNum, minVersionNum, minReleaseNum);
|
|
53
|
-
return DPI_SUCCESS;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//-----------------------------------------------------------------------------
|
|
58
|
-
// dpiUtils__checkDatabaseVersion() [INTERNAL]
|
|
59
|
-
// Check the Oracle Database version and verify that it is at least at the
|
|
60
|
-
// minimum version that is required.
|
|
61
|
-
//-----------------------------------------------------------------------------
|
|
62
|
-
int dpiUtils__checkDatabaseVersion(dpiConn *conn, int minVersionNum,
|
|
63
|
-
int minReleaseNum, dpiError *error)
|
|
64
|
-
{
|
|
65
|
-
if (dpiConn__getServerVersion(conn, error) < 0)
|
|
66
|
-
return DPI_FAILURE;
|
|
67
|
-
if (conn->versionInfo.versionNum < minVersionNum ||
|
|
68
|
-
(conn->versionInfo.versionNum == minVersionNum &&
|
|
69
|
-
conn->versionInfo.releaseNum < minReleaseNum))
|
|
70
|
-
return dpiError__set(error, "check Oracle Database version",
|
|
71
|
-
DPI_ERR_ORACLE_DB_TOO_OLD, conn->versionInfo.versionNum,
|
|
72
|
-
conn->versionInfo.releaseNum, minVersionNum, minReleaseNum);
|
|
73
|
-
return DPI_SUCCESS;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//-----------------------------------------------------------------------------
|
|
78
|
-
// dpiUtils__clearMemory() [INTERNAL]
|
|
79
|
-
// Method for clearing memory that will not be optimised away by the
|
|
80
|
-
// compiler. Simple use of memset() can be optimised away. This routine makes
|
|
81
|
-
// use of a volatile pointer which most compilers will avoid optimising away,
|
|
82
|
-
// even if the pointer appears to be unused after the call.
|
|
83
|
-
//-----------------------------------------------------------------------------
|
|
84
|
-
void dpiUtils__clearMemory(void *ptr, size_t length)
|
|
85
|
-
{
|
|
86
|
-
volatile unsigned char *temp = (unsigned char *) ptr;
|
|
87
|
-
|
|
88
|
-
while (length--)
|
|
89
|
-
*temp++ = '\0';
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
//-----------------------------------------------------------------------------
|
|
94
|
-
// dpiUtils__freeMemory() [INTERNAL]
|
|
95
|
-
// Method for allocating memory which permits tracing and populates the error
|
|
96
|
-
// structure in the event of a memory allocation failure.
|
|
97
|
-
//-----------------------------------------------------------------------------
|
|
98
|
-
void dpiUtils__freeMemory(void *ptr)
|
|
99
|
-
{
|
|
100
|
-
if (dpiDebugLevel & DPI_DEBUG_LEVEL_MEM)
|
|
101
|
-
dpiDebug__print("freed ptr at %p\n", ptr);
|
|
102
|
-
free(ptr);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
//-----------------------------------------------------------------------------
|
|
107
|
-
// dpiUtils__getAttrStringWithDup() [INTERNAL]
|
|
108
|
-
// Get the string attribute from the OCI and duplicate its contents.
|
|
109
|
-
//-----------------------------------------------------------------------------
|
|
110
|
-
int dpiUtils__getAttrStringWithDup(const char *action, const void *ociHandle,
|
|
111
|
-
uint32_t ociHandleType, uint32_t ociAttribute, const char **value,
|
|
112
|
-
uint32_t *valueLength, dpiError *error)
|
|
113
|
-
{
|
|
114
|
-
char *source, *temp;
|
|
115
|
-
|
|
116
|
-
if (dpiOci__attrGet(ociHandle, ociHandleType, (void*) &source,
|
|
117
|
-
valueLength, ociAttribute, action, error) < 0)
|
|
118
|
-
return DPI_FAILURE;
|
|
119
|
-
if (dpiUtils__allocateMemory(1, *valueLength, 0, action, (void**) &temp,
|
|
120
|
-
error) < 0)
|
|
121
|
-
return DPI_FAILURE;
|
|
122
|
-
*value = (const char*) memcpy(temp, source, *valueLength);
|
|
123
|
-
return DPI_SUCCESS;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//-----------------------------------------------------------------------------
|
|
128
|
-
// dpiUtils__parseNumberString() [INTERNAL]
|
|
129
|
-
// Parse the contents of a string that is supposed to contain a number. The
|
|
130
|
-
// number is expected to be in the format (www.json.org):
|
|
131
|
-
// - optional negative sign (-)
|
|
132
|
-
// - any number of digits but at least one (0-9)
|
|
133
|
-
// - an optional decimal point (.)
|
|
134
|
-
// - any number of digits but at least one if decimal point specified (0-9)
|
|
135
|
-
// - an optional exponent indicator (e or E)
|
|
136
|
-
// - an optional exponent sign (+ or -)
|
|
137
|
-
// - any number of digits, but at least one if exponent specified (0-9)
|
|
138
|
-
// What is returned is an indication of whether the number is negative, what
|
|
139
|
-
// the index of the decimal point in the string is and the list of digits
|
|
140
|
-
// without the decimal point. Note that OCI doesn't support more than 40 digits
|
|
141
|
-
// so if there are more than this amount an error is raised. OCI doesn't
|
|
142
|
-
// support larger than 1e126 so check for this value and raise a numeric
|
|
143
|
-
// overflow error if found. OCI also doesn't support smaller than 1E-130 so
|
|
144
|
-
// check for this value as well and if smaller than that value simply return
|
|
145
|
-
// zero.
|
|
146
|
-
//-----------------------------------------------------------------------------
|
|
147
|
-
int dpiUtils__parseNumberString(const char *value, uint32_t valueLength,
|
|
148
|
-
uint16_t charsetId, int *isNegative, int16_t *decimalPointIndex,
|
|
149
|
-
uint8_t *numDigits, uint8_t *digits, dpiError *error)
|
|
150
|
-
{
|
|
151
|
-
char convertedValue[DPI_NUMBER_AS_TEXT_CHARS], exponentDigits[4];
|
|
152
|
-
uint8_t numExponentDigits, digit;
|
|
153
|
-
uint32_t convertedValueLength;
|
|
154
|
-
uint16_t *utf16chars, i;
|
|
155
|
-
int exponentIsNegative;
|
|
156
|
-
const char *endValue;
|
|
157
|
-
int16_t exponent;
|
|
158
|
-
|
|
159
|
-
// empty strings are not valid numbers
|
|
160
|
-
if (valueLength == 0)
|
|
161
|
-
return dpiError__set(error, "zero length", DPI_ERR_INVALID_NUMBER);
|
|
162
|
-
|
|
163
|
-
// strings longer than the maximum length of a valid number are also
|
|
164
|
-
// excluded
|
|
165
|
-
if ((charsetId == DPI_CHARSET_ID_UTF16 &&
|
|
166
|
-
valueLength > DPI_NUMBER_AS_TEXT_CHARS * 2) ||
|
|
167
|
-
(charsetId != DPI_CHARSET_ID_UTF16 &&
|
|
168
|
-
valueLength > DPI_NUMBER_AS_TEXT_CHARS))
|
|
169
|
-
return dpiError__set(error, "check length",
|
|
170
|
-
DPI_ERR_NUMBER_STRING_TOO_LONG);
|
|
171
|
-
|
|
172
|
-
// if value is encoded in UTF-16, convert to single byte encoding first
|
|
173
|
-
// check for values that cannot be encoded in a single byte and are
|
|
174
|
-
// obviously not part of a valid numeric string
|
|
175
|
-
// also verify maximum length of number
|
|
176
|
-
if (charsetId == DPI_CHARSET_ID_UTF16) {
|
|
177
|
-
utf16chars = (uint16_t*) value;
|
|
178
|
-
convertedValue[0] = '\0';
|
|
179
|
-
convertedValueLength = valueLength / 2;
|
|
180
|
-
for (i = 0; i < convertedValueLength; i++) {
|
|
181
|
-
if (*utf16chars > 127)
|
|
182
|
-
return dpiError__set(error, "convert from UTF-16",
|
|
183
|
-
DPI_ERR_INVALID_NUMBER);
|
|
184
|
-
convertedValue[i] = (char) *utf16chars++;
|
|
185
|
-
}
|
|
186
|
-
value = convertedValue;
|
|
187
|
-
valueLength = convertedValueLength;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// see if first character is a minus sign (number is negative)
|
|
191
|
-
endValue = value + valueLength;
|
|
192
|
-
*isNegative = (*value == '-');
|
|
193
|
-
if (*isNegative)
|
|
194
|
-
value++;
|
|
195
|
-
|
|
196
|
-
// scan for digits until the decimal point or exponent indicator is found
|
|
197
|
-
*numDigits = 0;
|
|
198
|
-
while (value < endValue) {
|
|
199
|
-
if (*value == '.' || *value == 'e' || *value == 'E')
|
|
200
|
-
break;
|
|
201
|
-
if (*value < '0' || *value > '9')
|
|
202
|
-
return dpiError__set(error, "check digits before decimal point",
|
|
203
|
-
DPI_ERR_INVALID_NUMBER);
|
|
204
|
-
digit = (uint8_t) (*value++ - '0');
|
|
205
|
-
if (digit == 0 && *numDigits == 0)
|
|
206
|
-
continue;
|
|
207
|
-
*digits++ = digit;
|
|
208
|
-
(*numDigits)++;
|
|
209
|
-
}
|
|
210
|
-
*decimalPointIndex = *numDigits;
|
|
211
|
-
|
|
212
|
-
// scan for digits following the decimal point, if applicable
|
|
213
|
-
if (value < endValue && *value == '.') {
|
|
214
|
-
value++;
|
|
215
|
-
while (value < endValue) {
|
|
216
|
-
if (*value == 'e' || *value == 'E')
|
|
217
|
-
break;
|
|
218
|
-
if (*value < '0' || *value > '9')
|
|
219
|
-
return dpiError__set(error, "check digits after decimal point",
|
|
220
|
-
DPI_ERR_INVALID_NUMBER);
|
|
221
|
-
digit = (uint8_t) (*value++ - '0');
|
|
222
|
-
if (digit == 0 && *numDigits == 0) {
|
|
223
|
-
(*decimalPointIndex)--;
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
*digits++ = digit;
|
|
227
|
-
(*numDigits)++;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// handle exponent, if applicable
|
|
232
|
-
if (value < endValue && (*value == 'e' || *value == 'E')) {
|
|
233
|
-
value++;
|
|
234
|
-
exponentIsNegative = 0;
|
|
235
|
-
numExponentDigits = 0;
|
|
236
|
-
if (value < endValue && (*value == '+' || *value == '-')) {
|
|
237
|
-
exponentIsNegative = (*value == '-');
|
|
238
|
-
value++;
|
|
239
|
-
}
|
|
240
|
-
while (value < endValue) {
|
|
241
|
-
if (*value < '0' || *value > '9')
|
|
242
|
-
return dpiError__set(error, "check digits in exponent",
|
|
243
|
-
DPI_ERR_INVALID_NUMBER);
|
|
244
|
-
if (numExponentDigits == 3)
|
|
245
|
-
return dpiError__set(error, "check exponent digits > 3",
|
|
246
|
-
DPI_ERR_NOT_SUPPORTED);
|
|
247
|
-
exponentDigits[numExponentDigits] = *value++;
|
|
248
|
-
numExponentDigits++;
|
|
249
|
-
}
|
|
250
|
-
if (numExponentDigits == 0)
|
|
251
|
-
return dpiError__set(error, "no digits in exponent",
|
|
252
|
-
DPI_ERR_INVALID_NUMBER);
|
|
253
|
-
exponentDigits[numExponentDigits] = '\0';
|
|
254
|
-
exponent = (int16_t) strtol(exponentDigits, NULL, 0);
|
|
255
|
-
if (exponentIsNegative)
|
|
256
|
-
exponent = -exponent;
|
|
257
|
-
*decimalPointIndex += exponent;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
// if there is anything left in the string, that indicates an invalid
|
|
261
|
-
// number as well
|
|
262
|
-
if (value < endValue)
|
|
263
|
-
return dpiError__set(error, "check string used",
|
|
264
|
-
DPI_ERR_INVALID_NUMBER);
|
|
265
|
-
|
|
266
|
-
// strip trailing zeroes
|
|
267
|
-
digits--;
|
|
268
|
-
while (*numDigits > 0 && *digits-- == 0)
|
|
269
|
-
(*numDigits)--;
|
|
270
|
-
|
|
271
|
-
// only 40 digits are allowed in an OCI number
|
|
272
|
-
if (*numDigits > DPI_NUMBER_MAX_DIGITS)
|
|
273
|
-
return dpiError__set(error, "check number of digits > 40",
|
|
274
|
-
DPI_ERR_NOT_SUPPORTED);
|
|
275
|
-
|
|
276
|
-
// values must be less than 1e126
|
|
277
|
-
if (*decimalPointIndex > 126)
|
|
278
|
-
return dpiError__set(error, "check size of value",
|
|
279
|
-
DPI_ERR_NUMBER_TOO_LARGE);
|
|
280
|
-
|
|
281
|
-
// values smaller than 1e-130 are simply returned as zero
|
|
282
|
-
if (*decimalPointIndex < -129) {
|
|
283
|
-
*numDigits = 0;
|
|
284
|
-
*isNegative = 0;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return DPI_SUCCESS;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
//-----------------------------------------------------------------------------
|
|
292
|
-
// dpiUtils__parseOracleNumber() [INTERNAL]
|
|
293
|
-
// Parse the contents of an Oracle number and return its constituent parts
|
|
294
|
-
// so that a string can be generated from it easily.
|
|
295
|
-
//-----------------------------------------------------------------------------
|
|
296
|
-
int dpiUtils__parseOracleNumber(void *oracleValue, int *isNegative,
|
|
297
|
-
int16_t *decimalPointIndex, uint8_t *numDigits, uint8_t *digits,
|
|
298
|
-
dpiError *error)
|
|
299
|
-
{
|
|
300
|
-
uint8_t *source, length, i, byte, digit;
|
|
301
|
-
int8_t ociExponent;
|
|
302
|
-
|
|
303
|
-
// the first byte of the structure is a length byte which includes the
|
|
304
|
-
// exponent and the mantissa bytes
|
|
305
|
-
source = (uint8_t*) oracleValue;
|
|
306
|
-
length = *source++ - 1;
|
|
307
|
-
|
|
308
|
-
// a mantissa length longer than 20 signals corruption of some kind
|
|
309
|
-
if (length > 20)
|
|
310
|
-
return dpiError__set(error, "check mantissa length",
|
|
311
|
-
DPI_ERR_INVALID_OCI_NUMBER);
|
|
312
|
-
|
|
313
|
-
// the second byte of the structure is the exponent
|
|
314
|
-
// positive numbers have the highest order bit set whereas negative numbers
|
|
315
|
-
// have the highest order bit cleared and the bits inverted
|
|
316
|
-
ociExponent = (int8_t) *source++;
|
|
317
|
-
*isNegative = (ociExponent & 0x80) ? 0 : 1;
|
|
318
|
-
if (*isNegative)
|
|
319
|
-
ociExponent = ~ociExponent;
|
|
320
|
-
ociExponent -= 193;
|
|
321
|
-
*decimalPointIndex = ociExponent * 2 + 2;
|
|
322
|
-
|
|
323
|
-
// a mantissa length of 0 implies a value of 0 (if positive)
|
|
324
|
-
// or -1e126 (if negative)
|
|
325
|
-
if (length == 0) {
|
|
326
|
-
if (*isNegative) {
|
|
327
|
-
*digits = 1;
|
|
328
|
-
*decimalPointIndex = 127;
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
*decimalPointIndex = 1;
|
|
332
|
-
*digits = 0;
|
|
333
|
-
}
|
|
334
|
-
*numDigits = 1;
|
|
335
|
-
return DPI_SUCCESS;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// check for the trailing 102 byte for negative numbers and if present,
|
|
339
|
-
// reduce the number of mantissa digits
|
|
340
|
-
if (*isNegative && source[length - 1] == 102)
|
|
341
|
-
length--;
|
|
342
|
-
|
|
343
|
-
// process the mantissa which are the remaining bytes
|
|
344
|
-
// each mantissa byte is a base-100 digit
|
|
345
|
-
*numDigits = length * 2;
|
|
346
|
-
for (i = 0; i < length; i++) {
|
|
347
|
-
byte = *source++;
|
|
348
|
-
|
|
349
|
-
// positive numbers have 1 added to them; negative numbers are
|
|
350
|
-
// subtracted from the value 101
|
|
351
|
-
if (*isNegative)
|
|
352
|
-
byte = 101 - byte;
|
|
353
|
-
else byte--;
|
|
354
|
-
|
|
355
|
-
// process the first digit; leading zeroes are ignored
|
|
356
|
-
digit = (uint8_t) (byte / 10);
|
|
357
|
-
if (digit == 0 && i == 0) {
|
|
358
|
-
(*numDigits)--;
|
|
359
|
-
(*decimalPointIndex)--;
|
|
360
|
-
} else if (digit == 10) {
|
|
361
|
-
(*numDigits)++;
|
|
362
|
-
(*decimalPointIndex)++;
|
|
363
|
-
*digits++ = 1;
|
|
364
|
-
*digits++ = 0;
|
|
365
|
-
} else *digits++ = digit;
|
|
366
|
-
|
|
367
|
-
// process the second digit; trailing zeroes are ignored
|
|
368
|
-
digit = byte % 10;
|
|
369
|
-
if (digit == 0 && i == length - 1)
|
|
370
|
-
(*numDigits)--;
|
|
371
|
-
else *digits++ = digit;
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
return DPI_SUCCESS;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
//-----------------------------------------------------------------------------
|
|
380
|
-
// dpiUtils__setAttributesFromCommonCreateParams() [INTERNAL]
|
|
381
|
-
// Set the attributes on the authorization info structure or session handle
|
|
382
|
-
// using the specified parameters.
|
|
383
|
-
//-----------------------------------------------------------------------------
|
|
384
|
-
int dpiUtils__setAttributesFromCommonCreateParams(void *handle,
|
|
385
|
-
uint32_t handleType, const dpiCommonCreateParams *params,
|
|
386
|
-
dpiError *error)
|
|
387
|
-
{
|
|
388
|
-
uint32_t driverNameLength;
|
|
389
|
-
const char *driverName;
|
|
390
|
-
|
|
391
|
-
if (params->driverName && params->driverNameLength > 0) {
|
|
392
|
-
driverName = params->driverName;
|
|
393
|
-
driverNameLength = params->driverNameLength;
|
|
394
|
-
} else {
|
|
395
|
-
driverName = DPI_DEFAULT_DRIVER_NAME;
|
|
396
|
-
driverNameLength = (uint32_t) strlen(driverName);
|
|
397
|
-
}
|
|
398
|
-
if (driverName && driverNameLength > 0 && dpiOci__attrSet(handle,
|
|
399
|
-
handleType, (void*) driverName, driverNameLength,
|
|
400
|
-
DPI_OCI_ATTR_DRIVER_NAME, "set driver name", error) < 0)
|
|
401
|
-
return DPI_FAILURE;
|
|
402
|
-
if (params->edition && params->editionLength > 0 &&
|
|
403
|
-
dpiOci__attrSet(handle, handleType,
|
|
404
|
-
(void*) params->edition, params->editionLength,
|
|
405
|
-
DPI_OCI_ATTR_EDITION, "set edition", error) < 0)
|
|
406
|
-
return DPI_FAILURE;
|
|
407
|
-
|
|
408
|
-
return DPI_SUCCESS;
|
|
409
|
-
}
|
|
410
|
-
|