iobroker.sql 4.3.0 → 4.4.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 (71) hide show
  1. package/README.md +48 -6
  2. package/admin/custom/assets/{Components-CWJJ3bu1.js → Components-Biqn0PcX.js} +1 -1
  3. package/admin/custom/assets/DataBrowser-DTTVoTBj.js +7 -0
  4. package/admin/custom/assets/{_virtual_mf-localSharedImportMap___mfe_internal__SqlComponentsSet__mf_owner__1-D9xu_nUa.js → _virtual_mf-localSharedImportMap___mfe_internal__SqlComponentsSet__mf_owner__1-DAGgRMdx.js} +1 -1
  5. package/admin/custom/assets/{_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__233965516817701__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-D_KAxrKJ.js → _virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__264649249385412__loadShare___mf_0_iobroker_mf_1_gui_mf_2_components__loadShare__.js-DiZBpJW2.js} +541 -303
  6. package/admin/custom/assets/{_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__233965516817701__loadShare__shared-CdBNI0v_.js → _virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__264649249385412__loadShare__shared-DmziGsfK.js} +2 -2
  7. package/admin/custom/assets/{_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__233965516817701__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-CH3Bc0Pg.js → _virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__264649249385412__prebuild___mf_0_iobroker_mf_1_json_mf_2_config__prebuild__-CY-VVm-e.js} +5 -5
  8. package/admin/custom/assets/{_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__233965516817701__prebuild__react_mf_2_dom_mf_1_client__prebuild__-DKp49xnK.js → _virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__264649249385412__prebuild__react_mf_2_dom_mf_1_client__prebuild__-SIym-UC8.js} +1 -1
  9. package/admin/custom/assets/{dist-B3E7IYuQ.js → dist-ChhOvPa4.js} +1 -1
  10. package/admin/custom/assets/helpers-CwABI1ut.js +1 -0
  11. package/admin/custom/assets/hostInit-Bp3K06oA.js +1 -0
  12. package/admin/custom/assets/index-BACEccc0.js +1 -0
  13. package/admin/custom/assets/{lib-3uQoRWeQ.js → lib-BlyWjmi5.js} +1 -1
  14. package/admin/custom/assets/{mf-entry-bootstrap-0-3e3d8b70.js → mf-entry-bootstrap-0-03451604.js} +3 -3
  15. package/admin/custom/assets/pendingShares-BhtJBPS2.js +2 -0
  16. package/admin/custom/assets/{utils-Bi7ATSfV.js → utils-Cqsn1la4.js} +1 -1
  17. package/admin/custom/customComponents.js +2 -2
  18. package/admin/custom/i18n/de.json +15 -0
  19. package/admin/custom/i18n/en.json +15 -0
  20. package/admin/custom/i18n/es.json +15 -0
  21. package/admin/custom/i18n/fr.json +15 -0
  22. package/admin/custom/i18n/it.json +15 -0
  23. package/admin/custom/i18n/nl.json +15 -0
  24. package/admin/custom/i18n/pl.json +15 -0
  25. package/admin/custom/i18n/pt.json +15 -0
  26. package/admin/custom/i18n/ru.json +15 -0
  27. package/admin/custom/i18n/uk.json +15 -0
  28. package/admin/custom/i18n/zh-cn.json +15 -0
  29. package/admin/custom/mf-manifest.json +1 -1
  30. package/admin/jsonConfig.json +3 -0
  31. package/build/lib/connection-factory.js +5 -0
  32. package/build/lib/connection-factory.js.map +1 -1
  33. package/build/lib/errors.js +6 -0
  34. package/build/lib/errors.js.map +1 -1
  35. package/build/lib/messages.js +250 -0
  36. package/build/lib/messages.js.map +1 -1
  37. package/build/lib/mssql.js +19 -15
  38. package/build/lib/mssql.js.map +1 -1
  39. package/build/lib/mysql-client.js +87 -13
  40. package/build/lib/mysql-client.js.map +1 -1
  41. package/build/lib/mysql.js +186 -135
  42. package/build/lib/mysql.js.map +1 -1
  43. package/build/lib/names.js +47 -0
  44. package/build/lib/names.js.map +1 -0
  45. package/build/lib/optional-drivers.js.map +1 -1
  46. package/build/lib/postgresql.js +23 -13
  47. package/build/lib/postgresql.js.map +1 -1
  48. package/build/lib/sql-client-pool.js +7 -1
  49. package/build/lib/sql-client-pool.js.map +1 -1
  50. package/build/lib/sql-client.js +25 -5
  51. package/build/lib/sql-client.js.map +1 -1
  52. package/build/lib/sql-string.js +57 -0
  53. package/build/lib/sql-string.js.map +1 -0
  54. package/build/lib/sqlite.js +21 -14
  55. package/build/lib/sqlite.js.map +1 -1
  56. package/build/lib/statement.js +27 -0
  57. package/build/lib/statement.js.map +1 -0
  58. package/build/lib/values.js +27 -0
  59. package/build/lib/values.js.map +1 -1
  60. package/build/lib/write-buffer.js +80 -0
  61. package/build/lib/write-buffer.js.map +1 -0
  62. package/build/main.js +562 -351
  63. package/build/main.js.map +1 -1
  64. package/io-package.json +14 -14
  65. package/package.json +3 -3
  66. package/admin/custom/assets/DataBrowser-CXd6Wilm.js +0 -1
  67. package/admin/custom/assets/helpers-DE61bb74.js +0 -1
  68. package/admin/custom/assets/hostInit-DI6V2HBN.js +0 -1
  69. package/admin/custom/assets/index-DVNkzy1M.js +0 -1
  70. package/admin/custom/assets/pendingShares-Cg-jucDv.js +0 -2
  71. /package/admin/custom/assets/{_virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__233965516817701__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__--SURtz9t.js → _virtual_mf___mfe_internal__SqlComponentsSet__mf_owner__264649249385412__prebuild__react_mf_1_jsx_mf_2_runtime__prebuild__--SURtz9t.js} +0 -0
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MAX_KEPT_ROWS = exports.MAX_REQUEUED_ROWS = exports.ROWS_PER_STATEMENT = void 0;
4
+ exports.splitBatch = splitBatch;
5
+ exports.requeue = requeue;
6
+ exports.requeueCap = requeueCap;
7
+ /** Rows per INSERT: every dialect chunks its statements at this size */
8
+ exports.ROWS_PER_STATEMENT = 500;
9
+ /**
10
+ * Rows of one datapoint that are kept for a retry after the database was not reachable.
11
+ *
12
+ * At one value every 10 s this covers more than 5 hours of outage; the oldest rows are dropped first.
13
+ */
14
+ exports.MAX_REQUEUED_ROWS = 2000;
15
+ /**
16
+ * Rows of all datapoints together that are kept for a retry.
17
+ *
18
+ * The cap per datapoint alone does not bound the memory: a buffered row - the copy of the state that
19
+ * `pushHelper()` buffers - takes about 270 to 370 bytes, so 5000 datapoints with 2000 rows each would
20
+ * need about 3 GB. On a Raspberry Pi that ends with the adapter running out of memory, and every
21
+ * buffered value is lost with it. 200000 rows are about 55 to 75 MB, and up to 100 datapoints still
22
+ * get the full {@link MAX_REQUEUED_ROWS} each.
23
+ */
24
+ exports.MAX_KEPT_ROWS = 200_000;
25
+ /**
26
+ * Split a batch into groups of one table with at most {@link ROWS_PER_STATEMENT} rows.
27
+ *
28
+ * Each group becomes exactly one INSERT, so when a statement fails, it is known which rows were
29
+ * written and which were not.
30
+ *
31
+ * @param list the rows of one datapoint, in the order they were logged
32
+ * @param size rows per group
33
+ */
34
+ function splitBatch(list, size = exports.ROWS_PER_STATEMENT) {
35
+ const byTable = new Map();
36
+ for (const row of list) {
37
+ let rows = byTable.get(row.table);
38
+ if (!rows) {
39
+ rows = [];
40
+ byTable.set(row.table, rows);
41
+ }
42
+ rows.push(row);
43
+ }
44
+ const groups = [];
45
+ for (const rows of byTable.values()) {
46
+ for (let i = 0; i < rows.length; i += size) {
47
+ groups.push(rows.slice(i, i + size));
48
+ }
49
+ }
50
+ return groups;
51
+ }
52
+ /**
53
+ * Put rows that could not be written back in front of the rows logged since.
54
+ *
55
+ * Only re-queued rows are dropped to stay within the cap, the oldest first: the rows logged in the
56
+ * meantime are buffered as usual.
57
+ *
58
+ * @param current the rows that were buffered in the meantime
59
+ * @param unwritten the rows of the failed write, older than `current`
60
+ * @param cap the maximum number of rows to keep
61
+ * @returns the new buffer and the number of dropped rows
62
+ */
63
+ function requeue(current, unwritten, cap = exports.MAX_REQUEUED_ROWS) {
64
+ const rest = current || [];
65
+ const dropped = Math.min(unwritten.length, Math.max(0, unwritten.length + rest.length - cap));
66
+ return { list: [...unwritten.slice(dropped), ...rest], dropped };
67
+ }
68
+ /**
69
+ * The cap for {@link requeue}: what the buffer of one datapoint may hold after the rows of a failed
70
+ * write are put back, within the limit per datapoint and the limit for all datapoints together.
71
+ *
72
+ * @param buffered the rows in the buffer of the datapoint now
73
+ * @param keptTotal the rows of all datapoints that are kept for a retry now
74
+ * @param perDatapoint the limit for one datapoint
75
+ * @param total the limit for all datapoints together
76
+ */
77
+ function requeueCap(buffered, keptTotal, perDatapoint = exports.MAX_REQUEUED_ROWS, total = exports.MAX_KEPT_ROWS) {
78
+ return Math.min(perDatapoint, buffered + Math.max(0, total - keptTotal));
79
+ }
80
+ //# sourceMappingURL=write-buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-buffer.js","sourceRoot":"","sources":["../../src/lib/write-buffer.ts"],"names":[],"mappings":";;;AAgCA,gCAiBC;AAaD,0BAQC;AAWD,gCAOC;AAtFD,wEAAwE;AAC3D,QAAA,kBAAkB,GAAG,GAAG,CAAC;AAEtC;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,IAAI,CAAC;AAEtC;;;;;;;;GAQG;AACU,QAAA,aAAa,GAAG,OAAO,CAAC;AAErC;;;;;;;;GAQG;AACH,SAAgB,UAAU,CAAiC,IAAS,EAAE,IAAI,GAAG,0BAAkB;IAC3F,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,IAAI,GAAG,EAAE,CAAC;YACV,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACjC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,GAAG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