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

Sqlite EXPLAIN type inference improvements #1984

Merged
merged 3 commits into from
Sep 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions sqlx-core/src/sqlite/connection/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const OP_OPEN_WRITE: &str = "OpenWrite";
const OP_OPEN_EPHEMERAL: &str = "OpenEphemeral";
const OP_OPEN_AUTOINDEX: &str = "OpenAutoindex";
const OP_AGG_FINAL: &str = "AggFinal";
const OP_AGG_VALUE: &str = "AggValue";
const OP_AGG_STEP: &str = "AggStep";
const OP_FUNCTION: &str = "Function";
const OP_MOVE: &str = "Move";
Expand Down Expand Up @@ -727,11 +728,16 @@ pub(super) fn explain(
//else we don't know about the cursor
}

OP_AGG_STEP => {
OP_AGG_STEP | OP_AGG_VALUE => {
//assume that AGG_FINAL will be called
let p4 = from_utf8(p4).map_err(Error::protocol)?;

if p4.starts_with("count(") {
if p4.starts_with("count(")
|| p4.starts_with("row_number(")
|| p4.starts_with("rank(")
|| p4.starts_with("dense_rank(")
|| p4.starts_with("ntile(")
{
// count(_) -> INTEGER
state.r.insert(
p3,
Expand All @@ -749,7 +755,12 @@ pub(super) fn explain(
OP_AGG_FINAL => {
let p4 = from_utf8(p4).map_err(Error::protocol)?;

if p4.starts_with("count(") {
if p4.starts_with("count(")
|| p4.starts_with("row_number(")
|| p4.starts_with("rank(")
|| p4.starts_with("dense_rank(")
|| p4.starts_with("ntile(")
{
// count(_) -> INTEGER
state.r.insert(
p1,
Expand Down