Skip to content
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

Return values from INSERT are not parsed #51

Open
hengestone opened this issue Jan 30, 2019 · 2 comments
Open

Return values from INSERT are not parsed #51

hengestone opened this issue Jan 30, 2019 · 2 comments

Comments

@hengestone
Copy link

For a pgsql_connection:extended_query of the form
INSERT INTO address (v, acct_id, org_id,)
VALUES ( $1, $2, $3)
RETURNING id;

The return value is e.g.
{{insert, 0, 1}, {[{record, <<00,08....>>}]}}
I.e. the return value is not decoded from the raw binary as it is for a SELECT query.

Using pgsql_connection:simple_query instead, gives e.g.
{{insert, 0, 1}, {[{21}]}}

It would be great to be able to use the set and return pattern as it eliminates one DB round trip.

@pguyot
Copy link
Contributor

pguyot commented Jan 31, 2019

I am confused as there are tests with pgsql_connection:extended_query (or param_query which calls extended_query eventually) and INSERT ... RETURNING ... queries.

See:
https://github.com/semiocast/pgsql/blob/master/test/pgsql_connection_test.erl#L382
and:
https://github.com/semiocast/pgsql/blob/master/test/pgsql_connection_test.erl#L581

I believe there might be some problem with the decoding of the type of data you are returning, as decoding goes through two different paths whether the query is extended or simple, closely matching PostgreSQL protocol. Could you please provide a more complete case?

@hengestone
Copy link
Author

Thanks, will do 👍

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