-
Notifications
You must be signed in to change notification settings - Fork 20
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
Running sql scripts from graphical clients sends all sql statements as a single query string #41
Comments
Hi @kishaningithub, thanks for reporting this! We have to update the writer to allow for multiple column definitions to be returned. Looking at the PostgreSQL documentation it should be possible to send multiple row definitions after a single query message. I will update the writer and include a check to make sure that the previous definition has been marked as complete. |
@kishaningithub would you be able to include some debug logs of the psql server? |
Below are the logs (took this by pointing my psql server to the PR) {"level":"debug","timestamp":"2022-11-10T21:31:05.303184+05:30","caller":"[email protected]/wire.go:126","msg":"serving a new client connection"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.305053+05:30","caller":"[email protected]/wire.go:137","msg":"handshake successfull, validating authentication"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.305105+05:30","caller":"[email protected]/handshake.go:74","msg":"reading client parameters"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.305118+05:30","caller":"[email protected]/handshake.go:92","msg":"client parameter","key":"user","value":"asfsdf"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.30513+05:30","caller":"[email protected]/handshake.go:92","msg":"client parameter","key":"database","value":"asfsf"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.305145+05:30","caller":"[email protected]/handshake.go:92","msg":"client parameter","key":"client_encoding","value":"UTF8"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.305154+05:30","caller":"[email protected]/auth.go:33","msg":"authenticating client connection"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.311113+05:30","caller":"[email protected]/wire.go:150","msg":"connection authenticated, writing server parameters"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.311174+05:30","caller":"[email protected]/handshake.go:108","msg":"writing server parameters"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.311201+05:30","caller":"[email protected]/handshake.go:119","msg":"server parameter","key":"client_encoding","value":"UTF8"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.311267+05:30","caller":"[email protected]/handshake.go:119","msg":"server parameter","key":"is_superuser","value":"off"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.31138+05:30","caller":"[email protected]/handshake.go:119","msg":"server parameter","key":"session_authorization","value":"asfsdf"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.31167+05:30","caller":"[email protected]/handshake.go:119","msg":"server parameter","key":"server_encoding","value":"UTF8"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.311732+05:30","caller":"[email protected]/command.go:39","msg":"ready for query... starting to consume commands"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.312162+05:30","caller":"[email protected]/command.go:67","msg":"incoming command","length":82,"type":"Q"}
{"level":"debug","timestamp":"2022-11-10T21:31:05.312244+05:30","caller":"[email protected]/command.go:220","msg":"incoming simple query","query":"select * from employee limit 10;\nselect count(*) from student;"} |
Feel free to ask me if you need anything more |
i understood #41 (comment) only now 🤦 I updated the query handler to split using ";" and run statements so that the way it performs operation is Pseudocode
What happens is for the first query the result is written correctly. From the second query onwards i get the error
I tried it with several query combinations, it is always only the first query that succeeds |
I also have this question (may be it should belong in discussions) How should a consumer handle parameters array for bulk queries like this? |
It is currently a bit unclear to me how bulk queries have to be handled within the PostgreSQL wire protocol. It is mentioned within the message flow format document that multiple queries could be send.
It seems that most clients are handling bulk queries differently. Most split the query up front and send two separate queries to the server. I will try to reproduce the issue using the VSCode SQL client and try to reverse engineer how the client is expecting messages to be send back. I would expect that all parameters for a single bulk query have to be send in one go (ex: |
Context
When i run sql scripts through vscode sql tools. The received query string in SimpleQueryFn is of the form
What i tried
In the SimpleQueryFn implementation that i wrote, i tried splitting the sql with
;
character and running it separately and this results in the errorcolumns have already been defined
What i expect
I expect psql wire to do the split and send queries one by one inside the SimpleQueryFn
What are your thoughts?
The text was updated successfully, but these errors were encountered: