iobroker.sql 4.4.0 → 4.5.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.
- package/README.md +13 -24
- package/admin/i18n/en.json +2 -0
- package/admin/jsonConfig.json +12 -0
- package/build/lib/password.js +28 -0
- package/build/lib/password.js.map +1 -0
- package/build/lib/postgresql.js +6 -6
- package/build/lib/postgresql.js.map +1 -1
- package/build/lib/sql-string.js +19 -2
- package/build/lib/sql-string.js.map +1 -1
- package/build/main.js +67 -6
- package/build/main.js.map +1 -1
- package/io-package.json +32 -28
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,13 +23,14 @@ You can leave port 0 if the default port is desired.
|
|
|
23
23
|
- **Port**: Port of SQL Server (leave blank if not sure)
|
|
24
24
|
- **Database name**: Database name. Default iobroker
|
|
25
25
|
- **User**: Username for SQL. Must exist in the DB.
|
|
26
|
-
- **Password**: Password for SQL.
|
|
26
|
+
- **Password**: Password for SQL. It is stored encrypted in ioBroker.
|
|
27
27
|
- **Password confirm**: Just repeat password here.
|
|
28
28
|
- **Encrypt**: Some DBs support encryption.
|
|
29
29
|
- **Round real to**: Number of digits after the comma.
|
|
30
30
|
- **Allow parallel requests**: Allow simultaneous SQL requests to DB.
|
|
31
31
|
- **Statistics tab**: lists every ID in the database with its storage type, status (logged / logging off / state deleted), number of values, estimated size and the covered time range. The **Clean up** button first shows what would be deleted and removes it only after confirmation. States that still exist but merely have logging switched off are excluded unless you tick the checkbox, because their history is still reachable and may be wanted.
|
|
32
32
|
- **Do not create database**: Activate this option if a database already created (e.g. by administrator) and the ioBroker-user does not have enough rights to create a DB.
|
|
33
|
+
- **Relax PostgreSQL commit durability**: PostgreSQL only, off by default. Runs the adapter's own connections with `synchronous_commit=off`, so a commit no longer waits until the write-ahead log is flushed to disk. This strongly reduces disk I/O and wear, e.g. on SD cards and consumer SSDs. If the PostgreSQL server crashes, the values stored in the last few hundred milliseconds can be lost; unlike `fsync=off` this setting cannot corrupt the database. Other clients of the same server are not affected.
|
|
33
34
|
|
|
34
35
|
## Default Settings
|
|
35
36
|
- **Debounce Time** - Protection against unstable values to make sure that only stable values are logged when the value did not change in the defined amount of Milliseconds. ATTENTION: If values change more often than this setting effectively, no value will be logged (because any value is unstable)
|
|
@@ -270,7 +271,7 @@ Possible options:
|
|
|
270
271
|
- **q** - if *q* field should be included in answer
|
|
271
272
|
- **addId** - if *id* field should be included in answer
|
|
272
273
|
- **limit** - do not return more entries than limit
|
|
273
|
-
- **round** - round result to number of digits after decimal point
|
|
274
|
+
- **round** - round result to number of digits after decimal point. Default: "Round real to" of the datapoint, then of the instance. The stored values are not changed.
|
|
274
275
|
- **ignoreNull** - if null values should be included (false), replaced by last not null value (true) or replaced with 0 (0)
|
|
275
276
|
- **removeBorderValues** - By default, additional border values are returned to optimize charting. Set this option to true if this is not wanted (e.g. for script data processing)
|
|
276
277
|
- **returnNewestEntries** - The returned data are always sorted by timestamp ascending. When using aggregate "none" and also providing "count" or "limit", this means that normally the oldest entries are returned (unless no start data is provided). Set this option to true to get the newest entries instead.
|
|
@@ -649,6 +650,16 @@ sendTo('sql.0', 'getEnabledDPs', {}, function (result) {
|
|
|
649
650
|
-->
|
|
650
651
|
|
|
651
652
|
## Changelog
|
|
653
|
+
### 4.5.0 (2026-11-10)
|
|
654
|
+
* (@Schimi1983) The database password is stored encrypted (`encryptedNative`). A password saved with an older version is encrypted once on the first start, the instance then restarts by itself. Note: after going back to 4.4.1 or older, enter the password in the instance settings again (#587)
|
|
655
|
+
* (@DutchmanNL) PostgreSQL: new opt-in setting "Relax PostgreSQL commit durability" runs the adapter's connections with `synchronous_commit=off`, so commits no longer wait for the disk flush. This strongly reduces disk I/O and wear. A crash of the PostgreSQL server can lose the values of the last few hundred milliseconds; the database cannot be corrupted (#516)
|
|
656
|
+
|
|
657
|
+
### 4.4.1 (2026-11-08)
|
|
658
|
+
* (@GermanBluefox) `getDpOverview` with an empty `datapoints` table answers again and returns its connection. Before, the request never got an answer and the connection stayed borrowed, which with SQLite (one connection) blocked every further request (#587)
|
|
659
|
+
* (@GermanBluefox) "Round real to" of a datapoint now applies to `getHistory`. Before, the field was shown but had no effect, only the setting of the instance counted. As with the instance setting, the values are rounded when read, the stored values stay as they are (#587)
|
|
660
|
+
* (@GermanBluefox) phpMyAdmin container: new instances listen on `127.0.0.1` by default instead of on all network interfaces. Existing instances keep their setting; to reach phpMyAdmin from another machine, choose the IP in the instance settings (#587)
|
|
661
|
+
* (@Schimi1983) PostgreSQL: text values, datapoint IDs and sources are written as escape string literals (`E'...'`), so a backslash can no longer end a value early when `standard_conforming_strings` is off for the database or the user (#587)
|
|
662
|
+
|
|
652
663
|
### 4.4.0 (2026-11-05)
|
|
653
664
|
* (@Schimi1983) Booleans are stored the same in all databases: `on`/`yes`/`true`/`1` as true, `off`/`no`/`false`/`0` and an empty text as false, any other text as NULL. Before, PostgreSQL failed the whole batch on such a text or a number, SQLite and MS SQL stored `off` as true. `storeState` says "values are kept, do not send them again" also when its values were written together with others of the same datapoint (#587)
|
|
654
665
|
* (@Schimi1983) Messages are checked before they reach the database: `update`, `delete`, `deleteRange`, `deleteAll`, `storeState`, `getHistory` and `getCounter` refuse an entry without an ID, with a timestamp that is not a point in time, or with a value that does not fit the stored type, and report it in the answer instead of writing it into the SQL. Before, a `deleteRange` with an unparsable `start` deleted the whole history of the datapoint, a `delete` without an ID the history of the first datapoint of the table, a `start` given as a numeric string became `NaN`, and a value with a quote or a quote in a datapoint ID broke the statement (PostgreSQL, SQLite, MSSQL: quotes are now stored as they are instead of being removed, `Infinity` is stored as NULL). `storeState` with a value that is not a number for a numeric datapoint is answered again instead of waiting forever; a list of entries is answered after the last entry was written, with the errors of the entries that failed; a message with an unexpected shape no longer stops the adapter; "Maximum concurrent connections" of 0 no longer blocks every write (#587)
|
|
@@ -683,28 +694,6 @@ sendTo('sql.0', 'getEnabledDPs', {}, function (result) {
|
|
|
683
694
|
### 4.2.1 (2026-10-13)
|
|
684
695
|
* (@GermanBluefox) The error of a failed save or delete in the data browser is no longer hidden by the reload of the table
|
|
685
696
|
|
|
686
|
-
### 4.2.0 (2026-10-03)
|
|
687
|
-
* (@GermanBluefox) `npm run build:ts` no longer needs the optional `mysql2` and `sqlite3` drivers to be installed
|
|
688
|
-
* (@GermanBluefox) Fixed buffered values being lost when the adapter stops, and unload no longer hangs when there is nothing else to write (#577)
|
|
689
|
-
* (@GermanBluefox) `getCounter` no longer reads the NULL boundary marker that `writeNulls` stores on start and stop as a zero counter value (#577)
|
|
690
|
-
* (@GermanBluefox) Fixed "Test connection" reporting a failure for a working configuration: the request was built as a text template that could produce invalid JSON, and it left out `dbname`, `doNotCreateDatabase` and the docker settings (#355)
|
|
691
|
-
* (@GermanBluefox) "Record changes only" now compares the value instead of the controller's last-change timestamp, so an alias with a read converter no longer stores a row per source change (#295)
|
|
692
|
-
* (@GermanBluefox) Added a statistics tab listing every logged ID with its number of values and estimated size (#247)
|
|
693
|
-
* (@GermanBluefox) Added a cleanup for datapoints that are no longer logged, with a confirmation dialog showing what would be deleted (#247)
|
|
694
|
-
* (@GermanBluefox) The `Counter must have type "number"` error now names the datapoint and is logged once instead of for every value (#320)
|
|
695
|
-
* (@DutchmanNL) PostgreSQL: "do not create database" now connects straight to the configured database instead of opening the maintenance database `postgres` first, so roles without `CONNECT` on it can be used
|
|
696
|
-
* (@GermanBluefox) MySQL can now connect through a unix socket instead of host and port (#104)
|
|
697
|
-
* (@DutchmanNL) Fixed `info.connection` staying `true` while the database was unreachable
|
|
698
|
-
* (@GermanBluefox) Fixed crash (UNCAUGHT_EXCEPTION) when the database server closes the connection: the driver's `error` event had no listener (#527)
|
|
699
|
-
* (@GermanBluefox) A connection that the server dropped is now replaced instead of being handed out again
|
|
700
|
-
|
|
701
|
-
### 4.1.6 (2026-10-01)
|
|
702
|
-
* (@DutchmanNL) Fixed `getCounter` on PostgreSQL: the queries used MySQL-style backtick quoting
|
|
703
|
-
* (@DutchmanNL) Fixed `getCounter` on SQLite: `ORDER BY`/`LIMIT` is not allowed on a compound-select member
|
|
704
|
-
* (@DutchmanNL) Fixed `getCounter` on MS SQL: the counter subquery filtered on `ts_number` instead of `ts_counter`
|
|
705
|
-
* (@GermanBluefox) `getCounter` now sorts in the outer query on all dialects, so the row order no longer depends on the query plan
|
|
706
|
-
* (@DutchmanNL) Added `getCounter` test coverage for all four dialects
|
|
707
|
-
|
|
708
697
|
[Older changelogs can be found there](CHANGELOG_OLD.md)
|
|
709
698
|
|
|
710
699
|
## License
|
package/admin/i18n/en.json
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"Block time": "Blocktime",
|
|
21
21
|
"Boolean": "Boolean",
|
|
22
22
|
"Cancel": "Cancel",
|
|
23
|
+
"Commits no longer wait for the write-ahead log to be flushed to disk. Strongly reduces disk load and wear. If the PostgreSQL server crashes, the values stored in the last few hundred milliseconds can be lost - the database itself cannot be corrupted.": "Commits no longer wait for the write-ahead log to be flushed to disk. Strongly reduces disk load and wear. If the PostgreSQL server crashes, the values stored in the last few hundred milliseconds can be lost - the database itself cannot be corrupted.",
|
|
23
24
|
"Connect through this socket instead of host and port, e.g. /var/run/mysqld/mysqld.sock": "Connect through this socket instead of host and port, e.g. /var/run/mysqld/mysqld.sock",
|
|
24
25
|
"Counter": "Counter",
|
|
25
26
|
"Custom retention duration (days)": "Custom retention duration (days)",
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
"Please confirm": "Please confirm",
|
|
58
59
|
"Port": "Port",
|
|
59
60
|
"Reject on SSL errors": "Reject on SSL errors",
|
|
61
|
+
"Relax PostgreSQL commit durability (synchronous_commit=off)": "Relax PostgreSQL commit durability (synchronous_commit=off)",
|
|
60
62
|
"Reset DB": "Reset DB",
|
|
61
63
|
"Root URL": "Root URL",
|
|
62
64
|
"Root password": "Root password",
|
package/admin/jsonConfig.json
CHANGED
|
@@ -193,6 +193,18 @@
|
|
|
193
193
|
"lg": 4,
|
|
194
194
|
"xl": 4
|
|
195
195
|
},
|
|
196
|
+
"pgSynchronousCommitOff": {
|
|
197
|
+
"newLine": true,
|
|
198
|
+
"type": "checkbox",
|
|
199
|
+
"hidden": "data.dbtype !== 'postgresql'",
|
|
200
|
+
"label": "Relax PostgreSQL commit durability (synchronous_commit=off)",
|
|
201
|
+
"help": "Commits no longer wait for the write-ahead log to be flushed to disk. Strongly reduces disk load and wear. If the PostgreSQL server crashes, the values stored in the last few hundred milliseconds can be lost - the database itself cannot be corrupted.",
|
|
202
|
+
"xs": 12,
|
|
203
|
+
"sm": 12,
|
|
204
|
+
"md": 8,
|
|
205
|
+
"lg": 8,
|
|
206
|
+
"xl": 8
|
|
207
|
+
},
|
|
196
208
|
"_testConnection": {
|
|
197
209
|
"newLine": true,
|
|
198
210
|
"variant": "contained",
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The database password is stored encrypted (`encryptedNative` in io-package.json, #587).
|
|
4
|
+
*
|
|
5
|
+
* Kept out of `main.ts` so it can be unit tested (see `values.ts` for why main.ts cannot be loaded
|
|
6
|
+
* in a unit test).
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ENCRYPTED_PREFIX = void 0;
|
|
10
|
+
exports.isPlainPassword = isPlainPassword;
|
|
11
|
+
/** Prefix of every value js-controller encrypts with `encrypt()` (aes-192-cbc, js-controller >= 3.3) */
|
|
12
|
+
exports.ENCRYPTED_PREFIX = '$/aes-192-cbc:';
|
|
13
|
+
/**
|
|
14
|
+
* Whether the raw `native.password` of the instance object is still stored as plain text.
|
|
15
|
+
*
|
|
16
|
+
* Up to 4.4.1 the adapter had no `encryptedNative`, so admin stored the password as it was typed.
|
|
17
|
+
* js-controller decrypts every `encryptedNative` attribute on start, and a value without the prefix
|
|
18
|
+
* goes through its legacy XOR decryption - a plain password becomes garbage in `this.config` and
|
|
19
|
+
* the database refuses the login. Such a value has to be encrypted once (`migratePassword()` in
|
|
20
|
+
* main.ts). Admin >= 7 and `encrypt()` always write the prefix, so a value with it is encrypted
|
|
21
|
+
* already; the legacy XOR format was never written for this adapter.
|
|
22
|
+
*
|
|
23
|
+
* @param raw `native.password` as read with `getForeignObject` (which does not decrypt)
|
|
24
|
+
*/
|
|
25
|
+
function isPlainPassword(raw) {
|
|
26
|
+
return typeof raw === 'string' && raw !== '' && !raw.startsWith(exports.ENCRYPTED_PREFIX);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=password.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password.js","sourceRoot":"","sources":["../../src/lib/password.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAiBH,0CAEC;AAjBD,wGAAwG;AAC3F,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AAEjD;;;;;;;;;;;GAWG;AACH,SAAgB,eAAe,CAAC,GAAY;IACxC,OAAO,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,wBAAgB,CAAC,CAAC;AACtF,CAAC"}
|
package/build/lib/postgresql.js
CHANGED
|
@@ -82,7 +82,7 @@ function insert(_dbName, index, values) {
|
|
|
82
82
|
value.state.val = 'NULL';
|
|
83
83
|
}
|
|
84
84
|
else if (value.table === 'ts_string') {
|
|
85
|
-
value.state.val = (0, sql_string_1.
|
|
85
|
+
value.state.val = (0, sql_string_1.quotePgString)(value.state.val);
|
|
86
86
|
}
|
|
87
87
|
else if (value.table === 'ts_number' || value.table === 'ts_counter') {
|
|
88
88
|
value.state.val = (0, sql_string_1.numberOrNull)(value.state.val);
|
|
@@ -130,22 +130,22 @@ function getIdSelect(_dbName, name) {
|
|
|
130
130
|
if (!name) {
|
|
131
131
|
return 'SELECT id, type, name FROM datapoints;';
|
|
132
132
|
}
|
|
133
|
-
return `SELECT id, type, name FROM datapoints WHERE name=${(0, sql_string_1.
|
|
133
|
+
return `SELECT id, type, name FROM datapoints WHERE name=${(0, sql_string_1.quotePgString)(name)};`;
|
|
134
134
|
}
|
|
135
135
|
function getIdInsert(_dbName, name, type) {
|
|
136
|
-
return `INSERT INTO datapoints (name, type) VALUES(${(0, sql_string_1.
|
|
136
|
+
return `INSERT INTO datapoints (name, type) VALUES(${(0, sql_string_1.quotePgString)(name)}, ${type});`;
|
|
137
137
|
}
|
|
138
138
|
function getIdUpdate(_dbName, id, type) {
|
|
139
139
|
return `UPDATE datapoints SET type = ${type} WHERE id = ${id};`;
|
|
140
140
|
}
|
|
141
141
|
function getFromSelect(_dbName, name) {
|
|
142
142
|
if (name) {
|
|
143
|
-
return `SELECT id, name FROM sources WHERE name=${(0, sql_string_1.
|
|
143
|
+
return `SELECT id, name FROM sources WHERE name=${(0, sql_string_1.quotePgString)(name)};`;
|
|
144
144
|
}
|
|
145
145
|
return 'SELECT id, name FROM sources;';
|
|
146
146
|
}
|
|
147
147
|
function getFromInsert(dbName, values) {
|
|
148
|
-
return `INSERT INTO sources (name) VALUES(${(0, sql_string_1.
|
|
148
|
+
return `INSERT INTO sources (name) VALUES(${(0, sql_string_1.quotePgString)(values)});`;
|
|
149
149
|
}
|
|
150
150
|
function getCounterDiff(_dbName, options) {
|
|
151
151
|
// Take first real value after start
|
|
@@ -271,7 +271,7 @@ function update(_dbName, index, originalState, from, table) {
|
|
|
271
271
|
state.val = 'NULL';
|
|
272
272
|
}
|
|
273
273
|
else if (table === 'ts_string') {
|
|
274
|
-
state.val = (0, sql_string_1.
|
|
274
|
+
state.val = (0, sql_string_1.quotePgString)(state.val);
|
|
275
275
|
}
|
|
276
276
|
else if (table === 'ts_number' || table === 'ts_counter') {
|
|
277
277
|
state.val = (0, sql_string_1.numberOrNull)(state.val);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgresql.js","sourceRoot":"","sources":["../../src/lib/postgresql.ts"],"names":[],"mappings":";;AAGA,oBASC;AAED,0BASC;AAED,gCAEC;AAWD,kCAEC;AAYD,o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AU,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC;AACrG,CAAC"}
|
|
1
|
+
{"version":3,"file":"postgresql.js","sourceRoot":"","sources":["../../src/lib/postgresql.ts"],"names":[],"mappings":";;AAGA,oBASC;AAED,0BASC;AAED,gCAEC;AAWD,kCAEC;AAYD,oCAIC;AAED,wBA2DC;AAED,8BASC;AAED,kCAKC;AAED,kCAEC;AAED,kCAEC;AAED,sCAKC;AAED,sCAEC;AAED,wCA8BC;AAED,gCA4FC;AAED,0CAmBC;AAWD,0CAEC;AAED,wBAwCC;AAaD,sCAQC;AAED,gDAOC;AAlYD,6CAAuE;AAGvE,SAAgB,IAAI,CAAC,OAAe,EAAE,oBAA8B;IAChE,OAAO;QACH,sEAAsE;QACtE,oFAAoF;QACpF,oIAAoI;QACpI,oIAAoI;QACpI,oIAAoI;QACpI,qEAAqE;KACxE,CAAC;AACN,CAAC;AAED,SAAgB,OAAO,CAAC,OAAe,EAAE,oBAA8B;IACnE,OAAO;QACH,wBAAwB;QACxB,uBAAuB;QACvB,uBAAuB;QACvB,qBAAqB;QACrB,qBAAqB;QACrB,wBAAwB;KAC3B,CAAC;AACN,CAAC;AAED,SAAgB,UAAU,CAAC,OAAe,EAAE,KAAgB;IACxD,OAAO,iCAAiC,KAAK,eAAe,CAAC;AACjE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAgB,WAAW,CAAC,OAAe,EAAE,KAAgB;IACzD,OAAO,4EAA4E,KAAK,eAAe,CAAC;AAC5G,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,YAAY,CAAC,OAAe,EAAE,KAAgB;IAC1D,yFAAyF;IACzF,4DAA4D;IAC5D,OAAO,2MAA2M,KAAK,IAAI,CAAC;AAChO,CAAC;AAED,SAAgB,MAAM,CAClB,OAAe,EACf,KAAa,EACb,MAIG;IAEH,MAAM,YAAY,GAAkC,EAAE,CAAC;IACvD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,E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,CAAC,CAAC,CAAC,MAAM,EAAE;QAClE,UAAU,OAAO,CAAC,KAAK,WAAW,OAAO,CAAC,MAAM,GAAG,CACtD,CAAC;AACN,CAAC;AAED,SAAgB,kBAAkB,CAC9B,OAAe,EACf,KAAgB,EAChB,KAAa,EACb,OAAyC;IAEzC,OAAO,iCAAiC,KAAK,UAAU,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC;AACrG,CAAC"}
|
package/build/lib/sql-string.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.quoteSqlString = quoteSqlString;
|
|
4
|
+
exports.quotePgString = quotePgString;
|
|
4
5
|
exports.numberOrNull = numberOrNull;
|
|
5
6
|
exports.boolOrNull = boolOrNull;
|
|
6
7
|
const values_1 = require("./values");
|
|
@@ -13,8 +14,9 @@ const values_1 = require("./values");
|
|
|
13
14
|
* best and an injected statement at worst. Datapoint IDs and `from` names come from the object
|
|
14
15
|
* tree, string values from the states and from `storeState`/`update` messages.
|
|
15
16
|
*
|
|
16
|
-
* Standard SQL (
|
|
17
|
-
*
|
|
17
|
+
* Standard SQL (SQLite, MSSQL) knows only one escape in a string literal: `'` is doubled. A NUL byte
|
|
18
|
+
* can never be part of a literal and is dropped. PostgreSQL reads backslashes in a plain literal as
|
|
19
|
+
* escapes when `standard_conforming_strings` is off, so it gets its own quoting (`quotePgString`).
|
|
18
20
|
* MySQL escapes with a backslash; its dialect module binds the values instead of quoting them.
|
|
19
21
|
*/
|
|
20
22
|
/**
|
|
@@ -26,6 +28,21 @@ function quoteSqlString(value) {
|
|
|
26
28
|
const text = typeof value === 'string' ? value : String(value);
|
|
27
29
|
return `'${text.replace(/\0/g, '').replace(/'/g, "''")}'`;
|
|
28
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Return `value` as a PostgreSQL escape string literal (`E'...'`), including the prefix and quotes.
|
|
33
|
+
*
|
|
34
|
+
* A plain `'...'` literal depends on `standard_conforming_strings`: with it off - possible per
|
|
35
|
+
* database, per role or in postgresql.conf, although the default is on since 9.1 - a backslash
|
|
36
|
+
* escapes the next character, so `\'; DROP TABLE datapoints; --` turned the doubled quote into an
|
|
37
|
+
* escaped one plus a closing quote, and the rest was executed. An escape string literal reads
|
|
38
|
+
* backslashes as escapes with either setting, so doubling both `\` and `'` is always right.
|
|
39
|
+
*
|
|
40
|
+
* @param value the text to quote; anything else is converted with `String()`
|
|
41
|
+
*/
|
|
42
|
+
function quotePgString(value) {
|
|
43
|
+
const text = typeof value === 'string' ? value : String(value);
|
|
44
|
+
return `E'${text.replace(/\0/g, '').replace(/\\/g, '\\\\').replace(/'/g, "''")}'`;
|
|
45
|
+
}
|
|
29
46
|
/**
|
|
30
47
|
* Return `value` as an SQL number literal, or `NULL` when it is not a finite number.
|
|
31
48
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-string.js","sourceRoot":"","sources":["../../src/lib/sql-string.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"sql-string.js","sourceRoot":"","sources":["../../src/lib/sql-string.ts"],"names":[],"mappings":";;AAqBA,wCAGC;AAaD,sCAGC;AAUD,oCAEC;AASD,gCASC;AAtED,qCAAkC;AAClC;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,SAAgB,cAAc,CAAC,KAAc;IACzC,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,aAAa,CAAC,KAAc;IACxC,MAAM,IAAI,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/D,OAAO,KAAK,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC;AACtF,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,KAAc;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;AACxF,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,KAAc,EAAE,OAAgB;IACvD,MAAM,CAAC,GAAG,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,eAAM,EAAC,KAAK,CAAC,CAAC;IACvE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QACb,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,EAAE,CAAC;QACV,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AAChC,CAAC"}
|
package/build/main.js
CHANGED
|
@@ -47,6 +47,7 @@ const mysql_client_1 = require("./lib/mysql-client");
|
|
|
47
47
|
const connection_options_1 = require("./lib/connection-options");
|
|
48
48
|
const messages_1 = require("./lib/messages");
|
|
49
49
|
const values_1 = require("./lib/values");
|
|
50
|
+
const password_1 = require("./lib/password");
|
|
50
51
|
const names_1 = require("./lib/names");
|
|
51
52
|
const statement_1 = require("./lib/statement");
|
|
52
53
|
const statistics_1 = require("./lib/statistics");
|
|
@@ -716,6 +717,13 @@ class SqlAdapter extends adapter_core_1.Adapter {
|
|
|
716
717
|
}
|
|
717
718
|
: undefined,
|
|
718
719
|
};
|
|
720
|
+
if (this.config.pgSynchronousCommitOff) {
|
|
721
|
+
// Relax commit durability for this adapter's sessions only (sent in the startup
|
|
722
|
+
// packet, so every pooled connection gets it). Unlike fsync=off this cannot corrupt
|
|
723
|
+
// the database; a crash of the PostgreSQL server can lose the last few hundred
|
|
724
|
+
// milliseconds of committed values.
|
|
725
|
+
postgreSQLOptions.options = '-c synchronous_commit=off';
|
|
726
|
+
}
|
|
719
727
|
}
|
|
720
728
|
else if (this.config.dbtype === 'mssql') {
|
|
721
729
|
msSQLOptions = {
|
|
@@ -3035,22 +3043,25 @@ class SqlAdapter extends adapter_core_1.Adapter {
|
|
|
3035
3043
|
if (!options.start && options.count) {
|
|
3036
3044
|
options.returnNewestEntries = true;
|
|
3037
3045
|
}
|
|
3046
|
+
if (options.id && this.aliasMap[options.id]) {
|
|
3047
|
+
options.id = this.aliasMap[options.id];
|
|
3048
|
+
}
|
|
3049
|
+
// "Round real to" of the datapoint, which normalizeCustomConfig() defaults to the one of the instance.
|
|
3050
|
+
// It rounds what is read and leaves the stored values as they are, like the setting of the instance.
|
|
3051
|
+
const configuredRound = (options.id ? this.sqlDPs[options.id]?.config?.round : undefined) ?? this.config.round ?? undefined;
|
|
3038
3052
|
if (msg.message.options.round !== null &&
|
|
3039
3053
|
msg.message.options.round !== undefined &&
|
|
3040
3054
|
msg.message.options.round !== '') {
|
|
3041
3055
|
msg.message.options.round = parseInt(msg.message.options.round, 10);
|
|
3042
3056
|
if (!isFinite(msg.message.options.round) || msg.message.options.round < 0) {
|
|
3043
|
-
options.round =
|
|
3057
|
+
options.round = configuredRound;
|
|
3044
3058
|
}
|
|
3045
3059
|
else {
|
|
3046
3060
|
options.round = Math.pow(10, parseInt(msg.message.options.round, 10));
|
|
3047
3061
|
}
|
|
3048
3062
|
}
|
|
3049
3063
|
else {
|
|
3050
|
-
options.round =
|
|
3051
|
-
}
|
|
3052
|
-
if (options.id && this.aliasMap[options.id]) {
|
|
3053
|
-
options.id = this.aliasMap[options.id];
|
|
3064
|
+
options.round = configuredRound;
|
|
3054
3065
|
}
|
|
3055
3066
|
if ((options.aggregate === 'percentile' && options.percentile < 0) || options.percentile > 100) {
|
|
3056
3067
|
this.log.error(`Invalid percentile value: ${options.percentile}, use 50 as default`);
|
|
@@ -3950,8 +3961,9 @@ class SqlAdapter extends adapter_core_1.Adapter {
|
|
|
3950
3961
|
}
|
|
3951
3962
|
}
|
|
3952
3963
|
this.log.info(`initialisation result: ${JSON.stringify(result)}`);
|
|
3953
|
-
this.getFirstTsForIds(client, 0, result, msg);
|
|
3954
3964
|
}
|
|
3965
|
+
// Also with an empty table: this returns the connection and sends the answer.
|
|
3966
|
+
this.getFirstTsForIds(client, 0, result, msg);
|
|
3955
3967
|
});
|
|
3956
3968
|
});
|
|
3957
3969
|
}
|
|
@@ -4113,6 +4125,7 @@ class SqlAdapter extends adapter_core_1.Adapter {
|
|
|
4113
4125
|
if (config.writeNulls === undefined) {
|
|
4114
4126
|
config.writeNulls = true;
|
|
4115
4127
|
}
|
|
4128
|
+
config.pgSynchronousCommitOff = !!config.pgSynchronousCommitOff;
|
|
4116
4129
|
config.retention = parseInt(config.retention, 10) || 0;
|
|
4117
4130
|
if (config.retention === -1) {
|
|
4118
4131
|
// Custom timeframe
|
|
@@ -4254,8 +4267,56 @@ class SqlAdapter extends adapter_core_1.Adapter {
|
|
|
4254
4267
|
}
|
|
4255
4268
|
}
|
|
4256
4269
|
}
|
|
4270
|
+
/**
|
|
4271
|
+
* Encrypt a database password that is still stored as plain text (once, after the update from
|
|
4272
|
+
* <= 4.4.1, see `isPlainPassword()`).
|
|
4273
|
+
*
|
|
4274
|
+
* js-controller has already run the plain text through its decryption, so `this.config.password`
|
|
4275
|
+
* is garbage at this point; the raw value from the instance object is the right one. It is used
|
|
4276
|
+
* for this start and written back encrypted with `updateConfig()`, which encrypts every
|
|
4277
|
+
* `encryptedNative` attribute. The change of the instance object restarts the instance once.
|
|
4278
|
+
*
|
|
4279
|
+
* Returns `true` when the encrypted value was written, i.e. a restart is on its way.
|
|
4280
|
+
*
|
|
4281
|
+
* Deliberately no "already migrated" flag in `native`: a default for it in
|
|
4282
|
+
* io-package.json could reach existing instances on an upgrade and skip the migration, which
|
|
4283
|
+
* would leave them with a wrong password. The prefix of the stored value says it reliably.
|
|
4284
|
+
*/
|
|
4285
|
+
async migratePassword() {
|
|
4286
|
+
let raw;
|
|
4287
|
+
try {
|
|
4288
|
+
const obj = await this.getForeignObjectAsync(`system.adapter.${this.namespace}`);
|
|
4289
|
+
raw = obj?.native?.password;
|
|
4290
|
+
}
|
|
4291
|
+
catch (e) {
|
|
4292
|
+
this.log.error(`Cannot read object "system.adapter.${this.namespace}": ${e}`);
|
|
4293
|
+
return false;
|
|
4294
|
+
}
|
|
4295
|
+
if (!(0, password_1.isPlainPassword)(raw)) {
|
|
4296
|
+
return false;
|
|
4297
|
+
}
|
|
4298
|
+
this.config.password = raw;
|
|
4299
|
+
try {
|
|
4300
|
+
await this.updateConfig({ password: raw });
|
|
4301
|
+
this.log.info('The database password is stored encrypted now, the instance restarts once');
|
|
4302
|
+
return true;
|
|
4303
|
+
}
|
|
4304
|
+
catch (e) {
|
|
4305
|
+
// the plain value still works for this start; the next start tries again
|
|
4306
|
+
this.log.warn(`Cannot store the database password encrypted: ${e}`);
|
|
4307
|
+
return false;
|
|
4308
|
+
}
|
|
4309
|
+
}
|
|
4257
4310
|
async main() {
|
|
4258
4311
|
this.setConnected(false);
|
|
4312
|
+
if (await this.migratePassword()) {
|
|
4313
|
+
// js-controller stops the instance within a few hundred ms because its object changed.
|
|
4314
|
+
// Starting the connection and the subscriptions in the meantime only produced "DB closed"
|
|
4315
|
+
// errors in the log. `delay()` never resolves once the stop has begun; if no restart comes
|
|
4316
|
+
// (an instance not started by js-controller, e.g. in the tests), the start goes on with
|
|
4317
|
+
// the plain value.
|
|
4318
|
+
await this.delay(3000);
|
|
4319
|
+
}
|
|
4259
4320
|
// set default history if not yet set
|
|
4260
4321
|
try {
|
|
4261
4322
|
const obj = await this.getForeignObjectAsync('system.config');
|