Skip to content

Conversation

Z-Xiao-M
Copy link
Contributor

@Z-Xiao-M Z-Xiao-M commented Dec 12, 2024

DuckDB complains when it receives parameters that were not actually used in the query. From Postgres we get all supplied parameters though. So this changes the code to filter the unused ones out. To do this we lot DuckDB parse the query and tell us which parameters it expects, and then we remove the unexpected ones.

Fixes #411
Fixes #234

@zhousun
Copy link
Contributor

zhousun commented Dec 13, 2024

@Leo-XM-Zeng thx for the pr, can you check whether Mooncake-Labs/pg_mooncake@a6262b1 would be an easier way to fix the same issue?

@Z-Xiao-M
Copy link
Contributor Author

@Leo-XM-Zeng thx for the pr, can you check whether Mooncake-Labs/pg_mooncake@a6262b1 would be an easier way to fix the same issue?

Wow, a simpler change. My implementation is handled from a PostgreSQL perspective because my understanding of DuckDB is not as deep as PostgreSQL's. I can't judge whether your changes are good or bad, perhaps we need to consult someone who has a deeper understanding of these. @JelteF

@JelteF
Copy link
Collaborator

JelteF commented Dec 13, 2024

I can't judge whether your changes are good or bad, perhaps we need to consult someone who has a deeper understanding of these.

Looking at the changes linked by @zhousun, those are indeed quite simple: They let duckdb figure out what parameters are in the query, and then we only pass those parameters to duckdb from the full set of parameters that postgres has. If that indeed solves all these issues, then I like that approach better than us traversing the query tree ourselves to find all the parameters.

@zhousun are you okay with @Leo-XM-Zeng changing this PR to incorporate those changes?

@Z-Xiao-M
Copy link
Contributor Author

Looking at the changes linked by @zhousun, those are indeed quite simple: They let duckdb figure out what parameters are in the query, and then we only pass those parameters to duckdb from the full set of parameters that postgres has. If that indeed solves all these issues, then I like that approach better than us traversing the query tree ourselves to find all the parameters.

@zhousun Your code is much more perfect than mine, I just tested and validated it and found that it handles these scenarios much better. That would be a better solution.

@Z-Xiao-M
Copy link
Contributor Author

@Leo-XM-Zeng thx for the pr, can you check whether Mooncake-Labs/pg_mooncake@a6262b1 would be an easier way to fix the same issue?

If you want to submit your own PR, I will turn this off at that time, the current PR code is from you, I just added some test cases.

@zhousun
Copy link
Contributor

zhousun commented Dec 13, 2024

@Leo-XM-Zeng just take it :)

@Z-Xiao-M
Copy link
Contributor Author

just take it :)

Thank you ~ 😀

@JelteF JelteF merged commit 04be407 into duckdb:main Dec 16, 2024
5 checks passed
@JelteF
Copy link
Collaborator

JelteF commented Dec 16, 2024

Thanks both, I used the Co-authored-by: trailer in the git commit to also attribute @zhousun

@zhaonaiy
Copy link

Hello, I was wondering if this bug has been fixed? checked in which version? Thanks.

@Z-Xiao-M
Copy link
Contributor Author

Hello, I was wondering if this bug has been fixed? checked in which version? Thanks.

You can try compiling the main branch code.

image

@Z-Xiao-M Z-Xiao-M deleted the param branch June 18, 2025 08:23
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 this pull request may close these issues.

Any stored procedure is not working support "PREPARE" statement and "EXECUTE " statement
4 participants