Skip to content

Commit

Permalink
Sqlite EXPLAIN type inference improvements (#1984)
Browse files Browse the repository at this point in the history
* AggValue and ROW_NUMBER()

* Some more functions

* cargo fmt
  • Loading branch information
rongcuid authored and Aandreba committed Mar 31, 2023
1 parent a0e1f4a commit e021663
Showing 1 changed file with 14 additions and 3 deletions.
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

0 comments on commit e021663

Please sign in to comment.