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.
Files changed (112) hide show
  1. package/CHANGELOG.md +135 -8
  2. package/README.md +6 -4
  3. package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
  4. package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
  5. package/build/Release/oracledb-abi48-linux-x64.node +0 -0
  6. package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
  7. package/build/Release/oracledb-abi48-win32-x64.node +0 -0
  8. package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
  9. package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
  10. package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
  11. package/build/Release/oracledb-abi57-linux-x64.node +0 -0
  12. package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
  13. package/build/Release/oracledb-abi57-win32-x64.node +0 -0
  14. package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
  15. package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
  16. package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
  17. package/build/Release/oracledb-abi64-linux-x64.node +0 -0
  18. package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
  19. package/build/Release/oracledb-abi64-win32-x64.node +0 -0
  20. package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
  21. package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
  22. package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
  23. package/build/Release/oracledb-abi67-linux-x64.node +0 -0
  24. package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
  25. package/build/Release/oracledb-abi67-win32-x64.node +0 -0
  26. package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
  27. package/lib/connection.js +18 -4
  28. package/lib/oracledb.js +44 -92
  29. package/lib/pool.js +36 -2
  30. package/lib/sodaCollection.js +1 -1
  31. package/lib/sodaDatabase.js +1 -1
  32. package/lib/util.js +82 -5
  33. package/package/README.md +32 -101
  34. package/package/install.js +139 -0
  35. package/package/prunebinaries.js +51 -0
  36. package/package.json +4 -11
  37. package/binding.gyp +0 -162
  38. package/lib/rel.txt +0 -1
  39. package/odpi/.npmignore +0 -4
  40. package/odpi/LICENSE.md +0 -218
  41. package/odpi/README.md +0 -61
  42. package/odpi/embed/README.md +0 -4
  43. package/odpi/embed/dpi.c +0 -50
  44. package/odpi/include/dpi.h +0 -1748
  45. package/odpi/src/dpiConn.c +0 -2089
  46. package/odpi/src/dpiContext.c +0 -296
  47. package/odpi/src/dpiData.c +0 -797
  48. package/odpi/src/dpiDebug.c +0 -184
  49. package/odpi/src/dpiDeqOptions.c +0 -370
  50. package/odpi/src/dpiEnqOptions.c +0 -174
  51. package/odpi/src/dpiEnv.c +0 -189
  52. package/odpi/src/dpiError.c +0 -204
  53. package/odpi/src/dpiErrorMessages.h +0 -86
  54. package/odpi/src/dpiGen.c +0 -303
  55. package/odpi/src/dpiGlobal.c +0 -292
  56. package/odpi/src/dpiHandleList.c +0 -117
  57. package/odpi/src/dpiHandlePool.c +0 -118
  58. package/odpi/src/dpiImpl.h +0 -1707
  59. package/odpi/src/dpiLob.c +0 -506
  60. package/odpi/src/dpiMsgProps.c +0 -386
  61. package/odpi/src/dpiObject.c +0 -897
  62. package/odpi/src/dpiObjectAttr.c +0 -115
  63. package/odpi/src/dpiObjectType.c +0 -326
  64. package/odpi/src/dpiOci.c +0 -3527
  65. package/odpi/src/dpiOracleType.c +0 -492
  66. package/odpi/src/dpiPool.c +0 -549
  67. package/odpi/src/dpiRowid.c +0 -136
  68. package/odpi/src/dpiSodaColl.c +0 -685
  69. package/odpi/src/dpiSodaCollCursor.c +0 -143
  70. package/odpi/src/dpiSodaDb.c +0 -432
  71. package/odpi/src/dpiSodaDoc.c +0 -230
  72. package/odpi/src/dpiSodaDocCursor.c +0 -143
  73. package/odpi/src/dpiStmt.c +0 -1797
  74. package/odpi/src/dpiSubscr.c +0 -674
  75. package/odpi/src/dpiUtils.c +0 -410
  76. package/odpi/src/dpiVar.c +0 -1794
  77. package/package/MAKEPKG.BAT +0 -156
  78. package/package/Makefile +0 -85
  79. package/package/createpackage.js +0 -186
  80. package/package/extractpackage.js +0 -76
  81. package/package/getversion.js +0 -37
  82. package/package/oracledbinstall.js +0 -497
  83. package/package/package.json +0 -54
  84. package/package/util.js +0 -286
  85. package/src/njsCommon.cpp +0 -1055
  86. package/src/njsCommon.h +0 -484
  87. package/src/njsConnection.cpp +0 -2926
  88. package/src/njsConnection.h +0 -227
  89. package/src/njsIntLob.cpp +0 -618
  90. package/src/njsIntLob.h +0 -179
  91. package/src/njsMessages.cpp +0 -122
  92. package/src/njsMessages.h +0 -118
  93. package/src/njsOracle.cpp +0 -1274
  94. package/src/njsOracle.h +0 -237
  95. package/src/njsPool.cpp +0 -482
  96. package/src/njsPool.h +0 -132
  97. package/src/njsResultSet.cpp +0 -478
  98. package/src/njsResultSet.h +0 -120
  99. package/src/njsSodaCollection.cpp +0 -507
  100. package/src/njsSodaCollection.h +0 -128
  101. package/src/njsSodaDatabase.cpp +0 -335
  102. package/src/njsSodaDatabase.h +0 -108
  103. package/src/njsSodaDocCursor.cpp +0 -203
  104. package/src/njsSodaDocCursor.h +0 -94
  105. package/src/njsSodaDocument.cpp +0 -412
  106. package/src/njsSodaDocument.h +0 -105
  107. package/src/njsSodaOperation.cpp +0 -557
  108. package/src/njsSodaOperation.h +0 -123
  109. package/src/njsSubscription.cpp +0 -388
  110. package/src/njsSubscription.h +0 -111
  111. package/src/njsUtils.cpp +0 -158
  112. package/src/njsUtils.h +0 -68
@@ -1,674 +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
- // dpiSubscr.c
14
- // Implementation of subscriptions (CQN).
15
- //-----------------------------------------------------------------------------
16
-
17
- #include "dpiImpl.h"
18
-
19
- // forward declarations of internal functions only used in this file
20
- static void dpiSubscr__freeMessage(dpiSubscrMessage *message);
21
- static int dpiSubscr__populateMessage(dpiSubscr *subscr,
22
- dpiSubscrMessage *message, void *descriptor, dpiError *error);
23
- static int dpiSubscr__populateMessageTable(dpiSubscr *subscr,
24
- dpiSubscrMessageTable *table, void *descriptor, dpiError *error);
25
- static int dpiSubscr__populateQueryChangeMessage(dpiSubscr *subscr,
26
- dpiSubscrMessage *message, void *descriptor, dpiError *error);
27
-
28
-
29
- //-----------------------------------------------------------------------------
30
- // dpiSubscr__callback() [INTERNAL]
31
- // Callback that is used to execute the callback registered when the
32
- // subscription was created.
33
- //-----------------------------------------------------------------------------
34
- static void dpiSubscr__callback(dpiSubscr *subscr, UNUSED void *handle,
35
- UNUSED void *payload, UNUSED uint32_t payloadLength, void *descriptor,
36
- UNUSED uint32_t mode)
37
- {
38
- dpiSubscrMessage message;
39
- dpiErrorInfo errorInfo;
40
- dpiError error;
41
-
42
- // ensure that the subscription handle is still valid
43
- if (dpiGen__startPublicFn(subscr, DPI_HTYPE_SUBSCR, __func__, 1,
44
- &error) < 0)
45
- dpiGen__endPublicFn(subscr, DPI_FAILURE, &error);
46
-
47
- // populate message
48
- memset(&message, 0, sizeof(message));
49
- if (dpiSubscr__populateMessage(subscr, &message, descriptor, &error) < 0) {
50
- dpiError__getInfo(&error, &errorInfo);
51
- message.errorInfo = &errorInfo;
52
- }
53
- message.registered = subscr->registered;
54
-
55
- // invoke user callback
56
- (*subscr->callback)(subscr->callbackContext, &message);
57
-
58
- // clean up message
59
- dpiSubscr__freeMessage(&message);
60
- dpiGen__endPublicFn(subscr, DPI_SUCCESS, &error);
61
- }
62
-
63
-
64
- //-----------------------------------------------------------------------------
65
- // dpiSubscr__check() [INTERNAL]
66
- // Determine if the subscription is open and available for use.
67
- //-----------------------------------------------------------------------------
68
- static int dpiSubscr__check(dpiSubscr *subscr, const char *fnName,
69
- dpiError *error)
70
- {
71
- if (dpiGen__startPublicFn(subscr, DPI_HTYPE_SUBSCR, fnName, 1, error) < 0)
72
- return DPI_FAILURE;
73
- if (!subscr->handle)
74
- return dpiError__set(error, "check closed", DPI_ERR_SUBSCR_CLOSED);
75
- return dpiConn__checkConnected(subscr->conn, error);
76
- }
77
-
78
-
79
- //-----------------------------------------------------------------------------
80
- // dpiSubscr__create() [INTERNAL]
81
- // Create a new subscription structure and return it. In case of error NULL
82
- // is returned.
83
- //-----------------------------------------------------------------------------
84
- int dpiSubscr__create(dpiSubscr *subscr, dpiConn *conn,
85
- dpiSubscrCreateParams *params, dpiError *error)
86
- {
87
- uint32_t qosFlags;
88
- int32_t int32Val;
89
- int rowids;
90
-
91
- // retain a reference to the connection
92
- dpiGen__setRefCount(conn, error, 1);
93
- subscr->conn = conn;
94
- subscr->callback = params->callback;
95
- subscr->callbackContext = params->callbackContext;
96
- subscr->subscrNamespace = params->subscrNamespace;
97
- subscr->qos = params->qos;
98
-
99
- // create the subscription handle
100
- if (dpiOci__handleAlloc(conn->env->handle, &subscr->handle,
101
- DPI_OCI_HTYPE_SUBSCRIPTION, "create subscr handle", error) < 0)
102
- return DPI_FAILURE;
103
-
104
- // set the namespace
105
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
106
- (void*) &params->subscrNamespace, sizeof(uint32_t),
107
- DPI_OCI_ATTR_SUBSCR_NAMESPACE, "set namespace", error) < 0)
108
- return DPI_FAILURE;
109
-
110
- // set the protocol
111
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
112
- (void*) &params->protocol, sizeof(uint32_t),
113
- DPI_OCI_ATTR_SUBSCR_RECPTPROTO, "set protocol", error) < 0)
114
- return DPI_FAILURE;
115
-
116
- // set the timeout
117
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
118
- (void*) &params->timeout, sizeof(uint32_t),
119
- DPI_OCI_ATTR_SUBSCR_TIMEOUT, "set timeout", error) < 0)
120
- return DPI_FAILURE;
121
-
122
- // set the IP address used on the client to listen for events
123
- if (params->ipAddress && params->ipAddressLength > 0 &&
124
- dpiOci__attrSet(subscr->env->handle, DPI_OCI_HTYPE_ENV,
125
- (void*) params->ipAddress, params->ipAddressLength,
126
- DPI_OCI_ATTR_SUBSCR_IPADDR, "set IP address", error) < 0)
127
- return DPI_FAILURE;
128
-
129
- // set the port number used on the client to listen for events
130
- if (params->portNumber > 0 && dpiOci__attrSet(subscr->env->handle,
131
- DPI_OCI_HTYPE_ENV, (void*) &params->portNumber, 0,
132
- DPI_OCI_ATTR_SUBSCR_PORTNO, "set port number", error) < 0)
133
- return DPI_FAILURE;
134
-
135
- // set the context for the callback
136
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
137
- (void*) subscr, 0, DPI_OCI_ATTR_SUBSCR_CTX, "set callback context",
138
- error) < 0)
139
- return DPI_FAILURE;
140
-
141
- // set the callback, if applicable
142
- if (params->callback && dpiOci__attrSet(subscr->handle,
143
- DPI_OCI_HTYPE_SUBSCRIPTION, (void*) dpiSubscr__callback, 0,
144
- DPI_OCI_ATTR_SUBSCR_CALLBACK, "set callback", error) < 0)
145
- return DPI_FAILURE;
146
-
147
- // set the subscription name, if applicable
148
- if (params->name && params->nameLength > 0 &&
149
- dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
150
- (void*) params->name, params->nameLength,
151
- DPI_OCI_ATTR_SUBSCR_NAME, "set name", error) < 0)
152
- return DPI_FAILURE;
153
-
154
- // set QOS flags
155
- qosFlags = 0;
156
- if (params->qos & DPI_SUBSCR_QOS_RELIABLE)
157
- qosFlags |= DPI_OCI_SUBSCR_QOS_RELIABLE;
158
- if (params->qos & DPI_SUBSCR_QOS_DEREG_NFY)
159
- qosFlags |= DPI_OCI_SUBSCR_QOS_PURGE_ON_NTFN;
160
- if (qosFlags && dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
161
- (void*) &qosFlags, sizeof(uint32_t), DPI_OCI_ATTR_SUBSCR_QOSFLAGS,
162
- "set QOS", error) < 0)
163
- return DPI_FAILURE;
164
-
165
- // set CQ specific QOS flags
166
- qosFlags = 0;
167
- if (params->qos & DPI_SUBSCR_QOS_QUERY)
168
- qosFlags |= DPI_OCI_SUBSCR_CQ_QOS_QUERY;
169
- if (params->qos & DPI_SUBSCR_QOS_BEST_EFFORT)
170
- qosFlags |= DPI_OCI_SUBSCR_CQ_QOS_BEST_EFFORT;
171
- if (qosFlags && dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
172
- (void*) &qosFlags, sizeof(uint32_t),
173
- DPI_OCI_ATTR_SUBSCR_CQ_QOSFLAGS, "set CQ QOS", error) < 0)
174
- return DPI_FAILURE;
175
-
176
- // set rowids flag, if applicable
177
- if (params->qos & DPI_SUBSCR_QOS_ROWIDS) {
178
- rowids = 1;
179
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
180
- (void*) &rowids, 0, DPI_OCI_ATTR_CHNF_ROWIDS,
181
- "set rowids flag", error) < 0)
182
- return DPI_FAILURE;
183
- }
184
-
185
- // set which operations are desired, if applicable
186
- if (params->operations && dpiOci__attrSet(subscr->handle,
187
- DPI_OCI_HTYPE_SUBSCRIPTION, (void*) &params->operations, 0,
188
- DPI_OCI_ATTR_CHNF_OPERATIONS, "set operations", error) < 0)
189
- return DPI_FAILURE;
190
-
191
- // set grouping information, if applicable
192
- if (params->groupingClass) {
193
-
194
- // set grouping class
195
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
196
- (void*) &params->groupingClass, 0,
197
- DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_CLASS, "set grouping class",
198
- error) < 0)
199
- return DPI_FAILURE;
200
-
201
- // set grouping value
202
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
203
- (void*) &params->groupingValue, 0,
204
- DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_VALUE, "set grouping value",
205
- error) < 0)
206
- return DPI_FAILURE;
207
-
208
- // set grouping type
209
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
210
- (void*) &params->groupingType, 0,
211
- DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_TYPE, "set grouping type",
212
- error) < 0)
213
- return DPI_FAILURE;
214
-
215
- // set grouping repeat count
216
- int32Val = DPI_SUBSCR_GROUPING_FOREVER;
217
- if (dpiOci__attrSet(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION,
218
- (void*) &int32Val, 0,
219
- DPI_OCI_ATTR_SUBSCR_NTFN_GROUPING_REPEAT_COUNT,
220
- "set grouping repeat count", error) < 0)
221
- return DPI_FAILURE;
222
-
223
- }
224
-
225
- // register the subscription
226
- if (dpiOci__subscriptionRegister(conn, &subscr->handle, error) < 0)
227
- return DPI_FAILURE;
228
- subscr->registered = 1;
229
-
230
- return DPI_SUCCESS;
231
- }
232
-
233
-
234
- //-----------------------------------------------------------------------------
235
- // dpiSubscr__free() [INTERNAL]
236
- // Free the memory and any resources associated with the subscription.
237
- //-----------------------------------------------------------------------------
238
- void dpiSubscr__free(dpiSubscr *subscr, dpiError *error)
239
- {
240
- if (subscr->handle) {
241
- if (subscr->registered)
242
- dpiOci__subscriptionUnRegister(subscr->conn, subscr, error);
243
- dpiOci__handleFree(subscr->handle, DPI_OCI_HTYPE_SUBSCRIPTION);
244
- subscr->handle = NULL;
245
- }
246
- if (subscr->conn) {
247
- dpiGen__setRefCount(subscr->conn, error, -1);
248
- subscr->conn = NULL;
249
- }
250
- dpiUtils__freeMemory(subscr);
251
- }
252
-
253
-
254
- //-----------------------------------------------------------------------------
255
- // dpiSubscr__freeMessage() [INTERNAL]
256
- // Free memory associated with the message.
257
- //-----------------------------------------------------------------------------
258
- static void dpiSubscr__freeMessage(dpiSubscrMessage *message)
259
- {
260
- dpiSubscrMessageQuery *query;
261
- uint32_t i, j;
262
-
263
- // free the tables for the message
264
- if (message->numTables > 0) {
265
- for (i = 0; i < message->numTables; i++) {
266
- if (message->tables[i].numRows > 0)
267
- dpiUtils__freeMemory(message->tables[i].rows);
268
- }
269
- dpiUtils__freeMemory(message->tables);
270
- }
271
-
272
- // free the queries for the message
273
- if (message->numQueries > 0) {
274
- for (i = 0; i < message->numQueries; i++) {
275
- query = &message->queries[i];
276
- if (query->numTables > 0) {
277
- for (j = 0; j < query->numTables; j++) {
278
- if (query->tables[i].numRows > 0)
279
- dpiUtils__freeMemory(query->tables[i].rows);
280
- }
281
- dpiUtils__freeMemory(query->tables);
282
- }
283
- }
284
- dpiUtils__freeMemory(message->queries);
285
- }
286
- }
287
-
288
-
289
- //-----------------------------------------------------------------------------
290
- // dpiSubscr__populateAQMessage() [INTERNAL]
291
- // Populate message with details.
292
- //-----------------------------------------------------------------------------
293
- static int dpiSubscr__populateAQMessage(dpiSubscr *subscr,
294
- dpiSubscrMessage *message, void *descriptor, dpiError *error)
295
- {
296
- uint32_t flags = 0;
297
-
298
- // determine if message is a deregistration message
299
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_AQNFY_DESCRIPTOR, &flags,
300
- NULL, DPI_OCI_ATTR_NFY_FLAGS, "get flags", error) < 0)
301
- return DPI_FAILURE;
302
- message->eventType = (flags == 1) ? DPI_EVENT_DEREG : DPI_EVENT_AQ;
303
- if (message->eventType == DPI_EVENT_DEREG) {
304
- subscr->registered = 0;
305
- return DPI_SUCCESS;
306
- }
307
-
308
- // determine the name of the queue which spawned the event
309
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_AQNFY_DESCRIPTOR,
310
- (void*) &message->queueName, &message->queueNameLength,
311
- DPI_OCI_ATTR_QUEUE_NAME, "get queue name", error) < 0)
312
- return DPI_FAILURE;
313
-
314
- // determine the consumer name for the queue that spawned the event
315
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_AQNFY_DESCRIPTOR,
316
- (void*) &message->consumerName, &message->consumerNameLength,
317
- DPI_OCI_ATTR_CONSUMER_NAME, "get consumer name", error) < 0)
318
- return DPI_FAILURE;
319
-
320
- return DPI_SUCCESS;
321
- }
322
-
323
-
324
- //-----------------------------------------------------------------------------
325
- // dpiSubscr__populateObjectChangeMessage() [INTERNAL]
326
- // Populate object change message with details.
327
- //-----------------------------------------------------------------------------
328
- static int dpiSubscr__populateObjectChangeMessage(dpiSubscr *subscr,
329
- dpiSubscrMessage *message, void *descriptor, dpiError *error)
330
- {
331
- void **tableDescriptor, *indicator;
332
- int32_t numTables;
333
- void *tables;
334
- uint32_t i;
335
- int exists;
336
-
337
- // determine table collection
338
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CHDES, &tables, 0,
339
- DPI_OCI_ATTR_CHDES_TABLE_CHANGES, "get tables", error) < 0)
340
- return DPI_FAILURE;
341
- if (!tables)
342
- return DPI_SUCCESS;
343
-
344
- // determine number of tables
345
- if (dpiOci__collSize(subscr->conn, tables, &numTables, error) < 0)
346
- return DPI_FAILURE;
347
-
348
- // allocate memory for table entries
349
- if (dpiUtils__allocateMemory((size_t) numTables,
350
- sizeof(dpiSubscrMessageTable), 1, "allocate msg tables",
351
- (void**) &message->tables, error) < 0)
352
- return DPI_FAILURE;
353
- message->numTables = (uint32_t) numTables;
354
-
355
- // populate message table entries
356
- for (i = 0; i < message->numTables; i++) {
357
- if (dpiOci__collGetElem(subscr->conn, tables, (int32_t) i, &exists,
358
- (void**) &tableDescriptor, &indicator, error) < 0)
359
- return DPI_FAILURE;
360
- if (dpiSubscr__populateMessageTable(subscr, &message->tables[i],
361
- *tableDescriptor, error) < 0)
362
- return DPI_FAILURE;
363
- }
364
-
365
- return DPI_SUCCESS;
366
- }
367
-
368
-
369
- //-----------------------------------------------------------------------------
370
- // dpiSubscr__populateMessage() [INTERNAL]
371
- // Populate message with details.
372
- //-----------------------------------------------------------------------------
373
- static int dpiSubscr__populateMessage(dpiSubscr *subscr,
374
- dpiSubscrMessage *message, void *descriptor, dpiError *error)
375
- {
376
- void *rawValue;
377
-
378
- // if quality of service flag indicates that deregistration should take
379
- // place when the first notification is received, mark the subscription
380
- // as no longer registered
381
- if (subscr->qos & DPI_SUBSCR_QOS_DEREG_NFY)
382
- subscr->registered = 0;
383
-
384
- // handle AQ messages, if applicable
385
- if (subscr->subscrNamespace == DPI_SUBSCR_NAMESPACE_AQ)
386
- return dpiSubscr__populateAQMessage(subscr, message, descriptor,
387
- error);
388
-
389
- // determine the type of event that was spawned
390
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CHDES, &message->eventType,
391
- NULL, DPI_OCI_ATTR_CHDES_NFYTYPE, "get event type", error) < 0)
392
- return DPI_FAILURE;
393
-
394
- // determine the name of the database which spawned the event
395
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CHDES,
396
- (void*) &message->dbName, &message->dbNameLength,
397
- DPI_OCI_ATTR_CHDES_DBNAME, "get DB name", error) < 0)
398
- return DPI_FAILURE;
399
-
400
- // determine the id of the transaction which spawned the event
401
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CHDES, &rawValue, NULL,
402
- DPI_OCI_ATTR_CHDES_XID, "get transaction id", error) < 0)
403
- return DPI_FAILURE;
404
- dpiOci__rawPtr(subscr->env->handle, rawValue, (void**) &message->txId);
405
- dpiOci__rawSize(subscr->env->handle, rawValue, &message->txIdLength);
406
-
407
- // populate event specific attributes
408
- switch (message->eventType) {
409
- case DPI_EVENT_OBJCHANGE:
410
- return dpiSubscr__populateObjectChangeMessage(subscr, message,
411
- descriptor, error);
412
- case DPI_EVENT_QUERYCHANGE:
413
- return dpiSubscr__populateQueryChangeMessage(subscr, message,
414
- descriptor, error);
415
- case DPI_EVENT_DEREG:
416
- subscr->registered = 0;
417
- break;
418
- default:
419
- return dpiError__set(error, "event type", DPI_ERR_NOT_SUPPORTED);
420
- }
421
-
422
- return DPI_SUCCESS;
423
- }
424
-
425
-
426
- //-----------------------------------------------------------------------------
427
- // dpiSubscr__populateMessageQuery() [INTERNAL]
428
- // Populate a message query structure from the OCI descriptor.
429
- //-----------------------------------------------------------------------------
430
- static int dpiSubscr__populateMessageQuery(dpiSubscr *subscr,
431
- dpiSubscrMessageQuery *query, void *descriptor, dpiError *error)
432
- {
433
- void **tableDescriptor, *indicator, *tables;
434
- int32_t numTables;
435
- uint32_t i;
436
- int exists;
437
-
438
- // determine query id
439
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CQDES, &query->id, 0,
440
- DPI_OCI_ATTR_CQDES_QUERYID, "get id", error) < 0)
441
- return DPI_FAILURE;
442
-
443
- // determine operation
444
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CQDES, &query->operation, 0,
445
- DPI_OCI_ATTR_CQDES_OPERATION, "get operation", error) < 0)
446
- return DPI_FAILURE;
447
-
448
- // determine table collection
449
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CQDES, &tables, 0,
450
- DPI_OCI_ATTR_CQDES_TABLE_CHANGES, "get table descriptor",
451
- error) < 0)
452
- return DPI_FAILURE;
453
- if (!tables)
454
- return DPI_SUCCESS;
455
-
456
- // determine number of tables
457
- if (dpiOci__collSize(subscr->conn, tables, &numTables, error) < 0)
458
- return DPI_FAILURE;
459
-
460
- // allocate memory for table entries
461
- if (dpiUtils__allocateMemory((size_t) numTables,
462
- sizeof(dpiSubscrMessageTable), 1, "allocate query tables",
463
- (void**) &query->tables, error) < 0)
464
- return DPI_FAILURE;
465
- query->numTables = (uint32_t) numTables;
466
-
467
- // populate message table entries
468
- for (i = 0; i < query->numTables; i++) {
469
- if (dpiOci__collGetElem(subscr->conn, tables, (int32_t) i, &exists,
470
- (void**) &tableDescriptor, &indicator, error) < 0)
471
- return DPI_FAILURE;
472
- if (dpiSubscr__populateMessageTable(subscr, &query->tables[i],
473
- *tableDescriptor, error) < 0)
474
- return DPI_FAILURE;
475
- }
476
-
477
- return DPI_SUCCESS;
478
- }
479
-
480
-
481
- //-----------------------------------------------------------------------------
482
- // dpiSubscr__populateMessageRow() [INTERNAL]
483
- // Populate a message row structure from the OCI descriptor.
484
- //-----------------------------------------------------------------------------
485
- static int dpiSubscr__populateMessageRow(dpiSubscrMessageRow *row,
486
- void *descriptor, dpiError *error)
487
- {
488
- // determine operation
489
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_ROW_CHDES, &row->operation,
490
- 0, DPI_OCI_ATTR_CHDES_ROW_OPFLAGS, "get operation", error) < 0)
491
- return DPI_FAILURE;
492
-
493
- // determine rowid
494
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_ROW_CHDES,
495
- (void*) &row->rowid, &row->rowidLength,
496
- DPI_OCI_ATTR_CHDES_ROW_ROWID, "get rowid", error) < 0)
497
- return DPI_FAILURE;
498
-
499
- return DPI_SUCCESS;
500
- }
501
-
502
-
503
- //-----------------------------------------------------------------------------
504
- // dpiSubscr__populateMessageTable() [INTERNAL]
505
- // Populate a message table structure from the OCI descriptor.
506
- //-----------------------------------------------------------------------------
507
- static int dpiSubscr__populateMessageTable(dpiSubscr *subscr,
508
- dpiSubscrMessageTable *table, void *descriptor, dpiError *error)
509
- {
510
- void **rowDescriptor, *indicator, *rows;
511
- int32_t numRows;
512
- int exists;
513
- uint32_t i;
514
-
515
- // determine operation
516
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_TABLE_CHDES,
517
- &table->operation, 0, DPI_OCI_ATTR_CHDES_TABLE_OPFLAGS,
518
- "get operation", error) < 0)
519
- return DPI_FAILURE;
520
-
521
- // determine table name
522
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_TABLE_CHDES,
523
- (void*) &table->name, &table->nameLength,
524
- DPI_OCI_ATTR_CHDES_TABLE_NAME, "get table name", error) < 0)
525
- return DPI_FAILURE;
526
-
527
- // if change invalidated all rows, nothing to do
528
- if (table->operation & DPI_OPCODE_ALL_ROWS)
529
- return DPI_SUCCESS;
530
-
531
- // determine rows collection
532
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_TABLE_CHDES, &rows, 0,
533
- DPI_OCI_ATTR_CHDES_TABLE_ROW_CHANGES, "get rows descriptor",
534
- error) < 0)
535
- return DPI_FAILURE;
536
-
537
- // determine number of rows in collection
538
- if (dpiOci__collSize(subscr->conn, rows, &numRows, error) < 0)
539
- return DPI_FAILURE;
540
-
541
- // allocate memory for row entries
542
- if (dpiUtils__allocateMemory((size_t) numRows, sizeof(dpiSubscrMessageRow),
543
- 1, "allocate rows", (void**) &table->rows, error) < 0)
544
- return DPI_FAILURE;
545
- table->numRows = (uint32_t) numRows;
546
-
547
- // populate the rows attribute
548
- for (i = 0; i < table->numRows; i++) {
549
- if (dpiOci__collGetElem(subscr->conn, rows, (int32_t) i, &exists,
550
- (void**) &rowDescriptor, &indicator, error) < 0)
551
- return DPI_FAILURE;
552
- if (dpiSubscr__populateMessageRow(&table->rows[i], *rowDescriptor,
553
- error) < 0)
554
- return DPI_FAILURE;
555
- }
556
-
557
- return DPI_SUCCESS;
558
- }
559
-
560
-
561
- //-----------------------------------------------------------------------------
562
- // dpiSubscr__populateQueryChangeMessage() [INTERNAL]
563
- // Populate query change message with details.
564
- //-----------------------------------------------------------------------------
565
- static int dpiSubscr__populateQueryChangeMessage(dpiSubscr *subscr,
566
- dpiSubscrMessage *message, void *descriptor, dpiError *error)
567
- {
568
- void **queryDescriptor, *indicator, *queries;
569
- int32_t numQueries;
570
- int exists;
571
- uint32_t i;
572
-
573
- // determine query collection
574
- if (dpiOci__attrGet(descriptor, DPI_OCI_DTYPE_CHDES, &queries, 0,
575
- DPI_OCI_ATTR_CHDES_QUERIES, "get queries", error) < 0)
576
- return DPI_FAILURE;
577
- if (!queries)
578
- return DPI_SUCCESS;
579
-
580
- // determine number of queries
581
- if (dpiOci__collSize(subscr->conn, queries, &numQueries, error) < 0)
582
- return DPI_FAILURE;
583
-
584
- // allocate memory for query entries
585
- if (dpiUtils__allocateMemory((size_t) numQueries,
586
- sizeof(dpiSubscrMessageQuery), 1, "allocate queries",
587
- (void**) &message->queries, error) < 0)
588
- return DPI_FAILURE;
589
- message->numQueries = (uint32_t) numQueries;
590
-
591
- // populate each entry with a message query instance
592
- for (i = 0; i < message->numQueries; i++) {
593
- if (dpiOci__collGetElem(subscr->conn, queries, (int32_t) i, &exists,
594
- (void**) &queryDescriptor, &indicator, error) < 0)
595
- return DPI_FAILURE;
596
- if (dpiSubscr__populateMessageQuery(subscr, &message->queries[i],
597
- *queryDescriptor, error) < 0)
598
- return DPI_FAILURE;
599
- }
600
-
601
- return DPI_SUCCESS;
602
- }
603
-
604
-
605
- //-----------------------------------------------------------------------------
606
- // dpiSubscr__prepareStmt() [INTERNAL]
607
- // Internal method for preparing statement against a subscription. This
608
- // allows for normal error processing without having to worry about freeing the
609
- // statement for every error that might take place.
610
- //-----------------------------------------------------------------------------
611
- static int dpiSubscr__prepareStmt(dpiSubscr *subscr, dpiStmt *stmt,
612
- const char *sql, uint32_t sqlLength, dpiError *error)
613
- {
614
- // prepare statement for execution
615
- if (dpiStmt__prepare(stmt, sql, sqlLength, NULL, 0, error) < 0)
616
- return DPI_FAILURE;
617
-
618
- // fetch array size is set to 1 in order to avoid over allocation since
619
- // the query is not really going to be used for fetching rows, just for
620
- // registration
621
- stmt->fetchArraySize = 1;
622
-
623
- // set subscription handle
624
- return dpiOci__attrSet(stmt->handle, DPI_OCI_HTYPE_STMT, subscr->handle, 0,
625
- DPI_OCI_ATTR_CHNF_REGHANDLE, "set subscription handle", error);
626
- }
627
-
628
-
629
- //-----------------------------------------------------------------------------
630
- // dpiSubscr_addRef() [PUBLIC]
631
- // Add a reference to the subscription.
632
- //-----------------------------------------------------------------------------
633
- int dpiSubscr_addRef(dpiSubscr *subscr)
634
- {
635
- return dpiGen__addRef(subscr, DPI_HTYPE_SUBSCR, __func__);
636
- }
637
-
638
-
639
- //-----------------------------------------------------------------------------
640
- // dpiSubscr_prepareStmt() [PUBLIC]
641
- // Prepare statement for registration with subscription.
642
- //-----------------------------------------------------------------------------
643
- int dpiSubscr_prepareStmt(dpiSubscr *subscr, const char *sql,
644
- uint32_t sqlLength, dpiStmt **stmt)
645
- {
646
- dpiStmt *tempStmt;
647
- dpiError error;
648
-
649
- if (dpiSubscr__check(subscr, __func__, &error) < 0)
650
- return dpiGen__endPublicFn(subscr, DPI_FAILURE, &error);
651
- DPI_CHECK_PTR_NOT_NULL(subscr, sql)
652
- DPI_CHECK_PTR_NOT_NULL(subscr, stmt)
653
- if (dpiStmt__allocate(subscr->conn, 0, &tempStmt, &error) < 0)
654
- return dpiGen__endPublicFn(subscr, DPI_FAILURE, &error);
655
- if (dpiSubscr__prepareStmt(subscr, tempStmt, sql, sqlLength,
656
- &error) < 0) {
657
- dpiStmt__free(tempStmt, &error);
658
- return dpiGen__endPublicFn(subscr, DPI_FAILURE, &error);
659
- }
660
-
661
- *stmt = tempStmt;
662
- return dpiGen__endPublicFn(subscr, DPI_SUCCESS, &error);
663
- }
664
-
665
-
666
- //-----------------------------------------------------------------------------
667
- // dpiSubscr_release() [PUBLIC]
668
- // Release a reference to the subscription.
669
- //-----------------------------------------------------------------------------
670
- int dpiSubscr_release(dpiSubscr *subscr)
671
- {
672
- return dpiGen__release(subscr, DPI_HTYPE_SUBSCR, __func__);
673
- }
674
-