Skip to content

multirows syntax panics when passing correct (multiple) number of parameters #785

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SuperFluffy opened this issue Jun 8, 2021 · 2 comments

Comments

@SuperFluffy
Copy link

SuperFluffy commented Jun 8, 2021

This is on tokio-postgres 0.7.2.

I am dynamically constructing insert queries like the following (without the linebreak in between; just here for formatting):

INSERT INTO trades VALUES
($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20),
($21,$22,$23,$24,$25,$26,$27,$28,$29,$30,$31,$32,$33,$34,$35,$36,$37,$38,$39,$40);

However, when I then try to execute a statement with an iterator that contains the right number of elements, e.g. rows contains 40 dyn ToSql trait objects in client.execute_raw(&*insertion_query, rows.into_iter()).await?; I am getting the following error:

thread 'main' panicked at 'expected 20 parameters but got 40', /home/janis/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-postgres-0.7.2/src/query.rs:160:5

I was following this suggestion (for various reasons I cannot use the COPY FROM STDIN syntax): #336 (comment)

I have tried to explicitly name the columns I am inserting into, but the error remains the same.

EDIT: Is query parsing actually done by the server? If so, it might be that my database (questdb), although it claims compatibility with postgres, does not support multirows insertion syntax and hence gives an incorrect parse.

@sfackler
Copy link
Owner

sfackler commented Jun 8, 2021

Query parsing is done entirely on the server, yeah. We send the string over, and the server sends back how many parameters there are and what their types are expected to be.

@SuperFluffy
Copy link
Author

Alright, closing this after verifying with upstream (= the questdb devs): questdb does not support postgres multirow syntax, so that's where the issue comes from. The problem has nothing to do with rust-postgres. Sorry for the noise.

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

No branches or pull requests

2 participants