You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(vet): Add default query parameters for explain queries (#2543)
* feat(vet): add default query parameters for vet explain with MySQL
* feat(vet): Add default parameter values for PostgreSQL
Before this change, all parameters to a query would be set to NULL when explaining the query. For both PostgreSQL and MySQL, this caused the explain output to either error or return unhelpful results.
For MySQL, these NULL parameters would cause "Impossible WHERE clause" errors. For PostgreSQL, the EXPLAIN output would return plans without indexes.
The default parameters aren't complete and won't cover all cases. We're working on a fallback mechanism that would allow you to specify the explain parameters values directly. Stay tuned!
---------
Co-authored-by: Andrew Benton <[email protected]>
Copy file name to clipboardExpand all lines: docs/howto/vet.md
+4-2
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,8 @@ rules:
89
89
90
90
### Rules using `EXPLAIN ...` output
91
91
92
+
*Added in v1.20.0*
93
+
92
94
The CEL expression environment has two variables containing `EXPLAIN ...` output,
93
95
`postgresql.explain`and `mysql.explain`. `sqlc` only populates the variable associated with
94
96
your configured database engine, and only when you have a
@@ -100,15 +102,15 @@ For the `postgresql` engine, `sqlc` runs
100
102
EXPLAIN (ANALYZE false, VERBOSE, COSTS, SETTINGS, BUFFERS, FORMAT JSON) ...
101
103
```
102
104
103
-
where `"..."` is your query string, and parses the output into a `PostgreSQLExplain` proto message.
105
+
where `"..."` is your query string, and parses the output into a [`PostgreSQLExplain`](https://buf.build/sqlc/sqlc/docs/v1.20.0:vet#vet.PostgreSQLExplain) proto message.
104
106
105
107
For the `mysql` engine, `sqlc` runs
106
108
107
109
```sql
108
110
EXPLAIN FORMAT=JSON ...
109
111
```
110
112
111
-
where `"..."` is your query string, and parses the output into a `MySQLExplain` proto message.
113
+
where `"..."` is your query string, and parses the output into a [`MySQLExplain`](https://buf.build/sqlc/sqlc/docs/v1.20.0:vet#vet.MySQLExplain) proto message.
112
114
113
115
These proto message definitions are too long to include here, but you can find them in the `protos`
0 commit comments