oracledb 2.1.0 → 2.3.0

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +174 -54
  2. package/LICENSE.md +52 -18
  3. package/README.md +35 -68
  4. package/binding.gyp +5 -4
  5. package/lib/connection.js +164 -14
  6. package/lib/oracledb.js +160 -11
  7. package/lib/pool.js +33 -22
  8. package/lib/querystream.js +3 -2
  9. package/lib/rel.txt +1 -1
  10. package/odpi/LICENSE.md +1 -1
  11. package/odpi/README.md +25 -84
  12. package/odpi/embed/README.md +1 -1
  13. package/odpi/include/dpi.h +51 -7
  14. package/odpi/src/dpiConn.c +78 -9
  15. package/odpi/src/dpiContext.c +24 -10
  16. package/odpi/src/dpiEnv.c +5 -1
  17. package/odpi/src/dpiError.c +4 -0
  18. package/odpi/src/dpiErrorMessages.h +6 -4
  19. package/odpi/src/dpiImpl.h +125 -68
  20. package/odpi/src/dpiMsgProps.c +33 -0
  21. package/odpi/src/dpiObject.c +17 -10
  22. package/odpi/src/dpiObjectType.c +1 -1
  23. package/odpi/src/dpiOci.c +55 -40
  24. package/odpi/src/dpiOracleType.c +2 -2
  25. package/odpi/src/dpiPool.c +88 -18
  26. package/odpi/src/dpiStmt.c +57 -36
  27. package/odpi/src/dpiSubscr.c +117 -9
  28. package/odpi/src/dpiUtils.c +20 -9
  29. package/odpi/src/dpiVar.c +504 -430
  30. package/package/MAKEPKG.BAT +64 -1
  31. package/package/README.md +9 -5
  32. package/package/createpackage.js +2 -2
  33. package/package/extractpackage.js +2 -1
  34. package/package/oracledbinstall.js +19 -19
  35. package/package/package.json +4 -4
  36. package/package.json +4 -4
  37. package/src/njsCommon.cpp +94 -10
  38. package/src/njsCommon.h +73 -21
  39. package/src/njsConnection.cpp +1425 -458
  40. package/src/njsConnection.h +68 -19
  41. package/src/njsIntLob.cpp +5 -1
  42. package/src/njsIntLob.h +1 -1
  43. package/src/njsMessages.cpp +9 -2
  44. package/src/njsMessages.h +9 -2
  45. package/src/njsOracle.cpp +213 -23
  46. package/src/njsOracle.h +18 -2
  47. package/src/njsPool.cpp +32 -14
  48. package/src/njsPool.h +4 -4
  49. package/src/njsResultSet.cpp +4 -3
  50. package/src/njsResultSet.h +1 -1
  51. package/src/njsSubscription.cpp +388 -0
  52. package/src/njsSubscription.h +111 -0
@@ -92,6 +92,9 @@ extern unsigned long dpiDebugLevel;
92
92
  // define maximum buffer size permitted in variables
93
93
  #define DPI_MAX_VAR_BUFFER_SIZE (1024 * 1024 * 1024 - 2)
94
94
 
95
+ // define subscription grouping repeat count
96
+ #define DPI_SUBSCR_GROUPING_FOREVER -1
97
+
95
98
  // define number of rows to prefetch
96
99
  #define DPI_PREFETCH_ROWS_DEFAULT 2
97
100
 
@@ -129,6 +132,7 @@ extern unsigned long dpiDebugLevel;
129
132
  #define DPI_OCI_DTYPE_AQMSG_PROPERTIES 59
130
133
  #define DPI_OCI_DTYPE_INTERVAL_YM 62
131
134
  #define DPI_OCI_DTYPE_INTERVAL_DS 63
135
+ #define DPI_OCI_DTYPE_AQNFY_DESCRIPTOR 64
132
136
  #define DPI_OCI_DTYPE_TIMESTAMP 68
133
137
  #define DPI_OCI_DTYPE_TIMESTAMP_TZ 69
134
138
  #define DPI_OCI_DTYPE_TIMESTAMP_LTZ 70
@@ -178,6 +182,7 @@ extern unsigned long dpiDebugLevel;
178
182
  #define DPI_OCI_ATTR_ENQ_TIME 62
179
183
  #define DPI_OCI_ATTR_MSG_STATE 63
180
184
  #define DPI_OCI_ATTR_ORIGINAL_MSGID 69
185
+ #define DPI_OCI_ATTR_QUEUE_NAME 70
181
186
  #define DPI_OCI_ATTR_NUM_DML_ERRORS 73
182
187
  #define DPI_OCI_ATTR_DML_ROW_OFFSET 74
183
188
  #define DPI_OCI_ATTR_SUBSCR_NAME 94
@@ -207,6 +212,10 @@ extern unsigned long dpiDebugLevel;
207
212
  #define DPI_OCI_ATTR_SUBSCR_CQ_QOSFLAGS 229
208
213
  #define DPI_OCI_ATTR_LIST_TYPE_ATTRS 229
209
214
  #define DPI_OCI_ATTR_SUBSCR_CQ_REGID 230
215
+ #define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_CLASS 231
216
+ #define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_VALUE 232
217
+ #define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_TYPE 233
218
+ #define DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_REPEAT_COUNT 235
210
219
  #define DPI_OCI_ATTR_NCHARSET_ID 262
211
220
  #define DPI_OCI_ATTR_APPCTX_SIZE 273
212
221
  #define DPI_OCI_ATTR_APPCTX_LIST 274
@@ -229,6 +238,7 @@ extern unsigned long dpiDebugLevel;
229
238
  #define DPI_OCI_ATTR_CHNF_OPERATIONS 403
230
239
  #define DPI_OCI_ATTR_CHDES_DBNAME 405
231
240
  #define DPI_OCI_ATTR_CHDES_NFYTYPE 406
241
+ #define DPI_OCI_ATTR_NFY_FLAGS 406
232
242
  #define DPI_OCI_ATTR_CHDES_XID 407
233
243
  #define DPI_OCI_ATTR_MSG_DELIVERY_MODE 407
234
244
  #define DPI_OCI_ATTR_CHDES_TABLE_CHANGES 408
@@ -246,6 +256,7 @@ extern unsigned long dpiDebugLevel;
246
256
  #define DPI_OCI_ATTR_CONNECTION_CLASS 425
247
257
  #define DPI_OCI_ATTR_PURITY 426
248
258
  #define DPI_OCI_ATTR_RECEIVE_TIMEOUT 436
259
+ #define DPI_OCI_ATTR_SUBSCR_IPADDR 452
249
260
  #define DPI_OCI_ATTR_UB8_ROW_COUNT 457
250
261
  #define DPI_OCI_ATTR_SPOOL_AUTH 460
251
262
  #define DPI_OCI_ATTR_LTXID 462
@@ -257,6 +268,7 @@ extern unsigned long dpiDebugLevel;
257
268
  #define DPI_OCI_ATTR_BREAK_ON_NET_TIMEOUT 495
258
269
  #define DPI_OCI_ATTR_SHARDING_KEY 496
259
270
  #define DPI_OCI_ATTR_SUPER_SHARDING_KEY 497
271
+ #define DPI_OCI_ATTR_SPOOL_WAIT_TIMEOUT 506
260
272
 
261
273
  // define OCI object type constants
262
274
  #define DPI_OCI_OTYPE_NAME 1
@@ -444,7 +456,6 @@ typedef enum {
444
456
  DPI_ERR_TRANS_ID_TOO_LARGE,
445
457
  DPI_ERR_BRANCH_ID_TOO_LARGE,
446
458
  DPI_ERR_COLUMN_FETCH,
447
- DPI_ERR_OCI_VERSION_NOT_SUPPORTED,
448
459
  DPI_ERR_STMT_CLOSED,
449
460
  DPI_ERR_LOB_CLOSED,
450
461
  DPI_ERR_INVALID_CHARSET_ID,
@@ -454,18 +465,21 @@ typedef enum {
454
465
  DPI_ERR_NUMBER_STRING_TOO_LONG,
455
466
  DPI_ERR_NULL_POINTER_PARAMETER,
456
467
  DPI_ERR_LOAD_LIBRARY,
457
- DPI_ERR_UNUSED_1,
458
468
  DPI_ERR_LOAD_SYMBOL,
459
469
  DPI_ERR_LIBRARY_TOO_OLD,
460
- DPI_ERR_OVERFLOW,
461
470
  DPI_ERR_NLS_ENV_VAR_GET,
462
471
  DPI_ERR_PTR_LENGTH_MISMATCH,
463
- DPI_ERR_UNUSED_2,
464
472
  DPI_ERR_NAN,
465
473
  DPI_ERR_WRONG_TYPE,
466
474
  DPI_ERR_BUFFER_SIZE_TOO_LARGE,
467
475
  DPI_ERR_NO_EDITION_WITH_CONN_CLASS,
468
476
  DPI_ERR_NO_BIND_VARS_IN_DDL,
477
+ DPI_ERR_SUBSCR_CLOSED,
478
+ DPI_ERR_NO_EDITION_WITH_NEW_PASSWORD,
479
+ DPI_ERR_UNEXPECTED_OCI_RETURN_VALUE,
480
+ DPI_ERR_EXEC_MODE_ONLY_FOR_DML,
481
+ DPI_ERR_ARRAY_VAR_NOT_SUPPORTED,
482
+ DPI_ERR_EVENTS_MODE_REQUIRED,
469
483
  DPI_ERR_MAX
470
484
  } dpiErrorNum;
471
485
 
@@ -512,7 +526,6 @@ typedef enum {
512
526
  // old type definitions (to be dropped)
513
527
  //-----------------------------------------------------------------------------
514
528
 
515
- // structure used for creating connections (2.0)
516
529
  typedef struct {
517
530
  dpiAuthMode authMode;
518
531
  const char *connectionClass;
@@ -533,6 +546,34 @@ typedef struct {
533
546
  int outTagFound;
534
547
  } dpiConnCreateParams__v20;
535
548
 
549
+ typedef struct {
550
+ dpiSubscrNamespace subscrNamespace;
551
+ dpiSubscrProtocol protocol;
552
+ dpiSubscrQOS qos;
553
+ dpiOpCode operations;
554
+ uint32_t portNumber;
555
+ uint32_t timeout;
556
+ const char *name;
557
+ uint32_t nameLength;
558
+ dpiSubscrCallback callback;
559
+ void *callbackContext;
560
+ const char *recipientName;
561
+ uint32_t recipientNameLength;
562
+ } dpiSubscrCreateParams__v23;
563
+
564
+ typedef struct {
565
+ uint32_t minSessions;
566
+ uint32_t maxSessions;
567
+ uint32_t sessionIncrement;
568
+ int pingInterval;
569
+ int pingTimeout;
570
+ int homogeneous;
571
+ int externalAuth;
572
+ dpiPoolGetMode getMode;
573
+ const char *outPoolName;
574
+ uint32_t outPoolNameLength;
575
+ } dpiPoolCreateParams__v23;
576
+
536
577
 
537
578
  //-----------------------------------------------------------------------------
538
579
  // OCI type definitions
@@ -604,6 +645,7 @@ typedef struct {
604
645
  dpiVersionInfo *versionInfo;
605
646
  void *baseDate;
606
647
  int threaded;
648
+ int events;
607
649
  } dpiEnv;
608
650
 
609
651
  typedef struct {
@@ -661,6 +703,63 @@ typedef struct {
661
703
  uint32_t nameLength;
662
704
  } dpiBindVar;
663
705
 
706
+ typedef union {
707
+ void *asHandle;
708
+ dpiObject *asObject;
709
+ dpiStmt *asStmt;
710
+ dpiLob *asLOB;
711
+ dpiRowid *asRowid;
712
+ } dpiReferenceBuffer;
713
+
714
+ typedef union {
715
+ void *asRaw;
716
+ char *asBytes;
717
+ float *asFloat;
718
+ double *asDouble;
719
+ int64_t *asInt64;
720
+ uint64_t *asUint64;
721
+ dpiOciNumber *asNumber;
722
+ dpiOciDate *asDate;
723
+ void **asTimestamp;
724
+ void **asInterval;
725
+ void **asLobLocator;
726
+ void **asString;
727
+ void **asStmt;
728
+ void **asRowid;
729
+ int *asBoolean;
730
+ void **asObject;
731
+ void **asCollection;
732
+ } dpiOracleData;
733
+
734
+ typedef union {
735
+ int64_t asInt64;
736
+ uint64_t asUint64;
737
+ float asFloat;
738
+ double asDouble;
739
+ dpiOciNumber asNumber;
740
+ dpiOciDate asDate;
741
+ int asBoolean;
742
+ void *asString;
743
+ void *asTimestamp;
744
+ void *asLobLocator;
745
+ void *asRaw;
746
+ } dpiOracleDataBuffer;
747
+
748
+ typedef struct {
749
+ uint32_t maxArraySize;
750
+ uint32_t actualArraySize;
751
+ int16_t *indicator;
752
+ uint16_t *returnCode;
753
+ uint16_t *actualLength16;
754
+ uint32_t *actualLength32;
755
+ void **objectIndicator;
756
+ dpiReferenceBuffer *references;
757
+ dpiDynamicBytes *dynamicBytes;
758
+ char *tempBuffer;
759
+ dpiData *externalData;
760
+ dpiOracleData data;
761
+ } dpiVarBuffer;
762
+
664
763
 
665
764
  //-----------------------------------------------------------------------------
666
765
  // External implementation type definitions
@@ -728,70 +827,18 @@ struct dpiStmt {
728
827
  int closing;
729
828
  };
730
829
 
731
- typedef union {
732
- void *asRaw;
733
- char *asBytes;
734
- float *asFloat;
735
- double *asDouble;
736
- int64_t *asInt64;
737
- uint64_t *asUint64;
738
- dpiOciNumber *asNumber;
739
- dpiOciDate *asDate;
740
- void **asTimestamp;
741
- void **asInterval;
742
- void **asLobLocator;
743
- void **asString;
744
- void **asStmt;
745
- void **asRowid;
746
- int *asBoolean;
747
- void **asObject;
748
- void **asCollection;
749
- } dpiOracleData;
750
-
751
- typedef union {
752
- int64_t asInt64;
753
- uint64_t asUint64;
754
- float asFloat;
755
- double asDouble;
756
- dpiOciNumber asNumber;
757
- dpiOciDate asDate;
758
- int asBoolean;
759
- void *asString;
760
- void *asTimestamp;
761
- void *asLobLocator;
762
- void *asRaw;
763
- } dpiOracleDataBuffer;
764
-
765
- typedef union {
766
- void *asHandle;
767
- dpiObject *asObject;
768
- dpiStmt *asStmt;
769
- dpiLob *asLOB;
770
- dpiRowid *asRowid;
771
- } dpiReferenceBuffer;
772
-
773
830
  struct dpiVar {
774
831
  dpiType_HEAD
775
832
  dpiConn *conn;
776
833
  const dpiOracleType *type;
777
834
  dpiNativeTypeNum nativeTypeNum;
778
- uint32_t maxArraySize;
779
- uint32_t actualArraySize;
780
835
  int requiresPreFetch;
781
836
  int isArray;
782
- int16_t *indicator;
783
- uint16_t *returnCode;
784
- uint16_t *actualLength16;
785
- uint32_t *actualLength32;
786
837
  uint32_t sizeInBytes;
787
838
  int isDynamic;
788
839
  dpiObjectType *objectType;
789
- void **objectIndicator;
790
- dpiReferenceBuffer *references;
791
- dpiDynamicBytes *dynamicBytes;
792
- char *tempBuffer;
793
- dpiData *externalData;
794
- dpiOracleData data;
840
+ dpiVarBuffer buffer;
841
+ dpiVarBuffer *dynBindBuffers;
795
842
  dpiError *error;
796
843
  };
797
844
 
@@ -832,6 +879,8 @@ struct dpiObject {
832
879
  dpiObjectType *type;
833
880
  void *instance;
834
881
  void *indicator;
882
+ dpiObject *dependsOnObj;
883
+ int freeIndicator;
835
884
  };
836
885
 
837
886
  struct dpiRowid {
@@ -845,9 +894,11 @@ struct dpiSubscr {
845
894
  dpiType_HEAD
846
895
  dpiConn *conn;
847
896
  void *handle;
897
+ dpiSubscrNamespace subscrNamespace;
848
898
  dpiSubscrQOS qos;
849
899
  dpiSubscrCallback callback;
850
900
  void *callbackContext;
901
+ int registered;
851
902
  };
852
903
 
853
904
  struct dpiDeqOptions {
@@ -866,6 +917,8 @@ struct dpiMsgProps {
866
917
  dpiType_HEAD
867
918
  dpiConn *conn;
868
919
  void *handle;
920
+ char *buffer;
921
+ uint32_t bufferLength;
869
922
  };
870
923
 
871
924
 
@@ -873,8 +926,7 @@ struct dpiMsgProps {
873
926
  // definition of internal dpiContext methods
874
927
  //-----------------------------------------------------------------------------
875
928
  void dpiContext__initCommonCreateParams(dpiCommonCreateParams *params);
876
- void dpiContext__initConnCreateParams(const dpiContext *context,
877
- dpiConnCreateParams *params, size_t *structSize);
929
+ void dpiContext__initConnCreateParams(dpiConnCreateParams *params);
878
930
  void dpiContext__initPoolCreateParams(dpiPoolCreateParams *params);
879
931
  void dpiContext__initSubscrCreateParams(dpiSubscrCreateParams *params);
880
932
 
@@ -1020,15 +1072,16 @@ int dpiVar__copyData(dpiVar *var, uint32_t pos, dpiData *sourceData,
1020
1072
  int32_t dpiVar__defineCallback(dpiVar *var, void *defnp, uint32_t iter,
1021
1073
  void **bufpp, uint32_t **alenpp, uint8_t *piecep, void **indpp,
1022
1074
  uint16_t **rcodepp);
1023
- int dpiVar__extendedPreFetch(dpiVar *var, dpiError *error);
1075
+ int dpiVar__extendedPreFetch(dpiVar *var, dpiVarBuffer *buffer,
1076
+ dpiError *error);
1024
1077
  void dpiVar__free(dpiVar *var, dpiError *error);
1025
1078
  int32_t dpiVar__inBindCallback(dpiVar *var, void *bindp, uint32_t iter,
1026
1079
  uint32_t index, void **bufpp, uint32_t *alenp, uint8_t *piecep,
1027
1080
  void **indpp);
1028
- int dpiVar__getValue(dpiVar *var, uint32_t pos, dpiData *data,
1029
- dpiError *error);
1030
- int dpiVar__setValue(dpiVar *var, uint32_t pos, dpiData *data,
1031
- dpiError *error);
1081
+ int dpiVar__getValue(dpiVar *var, dpiVarBuffer *buffer, uint32_t pos,
1082
+ int inFetch, dpiError *error);
1083
+ int dpiVar__setValue(dpiVar *var, dpiVarBuffer *buffer, uint32_t pos,
1084
+ dpiData *data, dpiError *error);
1032
1085
  int32_t dpiVar__outBindCallback(dpiVar *var, void *bindp, uint32_t iter,
1033
1086
  uint32_t index, void **bufpp, uint32_t **alenpp, uint8_t *piecep,
1034
1087
  void **indpp, uint16_t **rcodepp);
@@ -1051,7 +1104,8 @@ int dpiLob__setFromBytes(dpiLob *lob, const char *value, uint64_t valueLength,
1051
1104
  // definition of internal dpiObject methods
1052
1105
  //-----------------------------------------------------------------------------
1053
1106
  int dpiObject__allocate(dpiObjectType *objType, void *instance,
1054
- void *indicator, dpiObject **obj, dpiError *error);
1107
+ void *indicator, dpiObject *dependsOnObj, dpiObject **obj,
1108
+ dpiError *error);
1055
1109
  void dpiObject__free(dpiObject *obj, dpiError *error);
1056
1110
 
1057
1111
 
@@ -1310,7 +1364,8 @@ int dpiOci__stringResize(void *envHandle, void **handle, uint32_t newSize,
1310
1364
  int dpiOci__stringSize(void *envHandle, void *handle, uint32_t *size);
1311
1365
  int dpiOci__subscriptionRegister(dpiConn *conn, void **handle,
1312
1366
  dpiError *error);
1313
- int dpiOci__subscriptionUnRegister(dpiSubscr *subscr, dpiError *error);
1367
+ int dpiOci__subscriptionUnRegister(dpiConn *conn, dpiSubscr *subscr,
1368
+ dpiError *error);
1314
1369
  int dpiOci__tableDelete(dpiObject *obj, int32_t index, dpiError *error);
1315
1370
  int dpiOci__tableExists(dpiObject *obj, int32_t index, int *exists,
1316
1371
  dpiError *error);
@@ -1341,6 +1396,8 @@ int dpiOci__typeByFullName(dpiConn *conn, const char *name,
1341
1396
  // definition of internal dpiMsgProps methods
1342
1397
  //-----------------------------------------------------------------------------
1343
1398
  int dpiMsgProps__create(dpiMsgProps *props, dpiConn *conn, dpiError *error);
1399
+ int dpiMsgProps__extractMsgId(dpiMsgProps *props, void *ociRaw,
1400
+ const char **msgId, uint32_t *msgIdLength, dpiError *error);
1344
1401
  void dpiMsgProps__free(dpiMsgProps *props, dpiError *error);
1345
1402
 
1346
1403
 
@@ -30,6 +30,35 @@ int dpiMsgProps__create(dpiMsgProps *options, dpiConn *conn, dpiError *error)
30
30
  }
31
31
 
32
32
 
33
+ //-----------------------------------------------------------------------------
34
+ // dpiMsgProps__extractMsgId() [INTERNAL]
35
+ // Extract bytes from the OCIRaw value containing the message id and store
36
+ // them in allocated memory on the message properties instance. Then resize the
37
+ // OCIRaw value so the memory can be reclaimed.
38
+ //-----------------------------------------------------------------------------
39
+ int dpiMsgProps__extractMsgId(dpiMsgProps *props, void *ociRaw,
40
+ const char **msgId, uint32_t *msgIdLength, dpiError *error)
41
+ {
42
+ const char *rawPtr;
43
+
44
+ dpiOci__rawPtr(props->env->handle, ociRaw, (void**) &rawPtr);
45
+ dpiOci__rawSize(props->env->handle, ociRaw, msgIdLength);
46
+ if (*msgIdLength > props->bufferLength) {
47
+ if (props->buffer) {
48
+ dpiUtils__freeMemory(props->buffer);
49
+ props->buffer = NULL;
50
+ }
51
+ if (dpiUtils__allocateMemory(1, *msgIdLength, 0,
52
+ "allocate msgid buffer", (void**) &props->buffer, error) < 0)
53
+ return DPI_FAILURE;
54
+ }
55
+ memcpy(props->buffer, rawPtr, *msgIdLength);
56
+ *msgId = props->buffer;
57
+ dpiOci__rawResize(props->env->handle, &ociRaw, 0, error);
58
+ return DPI_SUCCESS;
59
+ }
60
+
61
+
33
62
  //-----------------------------------------------------------------------------
34
63
  // dpiMsgProps__free() [INTERNAL]
35
64
  // Free the memory for a message properties structure.
@@ -44,6 +73,10 @@ void dpiMsgProps__free(dpiMsgProps *props, dpiError *error)
44
73
  dpiGen__setRefCount(props->conn, error, -1);
45
74
  props->conn = NULL;
46
75
  }
76
+ if (props->buffer) {
77
+ dpiUtils__freeMemory(props->buffer);
78
+ props->buffer = NULL;
79
+ }
47
80
  dpiUtils__freeMemory(props);
48
81
  }
49
82
 
@@ -21,7 +21,8 @@
21
21
  // Allocate and initialize an object structure.
22
22
  //-----------------------------------------------------------------------------
23
23
  int dpiObject__allocate(dpiObjectType *objType, void *instance,
24
- void *indicator, dpiObject **obj, dpiError *error)
24
+ void *indicator, dpiObject *dependsOnObj, dpiObject **obj,
25
+ dpiError *error)
25
26
  {
26
27
  dpiObject *tempObj;
27
28
 
@@ -32,6 +33,10 @@ int dpiObject__allocate(dpiObjectType *objType, void *instance,
32
33
  tempObj->type = objType;
33
34
  tempObj->instance = instance;
34
35
  tempObj->indicator = indicator;
36
+ if (dependsOnObj) {
37
+ dpiGen__setRefCount(dependsOnObj, error, 1);
38
+ tempObj->dependsOnObj = dependsOnObj;
39
+ }
35
40
  if (!instance) {
36
41
  if (dpiOci__objectNew(tempObj, error) < 0) {
37
42
  dpiObject__free(tempObj, error);
@@ -73,7 +78,9 @@ static void dpiObject__clearOracleValue(dpiEnv *env, dpiError *error,
73
78
  {
74
79
  switch (oracleTypeNum) {
75
80
  case DPI_ORACLE_TYPE_CHAR:
81
+ case DPI_ORACLE_TYPE_NCHAR:
76
82
  case DPI_ORACLE_TYPE_VARCHAR:
83
+ case DPI_ORACLE_TYPE_NVARCHAR:
77
84
  if (buffer->asString)
78
85
  dpiOci__stringResize(env->handle, &buffer->asString, 0, error);
79
86
  break;
@@ -105,7 +112,8 @@ static void dpiObject__clearOracleValue(dpiEnv *env, dpiError *error,
105
112
  void dpiObject__free(dpiObject *obj, dpiError *error)
106
113
  {
107
114
  if (obj->instance) {
108
- dpiOci__objectFree(obj, error);
115
+ if (!obj->dependsOnObj)
116
+ dpiOci__objectFree(obj, error);
109
117
  obj->instance = NULL;
110
118
  obj->indicator = NULL;
111
119
  }
@@ -113,6 +121,10 @@ void dpiObject__free(dpiObject *obj, dpiError *error)
113
121
  dpiGen__setRefCount(obj->type, error, -1);
114
122
  obj->type = NULL;
115
123
  }
124
+ if (obj->dependsOnObj) {
125
+ dpiGen__setRefCount(obj->dependsOnObj, error, -1);
126
+ obj->dependsOnObj = NULL;
127
+ }
116
128
  dpiUtils__freeMemory(obj);
117
129
  }
118
130
 
@@ -209,14 +221,9 @@ static int dpiObject__fromOracleValue(dpiObject *obj, dpiError *error,
209
221
  void *instance = (typeInfo->objectType->isCollection) ?
210
222
  *value->asCollection : value->asRaw;
211
223
  dpiObject *tempObj;
212
- if (dpiObject__allocate(typeInfo->objectType, NULL, NULL,
213
- &tempObj, error) < 0)
214
- return DPI_FAILURE;
215
- if (dpiOci__objectCopy(tempObj, instance, indicator,
216
- error) < 0) {
217
- dpiObject__free(tempObj, error);
224
+ if (dpiObject__allocate(typeInfo->objectType, instance,
225
+ indicator, obj, &tempObj, error) < 0)
218
226
  return DPI_FAILURE;
219
- }
220
227
  data->value.asObject = tempObj;
221
228
  return DPI_SUCCESS;
222
229
  }
@@ -457,7 +464,7 @@ int dpiObject_copy(dpiObject *obj, dpiObject **copiedObj)
457
464
  if (dpiGen__startPublicFn(obj, DPI_HTYPE_OBJECT, __func__, 1, &error) < 0)
458
465
  return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
459
466
  DPI_CHECK_PTR_NOT_NULL(obj, copiedObj)
460
- if (dpiObject__allocate(obj->type, NULL, NULL, &tempObj, &error) < 0)
467
+ if (dpiObject__allocate(obj->type, NULL, NULL, NULL, &tempObj, &error) < 0)
461
468
  return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
462
469
  if (dpiOci__objectCopy(tempObj, obj->instance, obj->indicator,
463
470
  &error) < 0) {
@@ -202,7 +202,7 @@ int dpiObjectType_createObject(dpiObjectType *objType, dpiObject **obj)
202
202
  &error) < 0)
203
203
  return dpiGen__endPublicFn(objType, DPI_FAILURE, &error);
204
204
  DPI_CHECK_PTR_NOT_NULL(objType, obj)
205
- status = dpiObject__allocate(objType, NULL, NULL, obj, &error);
205
+ status = dpiObject__allocate(objType, NULL, NULL, NULL, obj, &error);
206
206
  return dpiGen__endPublicFn(objType, status, &error);
207
207
  }
208
208
 
package/odpi/src/dpiOci.c CHANGED
@@ -640,14 +640,15 @@ int dpiOci__bindByName(dpiStmt *stmt, void **bindHandle, const char *name,
640
640
  DPI_OCI_LOAD_SYMBOL("OCIBindByName", dpiOciSymbols.fnBindByName)
641
641
  status = (*dpiOciSymbols.fnBindByName)(stmt->handle, bindHandle,
642
642
  error->handle, name, nameLength,
643
- (dynamicBind) ? NULL : var->data.asRaw,
643
+ (dynamicBind) ? NULL : var->buffer.data.asRaw,
644
644
  (var->isDynamic) ? INT_MAX : (int32_t) var->sizeInBytes,
645
- var->type->oracleType, (dynamicBind) ? NULL : var->indicator,
645
+ var->type->oracleType, (dynamicBind) ? NULL :
646
+ var->buffer.indicator,
646
647
  (dynamicBind || var->type->sizeInBytes) ? NULL :
647
- var->actualLength16,
648
- (dynamicBind) ? NULL : var->returnCode,
649
- (var->isArray) ? var->maxArraySize : 0,
650
- (var->isArray) ? &var->actualArraySize : NULL,
648
+ var->buffer.actualLength16,
649
+ (dynamicBind) ? NULL : var->buffer.returnCode,
650
+ (var->isArray) ? var->buffer.maxArraySize : 0,
651
+ (var->isArray) ? &var->buffer.actualArraySize : NULL,
651
652
  (dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
652
653
  return dpiError__check(error, status, stmt->conn, "bind by name");
653
654
  }
@@ -665,14 +666,15 @@ int dpiOci__bindByName2(dpiStmt *stmt, void **bindHandle, const char *name,
665
666
  DPI_OCI_LOAD_SYMBOL("OCIBindByName2", dpiOciSymbols.fnBindByName2)
666
667
  status = (*dpiOciSymbols.fnBindByName2)(stmt->handle, bindHandle,
667
668
  error->handle, name, nameLength,
668
- (dynamicBind) ? NULL : var->data.asRaw,
669
+ (dynamicBind) ? NULL : var->buffer.data.asRaw,
669
670
  (var->isDynamic) ? INT_MAX : var->sizeInBytes,
670
- var->type->oracleType, (dynamicBind) ? NULL : var->indicator,
671
+ var->type->oracleType, (dynamicBind) ? NULL :
672
+ var->buffer.indicator,
671
673
  (dynamicBind || var->type->sizeInBytes) ? NULL :
672
- var->actualLength32,
673
- (dynamicBind) ? NULL : var->returnCode,
674
- (var->isArray) ? var->maxArraySize : 0,
675
- (var->isArray) ? &var->actualArraySize : NULL,
674
+ var->buffer.actualLength32,
675
+ (dynamicBind) ? NULL : var->buffer.returnCode,
676
+ (var->isArray) ? var->buffer.maxArraySize : 0,
677
+ (var->isArray) ? &var->buffer.actualArraySize : NULL,
676
678
  (dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
677
679
  return dpiError__check(error, status, stmt->conn, "bind by name");
678
680
  }
@@ -689,14 +691,15 @@ int dpiOci__bindByPos(dpiStmt *stmt, void **bindHandle, uint32_t pos,
689
691
 
690
692
  DPI_OCI_LOAD_SYMBOL("OCIBindByPos", dpiOciSymbols.fnBindByPos)
691
693
  status = (*dpiOciSymbols.fnBindByPos)(stmt->handle, bindHandle,
692
- error->handle, pos, (dynamicBind) ? NULL : var->data.asRaw,
694
+ error->handle, pos, (dynamicBind) ? NULL : var->buffer.data.asRaw,
693
695
  (var->isDynamic) ? INT_MAX : (int32_t) var->sizeInBytes,
694
- var->type->oracleType, (dynamicBind) ? NULL : var->indicator,
696
+ var->type->oracleType, (dynamicBind) ? NULL :
697
+ var->buffer.indicator,
695
698
  (dynamicBind || var->type->sizeInBytes) ? NULL :
696
- var->actualLength16,
697
- (dynamicBind) ? NULL : var->returnCode,
698
- (var->isArray) ? var->maxArraySize : 0,
699
- (var->isArray) ? &var->actualArraySize : NULL,
699
+ var->buffer.actualLength16,
700
+ (dynamicBind) ? NULL : var->buffer.returnCode,
701
+ (var->isArray) ? var->buffer.maxArraySize : 0,
702
+ (var->isArray) ? &var->buffer.actualArraySize : NULL,
700
703
  (dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
701
704
  return dpiError__check(error, status, stmt->conn, "bind by position");
702
705
  }
@@ -713,14 +716,15 @@ int dpiOci__bindByPos2(dpiStmt *stmt, void **bindHandle, uint32_t pos,
713
716
 
714
717
  DPI_OCI_LOAD_SYMBOL("OCIBindByPos2", dpiOciSymbols.fnBindByPos2)
715
718
  status = (*dpiOciSymbols.fnBindByPos2)(stmt->handle, bindHandle,
716
- error->handle, pos, (dynamicBind) ? NULL : var->data.asRaw,
719
+ error->handle, pos, (dynamicBind) ? NULL : var->buffer.data.asRaw,
717
720
  (var->isDynamic) ? INT_MAX : var->sizeInBytes,
718
- var->type->oracleType, (dynamicBind) ? NULL : var->indicator,
721
+ var->type->oracleType, (dynamicBind) ? NULL :
722
+ var->buffer.indicator,
719
723
  (dynamicBind || var->type->sizeInBytes) ? NULL :
720
- var->actualLength32,
721
- (dynamicBind) ? NULL : var->returnCode,
722
- (var->isArray) ? var->maxArraySize : 0,
723
- (var->isArray) ? &var->actualArraySize : NULL,
724
+ var->buffer.actualLength32,
725
+ (dynamicBind) ? NULL : var->buffer.returnCode,
726
+ (var->isArray) ? var->buffer.maxArraySize : 0,
727
+ (var->isArray) ? &var->buffer.actualArraySize : NULL,
724
728
  (dynamicBind) ? DPI_OCI_DATA_AT_EXEC : DPI_OCI_DEFAULT);
725
729
  return dpiError__check(error, status, stmt->conn, "bind by position");
726
730
  }
@@ -752,8 +756,8 @@ int dpiOci__bindObject(dpiVar *var, void *bindHandle, dpiError *error)
752
756
 
753
757
  DPI_OCI_LOAD_SYMBOL("OCIBindObject", dpiOciSymbols.fnBindObject)
754
758
  status = (*dpiOciSymbols.fnBindObject)(bindHandle, error->handle,
755
- var->objectType->tdo, (void**) var->data.asRaw, 0,
756
- var->objectIndicator, 0);
759
+ var->objectType->tdo, (void**) var->buffer.data.asRaw, 0,
760
+ var->buffer.objectIndicator, 0);
757
761
  return dpiError__check(error, status, var->conn, "bind object");
758
762
  }
759
763
 
@@ -1044,11 +1048,13 @@ int dpiOci__defineByPos(dpiStmt *stmt, void **defineHandle, uint32_t pos,
1044
1048
 
1045
1049
  DPI_OCI_LOAD_SYMBOL("OCIDefineByPos", dpiOciSymbols.fnDefineByPos)
1046
1050
  status = (*dpiOciSymbols.fnDefineByPos)(stmt->handle, defineHandle,
1047
- error->handle, pos, (var->isDynamic) ? NULL : var->data.asRaw,
1051
+ error->handle, pos, (var->isDynamic) ? NULL :
1052
+ var->buffer.data.asRaw,
1048
1053
  (var->isDynamic) ? INT_MAX : (int32_t) var->sizeInBytes,
1049
- var->type->oracleType, (var->isDynamic) ? NULL : var->indicator,
1050
- (var->isDynamic) ? NULL : var->actualLength16,
1051
- (var->isDynamic) ? NULL : var->returnCode,
1054
+ var->type->oracleType, (var->isDynamic) ? NULL :
1055
+ var->buffer.indicator,
1056
+ (var->isDynamic) ? NULL : var->buffer.actualLength16,
1057
+ (var->isDynamic) ? NULL : var->buffer.returnCode,
1052
1058
  (var->isDynamic) ? DPI_OCI_DYNAMIC_FETCH : DPI_OCI_DEFAULT);
1053
1059
  return dpiError__check(error, status, stmt->conn, "define");
1054
1060
  }
@@ -1065,11 +1071,13 @@ int dpiOci__defineByPos2(dpiStmt *stmt, void **defineHandle, uint32_t pos,
1065
1071
 
1066
1072
  DPI_OCI_LOAD_SYMBOL("OCIDefineByPos2", dpiOciSymbols.fnDefineByPos2)
1067
1073
  status = (*dpiOciSymbols.fnDefineByPos2)(stmt->handle, defineHandle,
1068
- error->handle, pos, (var->isDynamic) ? NULL : var->data.asRaw,
1074
+ error->handle, pos, (var->isDynamic) ? NULL :
1075
+ var->buffer.data.asRaw,
1069
1076
  (var->isDynamic) ? INT_MAX : var->sizeInBytes,
1070
- var->type->oracleType, (var->isDynamic) ? NULL : var->indicator,
1071
- (var->isDynamic) ? NULL : var->actualLength32,
1072
- (var->isDynamic) ? NULL : var->returnCode,
1077
+ var->type->oracleType, (var->isDynamic) ? NULL :
1078
+ var->buffer.indicator,
1079
+ (var->isDynamic) ? NULL : var->buffer.actualLength32,
1080
+ (var->isDynamic) ? NULL : var->buffer.returnCode,
1073
1081
  (var->isDynamic) ? DPI_OCI_DYNAMIC_FETCH : DPI_OCI_DEFAULT);
1074
1082
  return dpiError__check(error, status, stmt->conn, "define");
1075
1083
  }
@@ -1100,8 +1108,8 @@ int dpiOci__defineObject(dpiVar *var, void *defineHandle, dpiError *error)
1100
1108
 
1101
1109
  DPI_OCI_LOAD_SYMBOL("OCIDefineObject", dpiOciSymbols.fnDefineObject)
1102
1110
  status = (*dpiOciSymbols.fnDefineObject)(defineHandle, error->handle,
1103
- var->objectType->tdo, (void**) var->data.asRaw, 0,
1104
- var->objectIndicator, 0);
1111
+ var->objectType->tdo, (void**) var->buffer.data.asRaw, 0,
1112
+ var->buffer.objectIndicator, 0);
1105
1113
  return dpiError__check(error, status, var->conn, "define object");
1106
1114
  }
1107
1115
 
@@ -1598,7 +1606,10 @@ static int dpiOci__loadLib(dpiError *error)
1598
1606
  static int dpiOci__loadLibValidate(dpiError *error)
1599
1607
  {
1600
1608
  // determine the OCI client version information
1601
- DPI_OCI_LOAD_SYMBOL("OCIClientVersion", dpiOciSymbols.fnClientVersion)
1609
+ if (dpiOci__loadSymbol("OCIClientVersion",
1610
+ (void**) &dpiOciSymbols.fnClientVersion, NULL) < 0)
1611
+ return dpiError__set(error, "get client version",
1612
+ DPI_ERR_LIBRARY_TOO_OLD);
1602
1613
  (*dpiOciSymbols.fnClientVersion)(&dpiOciLibVersionInfo.versionNum,
1603
1614
  &dpiOciLibVersionInfo.releaseNum,
1604
1615
  &dpiOciLibVersionInfo.updateNum,
@@ -2150,6 +2161,9 @@ int dpiOci__objectFree(dpiObject *obj, dpiError *error)
2150
2161
  DPI_OCI_LOAD_SYMBOL("OCIObjectFree", dpiOciSymbols.fnObjectFree)
2151
2162
  (*dpiOciSymbols.fnObjectFree)(obj->env->handle, error->handle,
2152
2163
  obj->instance, DPI_OCI_DEFAULT);
2164
+ if (obj->freeIndicator)
2165
+ (*dpiOciSymbols.fnObjectFree)(obj->env->handle, error->handle,
2166
+ obj->indicator, DPI_OCI_DEFAULT);
2153
2167
  return DPI_SUCCESS;
2154
2168
  }
2155
2169
 
@@ -2778,15 +2792,16 @@ int dpiOci__subscriptionRegister(dpiConn *conn, void **handle, dpiError *error)
2778
2792
  // dpiOci__subscriptionUnRegister() [INTERNAL]
2779
2793
  // Wrapper for OCISubscriptionUnRegister().
2780
2794
  //-----------------------------------------------------------------------------
2781
- int dpiOci__subscriptionUnRegister(dpiSubscr *subscr, dpiError *error)
2795
+ int dpiOci__subscriptionUnRegister(dpiConn *conn, dpiSubscr *subscr,
2796
+ dpiError *error)
2782
2797
  {
2783
2798
  int status;
2784
2799
 
2785
2800
  DPI_OCI_LOAD_SYMBOL("OCISubscriptionUnRegister",
2786
2801
  dpiOciSymbols.fnSubscriptionUnRegister)
2787
- status = (*dpiOciSymbols.fnSubscriptionUnRegister)(subscr->conn->handle,
2802
+ status = (*dpiOciSymbols.fnSubscriptionUnRegister)(conn->handle,
2788
2803
  subscr->handle, error->handle, DPI_OCI_DEFAULT);
2789
- return dpiError__check(error, status, subscr->conn, "unregister");
2804
+ return dpiError__check(error, status, conn, "unregister");
2790
2805
  }
2791
2806
 
2792
2807