Hi, I have been trying to use the PostgresNode to query a timescaleDB database with a COPY statement. I am using the PostgresNode from @topcs/node-red-contrib-postgres module since it's the only module I could find that supports COPY statement.
I use Node RED version 4.1.10 and Node.js v20.20.2.
Ideally the query statement I'd use would be like this:
COPY ( SELECT * FROM motors_data WHERE motor_id = 'M001'
AND time BETWEEN '2026-06-17T10:00:45.799Z'
AND '2026-06-17T16:00:45.799Z')
TO STDOUT WITH (FORMAT csv, HEADER true, DELIMITER ',');
Where the motor_id and the times are received in msg.payload and the query statement is format in a function node.
I have been testing with simpler statement directy in the PostgresNode. When I try this:
My Node RED instance crashes and I get this error in my terminal:
Jun 13:53:27 - [info] Started flows
19 Jun 13:53:31 - [info] [PostgresNode:f2eeb63b7b85be83] Connected to database
[red] Uncaught Exception:
19 Jun 13:53:31 - [error] TypeError: activeQuery.handleCopyData is not a function
at Client._handleCopyData (/data/node_modules/@topcs/node-red-contrib-postgres/node_modules/pg/lib/client.js:517:17)
at Connection.emit (node:events:524:28)
at /data/node_modules/@topcs/node-red-contrib-postgres/node_modules/pg/lib/connection.js:115:12
at Parser.parse (/data/node_modules/@topcs/node-red-contrib-postgres/node_modules/pg-protocol/dist/parser.js:38:17)
at Socket.<anonymous> (/data/node_modules/@topcs/node-red-contrib-postgres/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (node:events:524:28)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
Also, since I didn't much documentation on the COPY mode from this node I don't know if this error is abnormal or if I am not using the right way. Either way, I hope someone will help solve this issue.
Thank you!
