-
Notifications
You must be signed in to change notification settings - Fork 7
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
fix: explain query plan formatting #147
base: main
Are you sure you want to change the base?
Conversation
- in order to keep record of which query generated each result
474ea15
to
6da726b
Compare
63b2ca9
to
57ea872
Compare
internal/db/db.go
Outdated
for _, query := range queries { | ||
if shouldContinue := readQueryResultSet(queryRows, statementResultCh, query); !shouldContinue { | ||
return false | ||
} | ||
|
||
hasResultSetToRead = queryRows.NextResultSet() | ||
hasResultSetToRead = queryRows.NextResultSet() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't wanna to iterate twice here
internal/db/utils.go
Outdated
var explainQueryPlanColumnNames = []string{"id", "parent", "notused", "detail"} | ||
|
||
func queryContainsExplainQueryPlanStatement(query string) bool { | ||
return strings.Contains( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a StartsWith
is safer now, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs: https://www.sqlite.org/lang_explain.html
EXPLAIN QUERY PLAN
always appears in the beggining of statements, bug I agree that having some extra safety woud be nice.
internal/db/utils.go
Outdated
return false | ||
} | ||
for _, colName := range explainQueryPlanColumnNames { | ||
if !slices.Contains(colNames, colName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these ones we can match exactly, not with contains
57ea872
to
853980b
Compare
853980b
to
3eff2e6
Compare
3eff2e6
to
8b0663d
Compare
_, _, err := s.tc.Execute("CREATE TABLE fake_explain (ID INTEGER PRIMARY KEY, PARENT INTEGER, NOTUSED INTEGER, DETAIL TEXT);") | ||
s.tc.Assert(err, qt.IsNil) | ||
|
||
outS, errS, err := s.tc.ExecuteShell([]string{"SELECT * FROM fake_explain;"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't you be testing the EXPLAI QUERY PLAN
command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this is testing that a table with the same column names as the EQP table will still be treated as a normal table (which it should).
Description
Adds an ASCII tree representation to the output of
EXPLAIN QUERY PLAN ...
Related Issues
Visual reference
Here's an example