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

c/driver/postgresql: infer schema by using a prepared statement #701

Closed
lidavidm opened this issue May 23, 2023 · 1 comment · Fixed by #707
Closed

c/driver/postgresql: infer schema by using a prepared statement #701

lidavidm opened this issue May 23, 2023 · 1 comment · Fixed by #707
Assignees

Comments

@lidavidm
Copy link
Member

Would this have an impact on performance or server resources?

pqDescribePrepared gives you the columns of the result schema. That lets us infer the schema without the current SELECT (*) LIMIT 0 hack, which breaks down for things that aren't SELECTs.

@lidavidm lidavidm added this to the ADBC Libraries 0.5.0 milestone May 23, 2023
@lidavidm
Copy link
Member Author

I will probably do this first since the C++ equivalent of #700 would get much easier with this.

lidavidm added a commit to lidavidm/arrow-adbc that referenced this issue May 24, 2023
Before we tried to infer the query schema before COPY by wrapping
it in a "SELECT * FROM (...) LIMIT 0".  This broke if the query
was (for example) a CREATE or UPDATE.  Instead, use a prepared
statement to infer instead.  If we find that there are no result
columns, then execute without the COPY path.

Also, test what happens with "INSERT INTO ... RETURNING" (this
works with COPY).

Fixes apache#701.
@lidavidm lidavidm self-assigned this May 24, 2023
lidavidm added a commit that referenced this issue May 25, 2023
Before we tried to infer the query schema before COPY by wrapping it in
a "SELECT * FROM (...) LIMIT 0". This broke if the query was (for
example) a CREATE or UPDATE. Instead, use a prepared statement to infer
instead. If we find that there are no result columns, then execute
without the COPY path.

Also, test what happens with "INSERT INTO ... RETURNING" (this works
with COPY).

Fixes #701.
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

Successfully merging a pull request may close this issue.

1 participant