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

Support QUERY and QUERY_SQL that modify the database #477

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

cole-miller
Copy link
Contributor

@cole-miller cole-miller commented Feb 15, 2023

Closes #471. This is based on #476, I'll rebase onto master once that merges.

As suggested by @freeekanayaka, we don't support modifying statements that also return rows (for now). Modifying statements submitted with QUERY or QUERY_SQL go through exactly the same codepath as if submitted with EXEC or EXEC_SQL, respectively, except that we send an empty ROWS response instead of a RESULT response.

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

@codecov
Copy link

codecov bot commented Feb 15, 2023

Codecov Report

Merging #477 (d564cfd) into master (e9b38ad) will increase coverage by 0.12%.
The diff coverage is 54.00%.

@@            Coverage Diff             @@
##           master     #477      +/-   ##
==========================================
+ Coverage   58.73%   58.85%   +0.12%     
==========================================
  Files          33       33              
  Lines        5869     5916      +47     
  Branches     1762     1778      +16     
==========================================
+ Hits         3447     3482      +35     
  Misses       1358     1358              
- Partials     1064     1076      +12     
Impacted Files Coverage Δ
src/gateway.c 43.00% <54.00%> (+0.82%) ⬆️
src/transport.c 51.29% <0.00%> (+5.19%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Signed-off-by: Cole Miller <cole.miller@canonical.com>
@cole-miller cole-miller marked this pull request as ready for review February 22, 2023 15:48
@cole-miller
Copy link
Contributor Author

Rebased and ready for review.


is_readonly = (bool)sqlite3_stmt_readonly(stmt->stmt);
if (is_readonly) {
rv = leader__barrier(g->leader, &g->barrier, query_barrier_cb);
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't let it stop you (it's there in original code), but where do we send a failure response if this call or leader__exec in the other branch fails?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We end up returning nonzero from handle_query, which turns into a nonzero return from gateway__handle, which is handled here:

dqlite/src/conn.c

Lines 156 to 159 in 690818b

if (rv != 0) {
tracef("read gateway handle error %d", rv);
conn__stop(c);
}

So we don't send a failure response and just close the connection instead.

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.

Wire protocol limitations as a backend for the C client
2 participants