Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Cannot insert multiple commands into a prepared statement #88

Closed
lroal opened this issue Mar 12, 2020 · 3 comments · Fixed by #89
Closed

Cannot insert multiple commands into a prepared statement #88

lroal opened this issue Mar 12, 2020 · 3 comments · Fixed by #89

Comments

@lroal
Copy link

lroal commented Mar 12, 2020

When runing multiple inserts separated by semicolon, I get the error Cannot insert multiple commands into a prepared statement.
Line: /pg-native/index.js:173:26
I thought multiple statements were possible since v2 ...

@sehrope
Copy link

sehrope commented Mar 12, 2020

PostgreSQL allows for parameters only in commands with a single statement. Multi-statement commands (separated by semicolons) are not allowed to have parameters. This is a server limitation and not specific to this driver.

See the protocol docs for some more detail on this: https://www.postgresql.org/docs/current/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY

@lroal
Copy link
Author

lroal commented Mar 12, 2020

But I am not sending any parameters. I pass in an empty array.
This works: client.query(sql, onResult);
This does not work: client.query(sql, [], onResult);
The pure js client ('pg'), does no throw. So, it is inconsistent behaviour.

@charmander
Copy link
Collaborator

(See also brianc/node-postgres#2100)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants