Skip to content

Commit c5163d9

Browse files
committed
Code changes for node-oracledb 1.0
1 parent 4c43d72 commit c5163d9

31 files changed

+3524
-277
lines changed

binding.gyp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"src/njs/src/njsConnection.cpp",
99
"src/njs/src/njsResultSet.cpp",
1010
"src/njs/src/njsMessages.cpp",
11+
"src/njs/src/njsIntLob.cpp",
1112
"src/dpi/src/dpiEnv.cpp",
1213
"src/dpi/src/dpiEnvImpl.cpp",
1314
"src/dpi/src/dpiException.cpp",
@@ -16,7 +17,8 @@
1617
"src/dpi/src/dpiDateTimeArrayImpl.cpp",
1718
"src/dpi/src/dpiPoolImpl.cpp",
1819
"src/dpi/src/dpiStmtImpl.cpp",
19-
"src/dpi/src/dpiUtils.cpp"
20+
"src/dpi/src/dpiUtils.cpp",
21+
"src/dpi/src/dpiLob.cpp"
2022
],
2123
"conditions" : [
2224
[

src/dpi/include/dpiCommon.h

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */
2+
3+
/*******************************************************************************
4+
*
5+
* You may not use the identified files except in compliance with the Apache
6+
* License, Version 2.0 (the "License.")
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
*
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* NAME
19+
* dpiCommon.h
20+
*
21+
* DESCRIPTION
22+
*
23+
******************************************************************************/
24+
25+
#ifndef DPICOMMON_ORACLE
26+
# define DPICOMMON_ORACLE
27+
28+
29+
namespace dpi
30+
{
31+
32+
33+
/*----------------------------------------------------------------------------
34+
PUBLIC CONSTANTS
35+
----------------------------------------------------------------------------*/
36+
37+
38+
enum HandleType
39+
{
40+
ErrorHandleType = 2 // OCI_HTYPE_ERROR
41+
};
42+
43+
44+
45+
enum DescriptorType
46+
{
47+
LobDescriptorType = 50 // OCI_TYPE_LOB
48+
};
49+
50+
51+
52+
/*----------------------------------------------------------------------------
53+
PUBLIC TYPES
54+
----------------------------------------------------------------------------*/
55+
56+
struct DpiHandle;
57+
struct Descriptor;
58+
59+
/*----------------------------------------------------------------------------
60+
PUBLIC METHODS
61+
----------------------------------------------------------------------------*/
62+
63+
64+
65+
} // end of namespace dpi
66+
67+
68+
#endif /* DPICOMMON_ORACLE */

src/dpi/include/dpiConn.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
#ifndef DPICONN_ORACLE
2626
# define DPICONN_ORACLE
2727

28+
#ifndef DPILOB_ORACLE
29+
# include <dpiLob.h>
30+
#endif
31+
2832
#ifndef DPISTMT_ORACLE
2933
# include <dpiStmt.h>
3034
#endif
@@ -60,6 +64,9 @@ class Conn
6064
virtual void stmtCacheSize(unsigned int stmtCacheSize) = 0;
6165
virtual unsigned int stmtCacheSize() const = 0;
6266

67+
virtual void lobPrefetchSize(unsigned int lobPrefetchSize) = 0;
68+
virtual unsigned int lobPrefetchSize() const = 0;
69+
6370
virtual void clientId(const string &clientId) = 0;
6471

6572
virtual void module(const string &module) = 0;
@@ -75,6 +82,10 @@ class Conn
7582

7683
virtual void breakExecution() = 0;
7784

85+
virtual DpiHandle *getSvch () = 0;
86+
87+
virtual DpiHandle *getErrh () = 0;
88+
7889
protected:
7990
// clients cannot do new and delete
8091
Conn(){};

src/dpi/include/dpiEnv.h

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@
2828

2929
#include <string>
3030

31-
#ifndef DPI_ORACLE
32-
# include <dpi.h>
31+
32+
#ifndef DPICOMMON_ORACLE
33+
# include <dpiCommon.h>
3334
#endif
3435

3536
#ifndef DPIPOOL_ORACLE
3637
# include <dpiPool.h>
3738
#endif
3839

39-
4040
#ifndef DPICONN_ORACLE
4141
# include <dpiConn.h>
4242
#endif
@@ -51,6 +51,11 @@ namespace dpi
5151
class DateTimeArray;
5252

5353

54+
/*---------------------------------------------------------------------------
55+
PUBLIC CONSTANTS
56+
---------------------------------------------------------------------------*/
57+
58+
5459
/*---------------------------------------------------------------------------
5560
PUBLIC TYPES
5661
---------------------------------------------------------------------------*/
@@ -98,7 +103,30 @@ class Env
98103
// DateTime array
99104
virtual DateTimeArray * getDateTimeArray( OCIError *errh ) const = 0;
100105
virtual void releaseDateTimeArray ( DateTimeArray *arr ) const = 0;
101-
106+
107+
// handle and descriptor methods
108+
virtual DpiHandle * allocHandle(HandleType handleType) = 0;
109+
110+
static void freeHandle(DpiHandle *handle, HandleType handleType);
111+
112+
113+
virtual Descriptor * allocDescriptor(DescriptorType descriptorType)
114+
= 0;
115+
116+
static void freeDescriptor(Descriptor *descriptor,
117+
DescriptorType descriptorType);
118+
119+
virtual void allocDescriptorArray(DescriptorType descriptorType,
120+
unsigned int arraySize,
121+
Descriptor **descriptorArray) = 0;
122+
123+
static void freeDescriptorArray(Descriptor **descriptorArray,
124+
DescriptorType descriptorType);
125+
126+
127+
virtual DpiHandle * envHandle() const = 0;
128+
129+
102130
protected:
103131
// clients cannot do new and delete
104132
Env();

src/dpi/include/dpiException.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,30 @@ namespace dpi
3737
{
3838

3939

40-
/*---------------------------------------------------------------------------
40+
/*----------------------------------------------------------------------------
4141
PUBLIC CONSTANTS
42-
---------------------------------------------------------------------------*/
42+
----------------------------------------------------------------------------*/
4343

4444
enum DpiError // error type
4545
{
46-
DpiErrNoError = 000, // "DPI not an error"
47-
DpiErrInternal = 001, // "DPI internal error"
48-
DpiErrUnkOciError = 002, // "Could not get OCI Error message"
49-
DpiErrNoEnv = 003, // "No OCI environment handle created"
50-
DpiErrInvalidState = 004, // "Invalid state while working with timestamp"
51-
DpiErrUninitialized = 005, // "Uninitialized state while working with timestamp"
52-
DpiErrExtAuth= 006, // "user and password should not be set when using external authentication"
46+
DpiErrNoError = 0, // "DPI not an error"
47+
DpiErrInternal, // "DPI internal error"
48+
DpiErrUnkOciError, // "Could not get OCI error message"
49+
DpiErrNoEnv, // "No OCI environment handle created"
50+
DpiErrInvalidState, // "Invalid state while working with timestamp"
51+
DpiErrUninitialized, // "Uninitialized state while working with timestamp"
52+
DpiErrExtAuth,
53+
// "user and password should not be set when using external authentication"
54+
DpiOciInvalidHandle,
55+
// "Invalid OCI Handle/Descriptor or invalid parameter for OCI handle/descriptor allocation call"
56+
DpiErrMemAllocFail, // "Memory allocatio failed"
5357
};
5458

5559

5660

57-
/*---------------------------------------------------------------------------
61+
/*----------------------------------------------------------------------------
5862
PUBLIC TYPES
59-
---------------------------------------------------------------------------*/
63+
----------------------------------------------------------------------------*/
6064

6165
class Exception : public exception
6266
{

src/dpi/include/dpiLob.h

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. */
2+
3+
/*******************************************************************************
4+
*
5+
* You may not use the identified files except in compliance with the Apache
6+
* License, Version 2.0 (the "License.")
7+
*
8+
* You may obtain a copy of the License at
9+
* http://www.apache.org/licenses/LICENSE-2.0.
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
*
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* NAME
19+
* dpiLob.h - Lob class interface
20+
*
21+
* DESCRIPTION
22+
* This file defines the interface for the Lob class.
23+
*
24+
* NOTES
25+
* The Lob class methods are static functions providing wrappers over the
26+
* corresponding OCI calls.
27+
*
28+
******************************************************************************/
29+
30+
#ifndef DPILOB_ORACLE
31+
# define DPILOB_ORACLE
32+
33+
34+
#ifndef DPICOMMON_ORACLE
35+
# include <dpiCommon.h>
36+
#endif
37+
38+
39+
namespace dpi
40+
{
41+
42+
/*----------------------------------------------------------------------------
43+
PUBLIC CONSTANTS
44+
----------------------------------------------------------------------------*/
45+
46+
47+
/*----------------------------------------------------------------------------
48+
PUBLIC TYPES
49+
----------------------------------------------------------------------------*/
50+
51+
52+
/*******************************************************************************
53+
* NAME Lob
54+
*
55+
* DESCRIPTION Interface definiton for Lob
56+
*
57+
* METHODS
58+
* read - read the Lob
59+
*
60+
******************************************************************************/
61+
62+
class Lob
63+
{
64+
public:
65+
66+
static void read(DpiHandle *svch, DpiHandle *errh, Descriptor *lobLocator,
67+
unsigned long long &byteAmount,
68+
unsigned long long &charAmount,
69+
unsigned long long offset,
70+
void *buf);
71+
72+
static void write(DpiHandle *svch, DpiHandle *errh, Descriptor *lobLocator,
73+
unsigned long long &byteAmount,
74+
unsigned long long &charAmount,
75+
unsigned long long offset,
76+
void *buf);
77+
78+
static unsigned int chunkSize(DpiHandle *svch, DpiHandle *errh,
79+
Descriptor *lobLocator);
80+
81+
static unsigned long long length(DpiHandle *svch, DpiHandle *errh,
82+
Descriptor *lobLocator);
83+
};
84+
85+
86+
} // namespace dpi
87+
88+
#endif // ifdef DPILOB_ORACLE

src/dpi/include/dpiStmt.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ typedef enum
7777
DpiRaw = 23,
7878
DpiLongRaw = 24,
7979
DpiUnsignedInteger = 68,
80-
DpiRowid = 69, /* internal only */
80+
DpiRowid = 104, /* internal only */
8181
DpiFixedChar = 96,
8282
DpiBinaryFloat = 100, /* internal only */
8383
DpiBinaryDouble = 101, /* internal only */
@@ -110,13 +110,17 @@ typedef enum
110110
#define DPIBINDBYNAME OCIBindByName2
111111
#define DPIDEFINEBYPOS OCIDefineByPos2
112112
#define DPIATTRROWCOUNT OCI_ATTR_UB8_ROW_COUNT
113+
#define DPILOBREAD OCILobRead2
114+
#define DPILOBWRITE OCILobWrite2
113115
#else
114116
#define DPI_SZ_TYPE sb4
115117
#define DPI_BUFLEN_TYPE ub2
116118
#define DPIBINDBYPOS OCIBindByPos
117119
#define DPIBINDBYNAME OCIBindByName
118120
#define DPIDEFINEBYPOS OCIDefineByPos
119121
#define DPIATTRROWCOUNT OCI_ATTR_ROW_COUNT
122+
#define DPILOBREAD OCILobRead
123+
#define DPILOBWRITE OCILobWrite
120124
#endif
121125

122126

@@ -133,7 +137,8 @@ typedef struct
133137

134138

135139
// Application (Driver) level callback function prototype
136-
typedef int (*cbtype) (void *ctx, DPI_SZ_TYPE nRows, unsigned long iter,
140+
typedef int (*cbtype) (void *ctx, DPI_SZ_TYPE nRows, unsigned int bndpos,
141+
unsigned long iter,
137142
unsigned long index, dvoid **bufpp, void **alenp,
138143
dvoid **indpp, unsigned short **rcodepp,
139144
unsigned char *piecep );
@@ -164,6 +169,7 @@ class Stmt
164169
void *data, cbtype cb = NULL ) = 0;
165170

166171
virtual void bind(const unsigned char *name, int nameLen,
172+
unsigned int bndpos,
167173
unsigned short type, void *buf, DPI_SZ_TYPE bufSize,
168174
short *ind, DPI_BUFLEN_TYPE *bufLen,
169175
void *data, cbtype cb = NULL ) = 0;

0 commit comments

Comments
 (0)