prostgles-server 4.1.144 → 4.1.145
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/package.json
CHANGED
|
@@ -6,6 +6,31 @@ import { reject } from 'bluebird';
|
|
|
6
6
|
|
|
7
7
|
export default async function client_only(db: DBHandlerClient, auth: Auth, log: (...args: any[]) => any, methods, tableSchema: DBSchemaTable[], token: string){
|
|
8
8
|
|
|
9
|
+
await tryRunP("SQL Stream ensure the connection is never released (same pg_backend_pid is the same for subsequent) when using persistConnectionId", async (resolve, reject) => {
|
|
10
|
+
const query = "SELECT pg_backend_pid()";
|
|
11
|
+
const res = await db.sql!(query, {}, { returnType: "stream", persistStreamConnection: true });
|
|
12
|
+
const pids: number[] = [];
|
|
13
|
+
const listener = async (packet: SocketSQLStreamPacket) => {
|
|
14
|
+
if(packet.type === "error"){
|
|
15
|
+
reject(packet.error);
|
|
16
|
+
} else {
|
|
17
|
+
assert.equal(packet.type, "data");
|
|
18
|
+
assert.equal(packet.ended, true);
|
|
19
|
+
assert.equal(packet.rows.length, 1);
|
|
20
|
+
const pid = packet.rows[0][0];
|
|
21
|
+
pids.push(pid);
|
|
22
|
+
if(pids.length === 1){
|
|
23
|
+
startHandler.run(query).catch(reject);
|
|
24
|
+
}
|
|
25
|
+
if(pids.length === 2){
|
|
26
|
+
assert.equal(pids[0], pids[1]);
|
|
27
|
+
resolve("ok");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const startHandler = await res.start(listener);
|
|
32
|
+
});
|
|
33
|
+
|
|
9
34
|
await tryRunP("SQL Stream stop kills the query", async (resolve, reject) => {
|
|
10
35
|
const query = "SELECT * FROM pg_sleep(5)";
|
|
11
36
|
const res = await db.sql!(query, {}, { returnType: "stream" });
|
|
@@ -196,31 +221,6 @@ export default async function client_only(db: DBHandlerClient, auth: Auth, log:
|
|
|
196
221
|
await res.start(listener);
|
|
197
222
|
});
|
|
198
223
|
|
|
199
|
-
// await tryRunP("SQL Stream ensure the connection is never released (same pg_backend_pid is the same for subsequent) queries when using persistConnectionId", async (resolve, reject) => {
|
|
200
|
-
// const query = "SELECT pg_backend_pid()";
|
|
201
|
-
// const res = await db.sql!(query, {}, { returnType: "stream", persistConnectionId: true });
|
|
202
|
-
// const pids: number[] = [];
|
|
203
|
-
// const listener = async (packet: SocketSQLStreamPacket) => {
|
|
204
|
-
// if(packet.type === "error"){
|
|
205
|
-
// reject(packet.error);
|
|
206
|
-
// } else {
|
|
207
|
-
// assert.equal(packet.type, "data");
|
|
208
|
-
// assert.equal(packet.ended, true);
|
|
209
|
-
// assert.equal(packet.rows.length, 1);
|
|
210
|
-
// const pid = packet.rows[0].pg_backend_pid;
|
|
211
|
-
// pids.push(pid);
|
|
212
|
-
// if(pids.length === 1){
|
|
213
|
-
// startHandler.run(query)
|
|
214
|
-
// }
|
|
215
|
-
// if(pids.length === 2){
|
|
216
|
-
// assert.equal(pids[0], pids[1]);
|
|
217
|
-
// resolve("ok");
|
|
218
|
-
// }
|
|
219
|
-
// }
|
|
220
|
-
// };
|
|
221
|
-
// const startHandler = await res.start(listener);
|
|
222
|
-
// });
|
|
223
|
-
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* tableSchema must contan an array of all tables and their columns that have getInfo and getColumns allowed
|