@zowe/db2-for-zowe-cli 6.1.17 → 6.1.18

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 (232) hide show
  1. package/README.md +12 -10
  2. package/lib/Db2PluginLifeCycle.d.ts +11 -9
  3. package/lib/Db2PluginLifeCycle.js +18 -13
  4. package/lib/Db2PluginLifeCycle.js.map +1 -1
  5. package/node_modules/axios/CHANGELOG.md +62 -0
  6. package/node_modules/axios/README.md +233 -5
  7. package/node_modules/axios/dist/axios.js +387 -89
  8. package/node_modules/axios/dist/axios.min.js +3 -3
  9. package/node_modules/axios/dist/axios.min.js.map +1 -1
  10. package/node_modules/axios/dist/browser/axios.cjs +458 -98
  11. package/node_modules/axios/dist/esm/axios.js +458 -98
  12. package/node_modules/axios/dist/esm/axios.min.js +2 -2
  13. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  14. package/node_modules/axios/dist/node/axios.cjs +568 -116
  15. package/node_modules/axios/index.d.cts +4 -0
  16. package/node_modules/axios/index.d.ts +4 -0
  17. package/node_modules/axios/lib/adapters/fetch.js +64 -11
  18. package/node_modules/axios/lib/adapters/http.js +134 -50
  19. package/node_modules/axios/lib/adapters/xhr.js +52 -3
  20. package/node_modules/axios/lib/core/Axios.js +19 -14
  21. package/node_modules/axios/lib/core/InterceptorManager.js +107 -8
  22. package/node_modules/axios/lib/core/buildFullPath.js +1 -13
  23. package/node_modules/axios/lib/core/dispatchRequest.js +8 -2
  24. package/node_modules/axios/lib/core/mergeConfig.js +1 -1
  25. package/node_modules/axios/lib/core/methodList.js +17 -0
  26. package/node_modules/axios/lib/defaults/index.js +2 -1
  27. package/node_modules/axios/lib/env/data.js +1 -1
  28. package/node_modules/axios/lib/helpers/Http2Sessions.js +2 -0
  29. package/node_modules/axios/lib/helpers/HttpStatusCode.js +11 -1
  30. package/node_modules/axios/lib/helpers/fromDataURI.js +5 -4
  31. package/node_modules/axios/lib/helpers/normalizeURLForProtocolCheck.js +24 -0
  32. package/node_modules/axios/lib/helpers/progressEventReducer.js +1 -1
  33. package/node_modules/axios/lib/helpers/resolveConfig.js +4 -2
  34. package/node_modules/axios/lib/helpers/shouldBypassProxy.js +182 -6
  35. package/node_modules/axios/lib/helpers/throttle.js +3 -2
  36. package/node_modules/axios/lib/helpers/toFormData.js +14 -21
  37. package/node_modules/axios/lib/utils.js +134 -13
  38. package/node_modules/axios/package.json +1 -1
  39. package/node_modules/ibm_db/APIDocumentation.md +2883 -2024
  40. package/node_modules/ibm_db/LICENSE +23 -23
  41. package/node_modules/ibm_db/README.md +735 -735
  42. package/node_modules/ibm_db/binding.gyp +99 -98
  43. package/node_modules/ibm_db/installer/driverInstall.js +984 -958
  44. package/node_modules/ibm_db/installer/ifx.sh +38 -38
  45. package/node_modules/ibm_db/installer/setenv.sh +23 -23
  46. package/node_modules/ibm_db/installer/testODBCConnection.bat +51 -51
  47. package/node_modules/ibm_db/installer/testODBCConnection.sh +61 -61
  48. package/node_modules/ibm_db/lib/climacros.js +431 -431
  49. package/node_modules/ibm_db/lib/odbc.js +4293 -3487
  50. package/node_modules/ibm_db/lib/simple-queue.js +41 -41
  51. package/node_modules/ibm_db/package.json +70 -70
  52. package/node_modules/ibm_db/src/odbc.cpp +1495 -1396
  53. package/node_modules/ibm_db/src/odbc.h +477 -473
  54. package/node_modules/ibm_db/src/odbc_connection.cpp +1762 -1612
  55. package/node_modules/ibm_db/src/odbc_connection.h +228 -215
  56. package/node_modules/ibm_db/src/odbc_result.cpp +1547 -1547
  57. package/node_modules/ibm_db/src/odbc_result.h +152 -152
  58. package/node_modules/ibm_db/src/odbc_statement.cpp +2047 -861
  59. package/node_modules/ibm_db/src/odbc_statement.h +257 -135
  60. package/node_modules/ibm_db/src/strptime.c +389 -389
  61. package/node_modules/ibm_db/src/strptime.h +46 -46
  62. package/node_modules/ibm_db/test/README +23 -23
  63. package/node_modules/ibm_db/test/bench-insert.js +62 -62
  64. package/node_modules/ibm_db/test/bench-insertBatch10.js +74 -74
  65. package/node_modules/ibm_db/test/bench-insertBatch100.js +75 -75
  66. package/node_modules/ibm_db/test/bench-insertBatch1000.js +75 -75
  67. package/node_modules/ibm_db/test/bench-insertBatch10000.js +75 -75
  68. package/node_modules/ibm_db/test/bench-prepare-bind-execute-closeSync.js +60 -60
  69. package/node_modules/ibm_db/test/bench-prepare-bind-executeNonQuery.js +53 -53
  70. package/node_modules/ibm_db/test/bench-prepare-bindSync-execute-closeSync.js +50 -50
  71. package/node_modules/ibm_db/test/bench-prepare-bindSync-executeNonQuery.js +48 -48
  72. package/node_modules/ibm_db/test/bench-prepare-execute-closeSync.js +51 -51
  73. package/node_modules/ibm_db/test/bench-prepare-executeNonQuery.js +47 -47
  74. package/node_modules/ibm_db/test/bench-prepare-not.js +43 -43
  75. package/node_modules/ibm_db/test/bench-query-fetch.js +59 -59
  76. package/node_modules/ibm_db/test/bench-query-fetchAll.js +49 -49
  77. package/node_modules/ibm_db/test/bench-query-fetchAllSync.js +43 -43
  78. package/node_modules/ibm_db/test/bench-query.js +40 -40
  79. package/node_modules/ibm_db/test/bench-querySync-fetchArray.js +28 -28
  80. package/node_modules/ibm_db/test/bench-querySync.js +29 -29
  81. package/node_modules/ibm_db/test/common.d.ts +10 -10
  82. package/node_modules/ibm_db/test/common.js +127 -127
  83. package/node_modules/ibm_db/test/config.json +7 -7
  84. package/node_modules/ibm_db/test/config.zos.json +4 -4
  85. package/node_modules/ibm_db/test/data/sample1.txt +9 -9
  86. package/node_modules/ibm_db/test/data/trc.fmt +30114 -30114
  87. package/node_modules/ibm_db/test/nodeEE-leak-huge-query.js +152 -152
  88. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-multiple-connections.js +148 -148
  89. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query-pool-connections.js +154 -154
  90. package/node_modules/ibm_db/test/nodeEE-leak-multiple-query.js +133 -133
  91. package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall-multiple-connections.js +174 -174
  92. package/node_modules/ibm_db/test/nodeEE-stress-async-waterfall.js +169 -169
  93. package/node_modules/ibm_db/test/nodeEE-stress-mixed-query-multiple-connections.js +159 -159
  94. package/node_modules/ibm_db/test/nodeEE-stress-mixed-query.js +148 -148
  95. package/node_modules/ibm_db/test/odbc-bench.c +123 -123
  96. package/node_modules/ibm_db/test/perfTest.js +53 -53
  97. package/node_modules/ibm_db/test/quick-example.sh +30 -30
  98. package/node_modules/ibm_db/test/quick-example.ts +80 -80
  99. package/node_modules/ibm_db/test/run-bench.js +96 -96
  100. package/node_modules/ibm_db/test/run-nodeEE.js +132 -132
  101. package/node_modules/ibm_db/test/run-tests.js +132 -138
  102. package/node_modules/ibm_db/test/sql-cli.js +28 -28
  103. package/node_modules/ibm_db/test/test-all-data-types.js +109 -109
  104. package/node_modules/ibm_db/test/test-array-insert.js +178 -178
  105. package/node_modules/ibm_db/test/test-async-await.js +105 -105
  106. package/node_modules/ibm_db/test/test-attributes.js +34 -34
  107. package/node_modules/ibm_db/test/test-bad-pool-connection-prepare-execute.js +57 -57
  108. package/node_modules/ibm_db/test/test-basic-test.js +138 -138
  109. package/node_modules/ibm_db/test/test-binary-array-insert.js +73 -73
  110. package/node_modules/ibm_db/test/test-blob-from-file.js +90 -90
  111. package/node_modules/ibm_db/test/test-blob-insert.js +144 -144
  112. package/node_modules/ibm_db/test/test-blob-stream-insert.js +321 -299
  113. package/node_modules/ibm_db/test/test-blob-to-file.js +370 -370
  114. package/node_modules/ibm_db/test/test-block-fetch.js +364 -364
  115. package/node_modules/ibm_db/test/test-blocking-issue210.js +123 -123
  116. package/node_modules/ibm_db/test/test-call-async.js +64 -64
  117. package/node_modules/ibm_db/test/test-call-stmt.js +53 -53
  118. package/node_modules/ibm_db/test/test-cancel.js +703 -0
  119. package/node_modules/ibm_db/test/test-chinese-char.js +59 -59
  120. package/node_modules/ibm_db/test/test-connection.js +306 -0
  121. package/node_modules/ibm_db/test/test-date.js +32 -32
  122. package/node_modules/ibm_db/test/test-dbclob.js +93 -93
  123. package/node_modules/ibm_db/test/test-decimals.js +135 -135
  124. package/node_modules/ibm_db/test/test-describe-metadata.js +148 -0
  125. package/node_modules/ibm_db/test/test-executeFile.js +167 -167
  126. package/node_modules/ibm_db/test/test-executeFileSync.js +85 -85
  127. package/node_modules/ibm_db/test/test-fetch-apis.js +146 -146
  128. package/node_modules/ibm_db/test/test-fetchN.js +130 -130
  129. package/node_modules/ibm_db/test/test-getinfo.js +197 -197
  130. package/node_modules/ibm_db/test/test-ibm-db-issue14.js +58 -58
  131. package/node_modules/ibm_db/test/test-ibm-db-issue17.js +54 -54
  132. package/node_modules/ibm_db/test/test-ibm-db-issue18.js +54 -54
  133. package/node_modules/ibm_db/test/test-issue-1059-fetchAll-undefined.js +67 -67
  134. package/node_modules/ibm_db/test/test-issue-1080-array-blob-insert.js +40 -0
  135. package/node_modules/ibm_db/test/test-issue-54.js +39 -39
  136. package/node_modules/ibm_db/test/test-issue-get-column-value-2.js +44 -44
  137. package/node_modules/ibm_db/test/test-issue211.js +80 -80
  138. package/node_modules/ibm_db/test/test-issue253.js +39 -39
  139. package/node_modules/ibm_db/test/test-max-pool-size.js +96 -96
  140. package/node_modules/ibm_db/test/test-memory-leaks-new-objects.js +32 -32
  141. package/node_modules/ibm_db/test/test-multi-open-query-close.js +75 -75
  142. package/node_modules/ibm_db/test/test-param-put-data.js +713 -0
  143. package/node_modules/ibm_db/test/test-pool-idle-connection.js +72 -72
  144. package/node_modules/ibm_db/test/test-pool-operations.js +325 -0
  145. package/node_modules/ibm_db/test/test-pool-stale-connections.js +111 -111
  146. package/node_modules/ibm_db/test/test-pool-uncommited.js +33 -33
  147. package/node_modules/ibm_db/test/test-prepare-execute.js +339 -0
  148. package/node_modules/ibm_db/test/test-prepareSync-multiple-execution.js +93 -93
  149. package/node_modules/ibm_db/test/test-primary-foreign-keys.js +246 -0
  150. package/node_modules/ibm_db/test/test-procedures.js +243 -0
  151. package/node_modules/ibm_db/test/test-promise-all-data-types.js +42 -42
  152. package/node_modules/ibm_db/test/test-query-operations.js +405 -0
  153. package/node_modules/ibm_db/test/test-quick-example.js +25 -25
  154. package/node_modules/ibm_db/test/test-row-array-insert.js +167 -167
  155. package/node_modules/ibm_db/test/test-sp-array.js +54 -54
  156. package/node_modules/ibm_db/test/test-sp-dbc-6000.js +88 -88
  157. package/node_modules/ibm_db/test/test-sp-memleak.js +136 -136
  158. package/node_modules/ibm_db/test/test-sp-resultset-execute.js +269 -269
  159. package/node_modules/ibm_db/test/test-sp-resultset.js +228 -228
  160. package/node_modules/ibm_db/test/test-transactions.js +261 -0
  161. package/node_modules/ibm_db/test/test-typescript.js +48 -48
  162. package/node_modules/ibm_db/test/test-xml-datatype.js +70 -70
  163. package/node_modules/ibm_db/test/testWebApp.js +56 -56
  164. package/node_modules/ibm_db/test/trace +51 -51
  165. package/node_modules/ibm_db/test/typescript-apis-test.js +978 -978
  166. package/node_modules/ibm_db/test/webapp.html +17 -17
  167. package/node_modules/ibm_db/test/webapp.js +79 -79
  168. package/node_modules/ibm_db/typescript/README.md +28 -28
  169. package/node_modules/ibm_db/typescript/dist/Database.d.ts +26 -0
  170. package/node_modules/ibm_db/typescript/dist/ODBCStatement.d.ts +93 -0
  171. package/package.json +10 -6
  172. package/node_modules/ibm_db/test/disabled/test-binding-statement-rebinding.js +0 -59
  173. package/node_modules/ibm_db/test/disabled/test-open-dont-close.js +0 -12
  174. package/node_modules/ibm_db/test/disabled/test-param-select-with-booleans-only.js +0 -21
  175. package/node_modules/ibm_db/test/disabled/test-param-select-with-decimals-only.js +0 -20
  176. package/node_modules/ibm_db/test/disabled/test-param-select-with-null.js +0 -21
  177. package/node_modules/ibm_db/test/disabled/test-param-select-with-nulls-mixed.js +0 -23
  178. package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-mixed.js +0 -22
  179. package/node_modules/ibm_db/test/disabled/test-param-select-with-numbers-only.js +0 -24
  180. package/node_modules/ibm_db/test/disabled/test-param-select-with-strings-only.js +0 -23
  181. package/node_modules/ibm_db/test/disabled/test-param-select-with-unicode.js +0 -15
  182. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-closeSync.js +0 -62
  183. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-error.js +0 -49
  184. package/node_modules/ibm_db/test/disabled/test-prepare-bind-execute-long-string.js +0 -63
  185. package/node_modules/ibm_db/test/disabled/test-prepare-bind-executeNonQuery.js +0 -63
  186. package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-execute-closeSync.js +0 -46
  187. package/node_modules/ibm_db/test/disabled/test-prepare-bindSync-executeNonQuery.js +0 -50
  188. package/node_modules/ibm_db/test/disabled/test-prepare.js +0 -34
  189. package/node_modules/ibm_db/test/disabled/test-prepareSync.js +0 -29
  190. package/node_modules/ibm_db/test/disabled/test-query-select-fetchAll.js +0 -23
  191. package/node_modules/ibm_db/test/disabled/test-query-select-fetchAllSync.js +0 -23
  192. package/node_modules/ibm_db/test/disabled/test-query-select-unicode.js +0 -15
  193. package/node_modules/ibm_db/test/disabled/test-querySync-select-unicode.js +0 -20
  194. package/node_modules/ibm_db/test/test-affected-rows.js +0 -55
  195. package/node_modules/ibm_db/test/test-bad-connection-string.js +0 -30
  196. package/node_modules/ibm_db/test/test-binding-connection-timeOut.js +0 -31
  197. package/node_modules/ibm_db/test/test-binding-statement-executeSync.js +0 -84
  198. package/node_modules/ibm_db/test/test-binding-transaction-commit.js +0 -79
  199. package/node_modules/ibm_db/test/test-binding-transaction-commitSync.js +0 -53
  200. package/node_modules/ibm_db/test/test-closed.js +0 -14
  201. package/node_modules/ibm_db/test/test-connection-object.js +0 -16
  202. package/node_modules/ibm_db/test/test-describe-column.js +0 -92
  203. package/node_modules/ibm_db/test/test-describe-database.js +0 -18
  204. package/node_modules/ibm_db/test/test-describe-table.js +0 -31
  205. package/node_modules/ibm_db/test/test-domains-open.js +0 -19
  206. package/node_modules/ibm_db/test/test-global-open-close.js +0 -11
  207. package/node_modules/ibm_db/test/test-instantiate-one-and-end.js +0 -9
  208. package/node_modules/ibm_db/test/test-multi-open-close.js +0 -45
  209. package/node_modules/ibm_db/test/test-multi-openSync-closeSync.js +0 -52
  210. package/node_modules/ibm_db/test/test-open-close.js +0 -29
  211. package/node_modules/ibm_db/test/test-open-connectTimeout.js +0 -33
  212. package/node_modules/ibm_db/test/test-openSync.js +0 -31
  213. package/node_modules/ibm_db/test/test-pool-close.js +0 -120
  214. package/node_modules/ibm_db/test/test-pool-connect.js +0 -36
  215. package/node_modules/ibm_db/test/test-pool-rollbackTransaction.js +0 -35
  216. package/node_modules/ibm_db/test/test-prepareSync-bad-sql.js +0 -34
  217. package/node_modules/ibm_db/test/test-promise-open-close.js +0 -33
  218. package/node_modules/ibm_db/test/test-query-create-table-fetchSync.js +0 -23
  219. package/node_modules/ibm_db/test/test-query-create-table.js +0 -12
  220. package/node_modules/ibm_db/test/test-query-drop-table.js +0 -13
  221. package/node_modules/ibm_db/test/test-query-insert.js +0 -38
  222. package/node_modules/ibm_db/test/test-query-select-fetch.js +0 -21
  223. package/node_modules/ibm_db/test/test-query-select-fetchMode-array.js +0 -17
  224. package/node_modules/ibm_db/test/test-query-select.js +0 -64
  225. package/node_modules/ibm_db/test/test-queryResult.js +0 -35
  226. package/node_modules/ibm_db/test/test-queryStream.js +0 -43
  227. package/node_modules/ibm_db/test/test-querySync-select-with-exception.js +0 -25
  228. package/node_modules/ibm_db/test/test-querySync-select.js +0 -28
  229. package/node_modules/ibm_db/test/test-require-and-end.js +0 -8
  230. package/node_modules/ibm_db/test/test-statement-close.js +0 -118
  231. package/node_modules/ibm_db/test/test-transaction-commit-sync.js +0 -54
  232. package/node_modules/ibm_db/test/test-transaction-commit.js +0 -79
@@ -1,299 +1,321 @@
1
- // Test for SQLPutData-based chunked LOB insert.
2
- // Tests inserting BLOB data via array of Buffers (sync + async)
3
- // and via Readable stream (async only).
4
- //
5
- // This uses the DATA_AT_EXEC parameter type internally, which
6
- // uses SQLBindParameter with SQL_LEN_DATA_AT_EXEC + SQLPutData
7
- // to send LOB data in chunks to the server.
8
-
9
- var common = require("./common")
10
- , ibmdb = require("../")
11
- , assert = require("assert")
12
- , fs = require("fs")
13
- , path = require("path")
14
- , { Readable } = require("stream")
15
- , cn = common.connectionString
16
- ;
17
-
18
- var tableName = "TEST_BLOB_STREAM_INSERT";
19
- var dataDir = path.join(__dirname, "data");
20
-
21
- // Source file for test data
22
- var srcImage = path.join(dataDir, "phool.jpg");
23
- var srcImageBuf = fs.readFileSync(srcImage);
24
- var srcImageSize = srcImageBuf.length;
25
-
26
- console.log("Source file: " + srcImage + " (" + srcImageSize + " bytes)");
27
-
28
- ibmdb.open(cn, function(err, conn) {
29
- if (err) { console.log(err); process.exit(-1); }
30
- console.log("Connection opened.");
31
-
32
- // Setup table
33
- try { conn.querySync("DROP TABLE " + tableName); } catch(e) {}
34
- conn.querySync("CREATE TABLE " + tableName +
35
- " (ID INTEGER, PHOTO BLOB(1M), DESCR VARCHAR(100))");
36
-
37
- testSyncChunkedInsert();
38
-
39
- // ======================================================================
40
- // Test 1: Sync insert with array of Buffers via querySync
41
- // ======================================================================
42
- function testSyncChunkedInsert() {
43
- console.log("\n--- Test 1: querySync with array of Buffers ---");
44
-
45
- // Split the image into 64KB chunks
46
- var chunkSize = 65536;
47
- var chunks = [];
48
- for (var offset = 0; offset < srcImageBuf.length; offset += chunkSize) {
49
- var end = Math.min(offset + chunkSize, srcImageBuf.length);
50
- chunks.push(srcImageBuf.subarray(offset, end));
51
- }
52
- console.log(" Split into " + chunks.length + " chunks of ~" +
53
- chunkSize + " bytes");
54
-
55
- conn.querySync("INSERT INTO " + tableName +
56
- " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
57
- [
58
- 1,
59
- { ParamType: "INPUT", DataType: "BLOB", Data: chunks },
60
- 'chunked-sync'
61
- ]);
62
-
63
- // Verify by reading back
64
- var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
65
- " WHERE ID = 1");
66
- assert.equal(rows.length, 1, "Should return 1 row");
67
- assert.equal(rows[0].DESCR, 'chunked-sync');
68
-
69
- var photoData = rows[0].PHOTO;
70
- assert.ok(Buffer.isBuffer(photoData), "PHOTO should be a Buffer");
71
- assert.equal(photoData.length, srcImageSize,
72
- "PHOTO size should match source (" + photoData.length +
73
- " vs " + srcImageSize + ")");
74
- assert.ok(srcImageBuf.equals(photoData),
75
- "PHOTO content should match source exactly");
76
-
77
- console.log(" PASS: querySync with chunked Buffer array works.");
78
-
79
- testAsyncChunkedInsert();
80
- }
81
-
82
- // ======================================================================
83
- // Test 2: Async insert with array of Buffers via query()
84
- // ======================================================================
85
- function testAsyncChunkedInsert() {
86
- console.log("\n--- Test 2: query() with array of Buffers ---");
87
-
88
- var chunkSize = 32768;
89
- var chunks = [];
90
- for (var offset = 0; offset < srcImageBuf.length; offset += chunkSize) {
91
- var end = Math.min(offset + chunkSize, srcImageBuf.length);
92
- chunks.push(srcImageBuf.subarray(offset, end));
93
- }
94
- console.log(" Split into " + chunks.length + " chunks of ~" +
95
- chunkSize + " bytes");
96
-
97
- conn.query("INSERT INTO " + tableName +
98
- " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
99
- [
100
- 2,
101
- { ParamType: "INPUT", DataType: "BLOB", Data: chunks },
102
- 'chunked-async'
103
- ],
104
- function(err) {
105
- if (err) { console.log("ERROR:", err); assert.fail(); }
106
-
107
- var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
108
- " WHERE ID = 2");
109
- assert.equal(rows.length, 1);
110
- assert.equal(rows[0].DESCR, 'chunked-async');
111
-
112
- var photoData = rows[0].PHOTO;
113
- assert.ok(Buffer.isBuffer(photoData));
114
- assert.equal(photoData.length, srcImageSize);
115
- assert.ok(srcImageBuf.equals(photoData));
116
-
117
- console.log(" PASS: async query() with chunked Buffer array works.");
118
-
119
- testPrepareExecuteSync();
120
- });
121
- }
122
-
123
- // ======================================================================
124
- // Test 3: Sync prepare/bind/execute with array of Buffers
125
- // ======================================================================
126
- function testPrepareExecuteSync() {
127
- console.log("\n--- Test 3: prepareSync + executeSync with array of Buffers ---");
128
-
129
- var chunkSize = 100000;
130
- var chunks = [];
131
- for (var offset = 0; offset < srcImageBuf.length; offset += chunkSize) {
132
- var end = Math.min(offset + chunkSize, srcImageBuf.length);
133
- chunks.push(srcImageBuf.subarray(offset, end));
134
- }
135
- console.log(" Split into " + chunks.length + " chunks of ~" +
136
- chunkSize + " bytes");
137
-
138
- var stmt = conn.prepareSync("INSERT INTO " + tableName +
139
- " (ID, PHOTO, DESCR) VALUES (?, ?, ?)");
140
- stmt.executeSync([
141
- 3,
142
- { ParamType: "INPUT", DataType: "BLOB", Data: chunks },
143
- 'chunked-prepare-sync'
144
- ]);
145
- stmt.closeSync();
146
-
147
- var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
148
- " WHERE ID = 3");
149
- assert.equal(rows.length, 1);
150
- assert.equal(rows[0].DESCR, 'chunked-prepare-sync');
151
- assert.equal(rows[0].PHOTO.length, srcImageSize);
152
- assert.ok(srcImageBuf.equals(rows[0].PHOTO));
153
-
154
- console.log(" PASS: prepareSync + executeSync with chunks works.");
155
-
156
- testStreamInsert();
157
- }
158
-
159
- // ======================================================================
160
- // Test 4: Async insert with Readable stream via query()
161
- // ======================================================================
162
- function testStreamInsert() {
163
- console.log("\n--- Test 4: query() with Readable stream ---");
164
-
165
- var stream = fs.createReadStream(srcImage, { highWaterMark: 65536 });
166
- console.log(" Using fs.createReadStream with 64KB highWaterMark");
167
-
168
- conn.query("INSERT INTO " + tableName +
169
- " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
170
- [
171
- 4,
172
- { ParamType: "INPUT", DataType: "BLOB",
173
- Data: stream, Length: srcImageSize },
174
- 'stream-async'
175
- ],
176
- function(err) {
177
- if (err) { console.log("ERROR:", err); assert.fail(); }
178
-
179
- var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
180
- " WHERE ID = 4");
181
- assert.equal(rows.length, 1);
182
- assert.equal(rows[0].DESCR, 'stream-async');
183
- assert.equal(rows[0].PHOTO.length, srcImageSize);
184
- assert.ok(srcImageBuf.equals(rows[0].PHOTO));
185
-
186
- console.log(" PASS: async query() with Readable stream works.");
187
-
188
- testStreamExecute();
189
- });
190
- }
191
-
192
- // ======================================================================
193
- // Test 5: Async prepare/execute with Readable stream
194
- // ======================================================================
195
- function testStreamExecute() {
196
- console.log("\n--- Test 5: prepare + execute with Readable stream ---");
197
-
198
- var stream = fs.createReadStream(srcImage, { highWaterMark: 32768 });
199
- console.log(" Using fs.createReadStream with 32KB highWaterMark");
200
-
201
- var stmt = conn.prepareSync("INSERT INTO " + tableName +
202
- " (ID, PHOTO, DESCR) VALUES (?, ?, ?)");
203
-
204
- stmt.execute([
205
- 5,
206
- { ParamType: "INPUT", DataType: "BLOB",
207
- Data: stream, Length: srcImageSize },
208
- 'stream-execute'
209
- ],
210
- function(err) {
211
- if (err) { console.log("ERROR:", err); assert.fail(); }
212
-
213
- stmt.closeSync();
214
-
215
- var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
216
- " WHERE ID = 5");
217
- assert.equal(rows.length, 1);
218
- assert.equal(rows[0].DESCR, 'stream-execute');
219
- assert.equal(rows[0].PHOTO.length, srcImageSize);
220
- assert.ok(srcImageBuf.equals(rows[0].PHOTO));
221
-
222
- console.log(" PASS: prepare + execute with Readable stream works.");
223
-
224
- testSingleChunk();
225
- });
226
- }
227
-
228
- // ======================================================================
229
- // Test 6: Single chunk (array with one Buffer)
230
- // ======================================================================
231
- function testSingleChunk() {
232
- console.log("\n--- Test 6: Single chunk (one Buffer in array) ---");
233
-
234
- conn.querySync("INSERT INTO " + tableName +
235
- " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
236
- [
237
- 6,
238
- { ParamType: "INPUT", DataType: "BLOB",
239
- Data: [srcImageBuf] },
240
- 'single-chunk'
241
- ]);
242
-
243
- var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
244
- " WHERE ID = 6");
245
- assert.equal(rows.length, 1);
246
- assert.equal(rows[0].DESCR, 'single-chunk');
247
- assert.equal(rows[0].PHOTO.length, srcImageSize);
248
- assert.ok(srcImageBuf.equals(rows[0].PHOTO));
249
-
250
- console.log(" PASS: Single chunk works.");
251
-
252
- testAsyncAwait();
253
- }
254
-
255
- // ======================================================================
256
- // Test 7: async/await with stream (Promise)
257
- // ======================================================================
258
- function testAsyncAwait() {
259
- console.log("\n--- Test 7: async/await with stream ---");
260
-
261
- asyncTests().then(function() {
262
- cleanup();
263
- }).catch(function(err) {
264
- console.log(" Error:", err);
265
- assert.fail("async/await test failed");
266
- });
267
- }
268
-
269
- async function asyncTests() {
270
- var stream = fs.createReadStream(srcImage, { highWaterMark: 65536 });
271
-
272
- await conn.query("INSERT INTO " + tableName +
273
- " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
274
- [
275
- 7,
276
- { ParamType: "INPUT", DataType: "BLOB",
277
- Data: stream, Length: srcImageSize },
278
- 'stream-await'
279
- ]);
280
-
281
- var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
282
- " WHERE ID = 7");
283
- assert.equal(rows.length, 1);
284
- assert.equal(rows[0].DESCR, 'stream-await');
285
- assert.equal(rows[0].PHOTO.length, srcImageSize);
286
- assert.ok(srcImageBuf.equals(rows[0].PHOTO));
287
-
288
- console.log(" PASS: async/await with stream works.");
289
- }
290
-
291
- // ======================================================================
292
- // Cleanup
293
- // ======================================================================
294
- function cleanup() {
295
- conn.querySync("DROP TABLE " + tableName);
296
- conn.closeSync();
297
- console.log("\nAll tests passed! Connection closed.");
298
- }
299
- });
1
+ // Test for SQLPutData-based chunked LOB insert.
2
+ // Tests inserting BLOB data via array of Buffers (sync + async)
3
+ // and via Readable stream (async only).
4
+ //
5
+ // This uses the DATA_AT_EXEC parameter type internally, which
6
+ // uses SQLBindParameter with SQL_LEN_DATA_AT_EXEC + SQLPutData
7
+ // to send LOB data in chunks to the server.
8
+
9
+ var common = require("./common")
10
+ , ibmdb = require("../")
11
+ , assert = require("assert")
12
+ , fs = require("fs")
13
+ , path = require("path")
14
+ , { Readable } = require("stream")
15
+ , cn = common.connectionString
16
+ ;
17
+
18
+ var tableName = "TEST_BLOB_STREAM_INSERT";
19
+ var dataDir = path.join(__dirname, "data");
20
+
21
+ // Source file for test data
22
+ var srcImage = path.join(dataDir, "phool.jpg");
23
+ var srcImageBuf = fs.readFileSync(srcImage);
24
+ var srcImageSize = srcImageBuf.length;
25
+
26
+ console.log("Source file: " + srcImage + " (" + srcImageSize + " bytes)");
27
+
28
+ ibmdb.open(cn, function(err, conn) {
29
+ if (err) { console.log(err); process.exit(-1); }
30
+ console.log("Connection opened.");
31
+
32
+ // Setup table
33
+ try { conn.querySync("DROP TABLE " + tableName); } catch(e) {}
34
+ conn.querySync("CREATE TABLE " + tableName +
35
+ " (ID INTEGER, PHOTO BLOB(1M), DESCR VARCHAR(100))");
36
+
37
+ testSyncChunkedInsert();
38
+
39
+ // ======================================================================
40
+ // Test 1: Sync insert with array of Buffers via querySync
41
+ // ======================================================================
42
+ function testSyncChunkedInsert() {
43
+ console.log("\n--- Test 1: querySync with array of Buffers ---");
44
+
45
+ // Split the image into 64KB chunks
46
+ var chunkSize = 65536;
47
+ var chunks = [];
48
+ for (var offset = 0; offset < srcImageBuf.length; offset += chunkSize) {
49
+ var end = Math.min(offset + chunkSize, srcImageBuf.length);
50
+ chunks.push(srcImageBuf.subarray(offset, end));
51
+ }
52
+ console.log(" Split into " + chunks.length + " chunks of ~" +
53
+ chunkSize + " bytes");
54
+
55
+ conn.querySync("INSERT INTO " + tableName +
56
+ " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
57
+ [
58
+ 1,
59
+ { ParamType: "INPUT", DataType: "BLOB", Data: chunks },
60
+ 'chunked-sync'
61
+ ]);
62
+
63
+ // Verify by reading back
64
+ var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
65
+ " WHERE ID = 1");
66
+ assert.equal(rows.length, 1, "Should return 1 row");
67
+ assert.equal(rows[0].DESCR, 'chunked-sync');
68
+
69
+ var photoData = rows[0].PHOTO;
70
+ assert.ok(Buffer.isBuffer(photoData), "PHOTO should be a Buffer");
71
+ assert.equal(photoData.length, srcImageSize,
72
+ "PHOTO size should match source (" + photoData.length +
73
+ " vs " + srcImageSize + ")");
74
+ assert.ok(srcImageBuf.equals(photoData),
75
+ "PHOTO content should match source exactly");
76
+
77
+ console.log(" PASS: querySync with chunked Buffer array works.");
78
+
79
+ testAsyncChunkedInsert();
80
+ }
81
+
82
+ // ======================================================================
83
+ // Test 2: Async insert with array of Buffers via query()
84
+ // ======================================================================
85
+ function testAsyncChunkedInsert() {
86
+ console.log("\n--- Test 2: query() with array of Buffers ---");
87
+
88
+ var chunkSize = 32768;
89
+ var chunks = [];
90
+ for (var offset = 0; offset < srcImageBuf.length; offset += chunkSize) {
91
+ var end = Math.min(offset + chunkSize, srcImageBuf.length);
92
+ chunks.push(srcImageBuf.subarray(offset, end));
93
+ }
94
+ console.log(" Split into " + chunks.length + " chunks of ~" +
95
+ chunkSize + " bytes");
96
+
97
+ conn.query("INSERT INTO " + tableName +
98
+ " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
99
+ [
100
+ 2,
101
+ { ParamType: "INPUT", DataType: "BLOB", Data: chunks },
102
+ 'chunked-async'
103
+ ],
104
+ function(err) {
105
+ if (err) { console.log("ERROR:", err); assert.fail(); }
106
+
107
+ var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
108
+ " WHERE ID = 2");
109
+ assert.equal(rows.length, 1);
110
+ assert.equal(rows[0].DESCR, 'chunked-async');
111
+
112
+ var photoData = rows[0].PHOTO;
113
+ assert.ok(Buffer.isBuffer(photoData));
114
+ assert.equal(photoData.length, srcImageSize);
115
+ assert.ok(srcImageBuf.equals(photoData));
116
+
117
+ console.log(" PASS: async query() with chunked Buffer array works.");
118
+
119
+ testPrepareExecuteSync();
120
+ });
121
+ }
122
+
123
+ // ======================================================================
124
+ // Test 3: Sync prepare/bind/execute with array of Buffers
125
+ // ======================================================================
126
+ function testPrepareExecuteSync() {
127
+ console.log("\n--- Test 3: prepareSync + executeSync with array of Buffers ---");
128
+
129
+ var chunkSize = 100000;
130
+ var chunks = [];
131
+ for (var offset = 0; offset < srcImageBuf.length; offset += chunkSize) {
132
+ var end = Math.min(offset + chunkSize, srcImageBuf.length);
133
+ chunks.push(srcImageBuf.subarray(offset, end));
134
+ }
135
+ console.log(" Split into " + chunks.length + " chunks of ~" +
136
+ chunkSize + " bytes");
137
+
138
+ var stmt = conn.prepareSync("INSERT INTO " + tableName +
139
+ " (ID, PHOTO, DESCR) VALUES (?, ?, ?)");
140
+ stmt.executeSync([
141
+ 3,
142
+ { ParamType: "INPUT", DataType: "BLOB", Data: chunks },
143
+ 'chunked-prepare-sync'
144
+ ]);
145
+ stmt.closeSync();
146
+
147
+ var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
148
+ " WHERE ID = 3");
149
+ assert.equal(rows.length, 1);
150
+ assert.equal(rows[0].DESCR, 'chunked-prepare-sync');
151
+ assert.equal(rows[0].PHOTO.length, srcImageSize);
152
+ assert.ok(srcImageBuf.equals(rows[0].PHOTO));
153
+
154
+ console.log(" PASS: prepareSync + executeSync with chunks works.");
155
+
156
+ testStreamInsert();
157
+ }
158
+
159
+ // ======================================================================
160
+ // Test 4: Async insert with Readable stream via query()
161
+ // ======================================================================
162
+ function testStreamInsert() {
163
+ console.log("\n--- Test 4: query() with Readable stream ---");
164
+
165
+ var stream = fs.createReadStream(srcImage, { highWaterMark: 65536 });
166
+ console.log(" Using fs.createReadStream with 64KB highWaterMark");
167
+
168
+ conn.query("INSERT INTO " + tableName +
169
+ " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
170
+ [
171
+ 4,
172
+ { ParamType: "INPUT", DataType: "BLOB",
173
+ Data: stream, Length: srcImageSize },
174
+ 'stream-async'
175
+ ],
176
+ function(err) {
177
+ if (err) { console.log("ERROR:", err); assert.fail(); }
178
+
179
+ var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
180
+ " WHERE ID = 4");
181
+ assert.equal(rows.length, 1);
182
+ assert.equal(rows[0].DESCR, 'stream-async');
183
+ assert.equal(rows[0].PHOTO.length, srcImageSize);
184
+ assert.ok(srcImageBuf.equals(rows[0].PHOTO));
185
+
186
+ console.log(" PASS: async query() with Readable stream works.");
187
+
188
+ testStreamExecute();
189
+ });
190
+ }
191
+
192
+ // ======================================================================
193
+ // Test 5: Async prepare/execute with Readable stream
194
+ // ======================================================================
195
+ function testStreamExecute() {
196
+ console.log("\n--- Test 5: prepare + execute with Readable stream ---");
197
+
198
+ var stream = fs.createReadStream(srcImage, { highWaterMark: 32768 });
199
+ console.log(" Using fs.createReadStream with 32KB highWaterMark");
200
+
201
+ var stmt = conn.prepareSync("INSERT INTO " + tableName +
202
+ " (ID, PHOTO, DESCR) VALUES (?, ?, ?)");
203
+
204
+ stmt.execute([
205
+ 5,
206
+ { ParamType: "INPUT", DataType: "BLOB",
207
+ Data: stream, Length: srcImageSize },
208
+ 'stream-execute'
209
+ ],
210
+ function(err) {
211
+ if (err) { console.log("ERROR:", err); assert.fail(); }
212
+
213
+ stmt.closeSync();
214
+
215
+ var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
216
+ " WHERE ID = 5");
217
+ assert.equal(rows.length, 1);
218
+ assert.equal(rows[0].DESCR, 'stream-execute');
219
+ assert.equal(rows[0].PHOTO.length, srcImageSize);
220
+ assert.ok(srcImageBuf.equals(rows[0].PHOTO));
221
+
222
+ console.log(" PASS: prepare + execute with Readable stream works.");
223
+
224
+ testSingleChunk();
225
+ });
226
+ }
227
+
228
+ // ======================================================================
229
+ // Test 6: Single chunk (array with one Buffer)
230
+ // ======================================================================
231
+ function testSingleChunk() {
232
+ console.log("\n--- Test 6: Single chunk (one Buffer in array) ---");
233
+
234
+ conn.querySync("INSERT INTO " + tableName +
235
+ " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
236
+ [
237
+ 6,
238
+ { ParamType: "INPUT", DataType: "BLOB",
239
+ Data: [srcImageBuf] },
240
+ 'single-chunk'
241
+ ]);
242
+
243
+ var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
244
+ " WHERE ID = 6");
245
+ assert.equal(rows.length, 1);
246
+ assert.equal(rows[0].DESCR, 'single-chunk');
247
+ assert.equal(rows[0].PHOTO.length, srcImageSize);
248
+ assert.ok(srcImageBuf.equals(rows[0].PHOTO));
249
+
250
+ console.log(" PASS: Single chunk works.");
251
+
252
+ testAsyncAwait();
253
+ }
254
+
255
+ // ======================================================================
256
+ // Test 7: async/await with stream (Promise)
257
+ // ======================================================================
258
+ function testAsyncAwait() {
259
+ console.log("\n--- Test 7: async/await with stream ---");
260
+
261
+ asyncTests().then(function() {
262
+ cleanup();
263
+ }).catch(function(err) {
264
+ console.log(" Error:", err);
265
+ assert.fail("async/await test failed");
266
+ });
267
+ }
268
+
269
+ async function asyncTests() {
270
+ var stream = fs.createReadStream(srcImage, { highWaterMark: 65536 });
271
+
272
+ await conn.query("INSERT INTO " + tableName +
273
+ " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
274
+ [
275
+ 7,
276
+ { ParamType: "INPUT", DataType: "BLOB",
277
+ Data: stream, Length: srcImageSize },
278
+ 'stream-await'
279
+ ]);
280
+
281
+ var rows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
282
+ " WHERE ID = 7");
283
+ assert.equal(rows.length, 1);
284
+ assert.equal(rows[0].DESCR, 'stream-await');
285
+ assert.equal(rows[0].PHOTO.length, srcImageSize);
286
+ assert.ok(srcImageBuf.equals(rows[0].PHOTO));
287
+
288
+ console.log(" PASS: async/await with stream works.");
289
+
290
+ var emptyStream = new Readable();
291
+ emptyStream._read = function() {
292
+ this.push(null);
293
+ };
294
+
295
+ await conn.query("INSERT INTO " + tableName +
296
+ " (ID, PHOTO, DESCR) VALUES (?, ?, ?)",
297
+ [
298
+ 8,
299
+ { ParamType: "INPUT", DataType: "BLOB", Data: emptyStream },
300
+ 'empty-stream'
301
+ ]);
302
+
303
+ var emptyRows = conn.querySync("SELECT PHOTO, DESCR FROM " + tableName +
304
+ " WHERE ID = 8");
305
+ assert.equal(emptyRows.length, 1);
306
+ assert.equal(emptyRows[0].DESCR, 'empty-stream');
307
+ assert.ok(Buffer.isBuffer(emptyRows[0].PHOTO));
308
+ assert.equal(emptyRows[0].PHOTO.length, 0);
309
+
310
+ console.log(" PASS: empty Readable stream works.");
311
+ }
312
+
313
+ // ======================================================================
314
+ // Cleanup
315
+ // ======================================================================
316
+ function cleanup() {
317
+ conn.querySync("DROP TABLE " + tableName);
318
+ conn.closeSync();
319
+ console.log("\nAll tests passed! Connection closed.");
320
+ }
321
+ });