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

Always use QUERY_SQL in the dqlite shell #260

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

cole-miller
Copy link
Contributor

@cole-miller cole-miller commented Jul 17, 2023

In recent versions of dqlite, the QUERY_SQL request supports SQL
queries that modify the database and do not return rows. Update
internal/shell/shell.go to always send this request for SQL strings
entered by the user, instead of switching between QUERY_SQL and EXEC_SQL
based on whether the string starts with SELECT.

Also fix the Rows iterator so that it can deal with empty row sets that
have zero columns, and add a regression test. Previously it would enter
an infinite loop in this situation.

Closes #239

Signed-off-by: Cole Miller cole.miller@canonical.com

In recent versions of dqlite, the QUERY_SQL request supports SQL
queries that modify the database and do not return rows. Update
internal/shell/shell.go to always send this request for SQL strings
entered by the user, instead of switching between QUERY_SQL and EXEC_SQL
based on whether the string start with `SELECT`.

Also fix the Rows iterator so that it can deal with empty row sets that
have zero columns. Previously it would enter an infinite loop in this
situation.

Signed-off-by: Cole Miller <cole.miller@canonical.com>
@cole-miller
Copy link
Contributor Author

Note that this does not address the desire for the dqlite shell to fully support RETURNING, but that's not a go-dqlite issue. Once dqlite learns how to handle requests that both modify the database and return rows, such statements will just work with go-dqlite Query and the shell.

Signed-off-by: Cole Miller <cole.miller@canonical.com>
Copy link
Contributor

@freeekanayaka freeekanayaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@cole-miller cole-miller merged commit beebd01 into canonical:master Jul 17, 2023
34 checks passed
@Zxilly
Copy link
Contributor

Zxilly commented Jul 22, 2023

Any related dqlite issue? I searched with RETURNING keyword, not no result.

@cole-miller
Copy link
Contributor Author

@zxill You're right, we didn't have a dqlite issue for this, so I've opened one at canonical/dqlite#527 and will fill in details there when I get the chance.

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.

Shell: Support for WITH clauses (or more complex queries)
3 participants