- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit06450c7
committed
Fix regression with location calculation of nested statements
The statement location calculated for some nested query cases was wrongwhen multiple queries are sent as a single string, these being separatedby semicolons. As pointed by Sami Imseih, the location calculation wasincorrect when the last query of nested statement with multiple queriesdoes **NOT** finish with a semicolon for the last statement. In thiscase, the statement length tracked by RawStmt is 0, which is equivalentto say that the string should be used until its end. The codepreviously discarded this case entirely, causing the location to remainat 0, the same as pointing at the beginning of the string. This causedpg_stat_statements to store incorrect query strings.This issue has been introduced in499edb0. I have looked at thediffs generated by pgaudit back then, and noticed the differencegenerated for this nested query case, but I have missed the point thatit was an actual regression with an existing case. A test case is addedin pg_stat_statements to provide some coverage, restoring the pre-17behavior for the calculation of the query locations. Special thanks toDavid Steele, who, through an analysis of the test diffs generated bypgaudit with the new v18 logic, has poked me about the fact that myoriginal analysis of the matter was wrong.The test output of pg_overexplain is updated to reflect the new logic,as the new locations refer to the beginning of the argument passed tothe function explain_filter(). When the module was introduced in8d5ceb1, which was after499edb0 (for the new calculationmethod), the locations of the test were not actually right: the plangenerated for the query string given in input of the function pointed tothe top-level query, not the nested one.Reported-by: David Steele <david@pgbackrest.org>Author: Michael Paquier <michael@paquier.xyz>Reviewed-by: Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>Reviewed-by: Jian He <jian.universality@gmail.com>Reviewed-by: Sami Imseih <samimseih@gmail.com>Reviewed-by: David Steele <david@pgbackrest.org>Discussion:https://postgr.es/m/844a3b38-bbf1-4fb2-9fd6-f58c35c09917@pgbackrest.org1 parenta6060f1 commit06450c7
File tree
4 files changed
+87
-15
lines changed- contrib
- pg_overexplain/expected
- pg_stat_statements
- expected
- sql
- src/backend/parser
4 files changed
+87
-15
lines changedLines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
119 | 119 |
| |
120 | 120 |
| |
121 | 121 |
| |
122 |
| - | |
| 122 | + | |
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
| |||
240 | 240 |
| |
241 | 241 |
| |
242 | 242 |
| |
243 |
| - | |
| 243 | + | |
244 | 244 |
| |
245 | 245 |
| |
246 | 246 |
| |
| |||
344 | 344 |
| |
345 | 345 |
| |
346 | 346 |
| |
347 |
| - | |
| 347 | + | |
348 | 348 |
| |
349 | 349 |
| |
350 | 350 |
| |
| |||
372 | 372 |
| |
373 | 373 |
| |
374 | 374 |
| |
375 |
| - | |
| 375 | + | |
376 | 376 |
| |
377 | 377 |
| |
378 | 378 |
| |
|
Lines changed: 51 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1319 | 1319 |
| |
1320 | 1320 |
| |
1321 | 1321 |
| |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
1322 | 1373 |
| |
1323 | 1374 |
| |
1324 | 1375 |
| |
|
Lines changed: 26 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
334 | 334 |
| |
335 | 335 |
| |
336 | 336 |
| |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
337 | 363 |
| |
338 | 364 |
| |
339 | 365 |
| |
|
Lines changed: 6 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
253 | 253 |
| |
254 | 254 |
| |
255 | 255 |
| |
256 |
| - | |
| 256 | + | |
| 257 | + | |
257 | 258 |
| |
258 | 259 |
| |
259 | 260 |
| |
260 | 261 |
| |
261 | 262 |
| |
262 | 263 |
| |
263 |
| - | |
264 |
| - | |
265 |
| - | |
266 |
| - | |
267 |
| - | |
268 |
| - | |
269 |
| - | |
270 | 264 |
| |
271 | 265 |
| |
272 | 266 |
| |
| |||
308 | 302 |
| |
309 | 303 |
| |
310 | 304 |
| |
311 |
| - | |
| 305 | + | |
312 | 306 |
| |
313 | 307 |
| |
314 |
| - | |
315 |
| - | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
316 | 311 |
| |
317 | 312 |
| |
318 | 313 |
| |
|
0 commit comments
Comments
(0)