Commit 9c20554
committed
fix(extended-query): populate fields in do_describe_statement
pgwire 0.39's `DescribeStatementResponse::is_no_data()` returns true
when both `parameters` and `fields` are empty, in which case the
framework sends `NoData` to the client. tokio-postgres takes its
column schema from `Describe Statement` (it doesn't issue
`Describe Portal` automatically during `client.query()`), so an
empty fields list left the client with a zero-column Statement and
`rows[0].get(0)` failed with "invalid column 0".
Run the pipeline at Describe Statement time for row-returning queries
(SELECT, WITH, set ops) and return the schema. For DML/DDL/SET we
return `no_data` *without* running the pipeline, so an INSERT or
UPDATE prepared via `client.prepare()` doesn't execute side effects
before Bind/Execute.
The cost is one extra Trino round-trip per `prepare()` of a
row-returning query. The Stream from this run is dropped; Trino's
server-side state is freed via its own TTL. Cleaning that up with an
explicit `DELETE /v1/statement/{id}` is the same `TODO(cancel)` already
tracked in `do_describe_portal`.
Adds `ParsedQuery::returns_rows()` for the AST-level pre-check.
After the fix:
- `test_extended_catalog_intercept` and the catalog-emulation paths
through the extended protocol now pass.
- The 28 simple-query integration tests are unaffected.
Three new extended-protocol tests (`test_extended_prepared_select`,
`test_extended_re_execute`, `test_extended_two_prepared_statements`)
remain blocked behind a separate issue: tokio-postgres' Bind
hardcodes binary format for every result column, but our DataRow
encoder emits text only. pgwire 0.39 stores `portal.result_column_format`
but its default encode path doesn't honor it. Marked `#[ignore]` with
a pointer to the README's "Wire format" section; runnable on demand
with `cargo test -- --ignored` once binary support lands (either as an
upstream pgwire fix or our own re-encoding wrapper).
Verified against a real Trino deployed on Stackable Data Platform:
28 passed, 0 failed, 3 ignored.1 parent 75aa3bb commit 9c20554
3 files changed
Lines changed: 76 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
146 | 149 | | |
147 | 150 | | |
148 | 151 | | |
149 | | - | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| |||
156 | 159 | | |
157 | 160 | | |
158 | 161 | | |
159 | | - | |
| 162 | + | |
| 163 | + | |
160 | 164 | | |
161 | 165 | | |
162 | 166 | | |
163 | 167 | | |
164 | | - | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
165 | 209 | | |
166 | 210 | | |
167 | 211 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
161 | 177 | | |
162 | 178 | | |
163 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1057 | 1057 | | |
1058 | 1058 | | |
1059 | 1059 | | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
1060 | 1069 | | |
| 1070 | + | |
1061 | 1071 | | |
1062 | 1072 | | |
1063 | 1073 | | |
| |||
1080 | 1090 | | |
1081 | 1091 | | |
1082 | 1092 | | |
| 1093 | + | |
1083 | 1094 | | |
1084 | 1095 | | |
1085 | 1096 | | |
| |||
1104 | 1115 | | |
1105 | 1116 | | |
1106 | 1117 | | |
| 1118 | + | |
1107 | 1119 | | |
1108 | 1120 | | |
1109 | 1121 | | |
| |||
0 commit comments