forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6572bd5
committed
Prevent RLS filters on ctid from breaking WHERE CURRENT OF <cursor>.
The executor only supports CurrentOfExpr as the sole tidqual of aTidScan plan node. tidpath.c failed to take any particular care aboutthat, but would just take the first ctid equality qual it could findin the target relation's baserestrictinfo list. Originally that wasfine because the grammar prevents any other WHERE conditions frombeing combined with CURRENT OF <cursor>. However, if the relation hasRLS visibility policies then those would get included in the list.Should such a policy include a condition on ctid, we'd typically grabthe wrong qual and produce a malfunctioning plan.To fix, introduce a simplistic priority ordering scheme for which ctidequality qual to prefer. Real-world cases involving more than onesuch qual are so rare that it doesn't seem worth going to any greattrouble to choose one over another, so I didn't work very hard; butthis code could be extended in future if someone thinks differently.It's extremely difficult to think of a reasonable use-case for an RLSrestriction involving ctid, and certainly we've heard no field reportsof this failure. So this doesn't seem worthy of back-patching, butin the name of cleanliness let's fix it going forward.Patch by me, per report from Robert Haas.Discussion:https://postgr.es/m/3914881.1715038270@sss.pgh.pa.us1 parent09fe965 commit6572bd5
File tree
3 files changed
+118
-30
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+118
-30
lines changedLines changed: 58 additions & 30 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
225 | 225 |
| |
226 | 226 |
| |
227 | 227 |
| |
228 |
| - | |
229 |
| - | |
230 |
| - | |
231 |
| - | |
232 |
| - | |
| 228 | + | |
233 | 229 |
| |
234 | 230 |
| |
235 |
| - | |
236 |
| - | |
| 231 | + | |
237 | 232 |
| |
238 |
| - | |
239 |
| - | |
| 233 | + | |
| 234 | + | |
240 | 235 |
| |
241 | 236 |
| |
242 | 237 |
| |
243 | 238 |
| |
244 | 239 |
| |
245 | 240 |
| |
246 |
| - | |
| 241 | + | |
247 | 242 |
| |
248 | 243 |
| |
249 | 244 |
| |
250 | 245 |
| |
251 | 246 |
| |
252 | 247 |
| |
253 |
| - | |
| 248 | + | |
254 | 249 |
| |
255 | 250 |
| |
256 |
| - | |
| 251 | + | |
257 | 252 |
| |
258 | 253 |
| |
259 | 254 |
| |
260 | 255 |
| |
261 |
| - | |
| 256 | + | |
262 | 257 |
| |
263 |
| - | |
| 258 | + | |
264 | 259 |
| |
265 | 260 |
| |
266 | 261 |
| |
| |||
270 | 265 |
| |
271 | 266 |
| |
272 | 267 |
| |
273 |
| - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
274 | 278 |
| |
275 | 279 |
| |
276 | 280 |
| |
277 | 281 |
| |
278 |
| - | |
| 282 | + | |
| 283 | + | |
279 | 284 |
| |
280 | 285 |
| |
281 | 286 |
| |
| |||
284 | 289 |
| |
285 | 290 |
| |
286 | 291 |
| |
| 292 | + | |
287 | 293 |
| |
288 | 294 |
| |
289 | 295 |
| |
| |||
308 | 314 |
| |
309 | 315 |
| |
310 | 316 |
| |
311 |
| - | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
312 | 321 |
| |
313 | 322 |
| |
314 | 323 |
| |
| |||
326 | 335 |
| |
327 | 336 |
| |
328 | 337 |
| |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
329 | 348 |
| |
330 | 349 |
| |
331 | 350 |
| |
332 | 351 |
| |
333 |
| - | |
334 |
| - | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
335 | 357 |
| |
336 |
| - | |
337 |
| - | |
338 |
| - | |
339 |
| - | |
340 |
| - | |
341 |
| - | |
342 |
| - | |
343 |
| - | |
344 |
| - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
345 | 367 |
| |
346 | 368 |
| |
347 |
| - | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
348 | 376 |
| |
349 | 377 |
| |
350 | 378 |
| |
| |||
405 | 433 |
| |
406 | 434 |
| |
407 | 435 |
| |
408 |
| - | |
| 436 | + | |
409 | 437 |
| |
410 | 438 |
| |
411 | 439 |
| |
|
Lines changed: 41 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3921 | 3921 |
| |
3922 | 3922 |
| |
3923 | 3923 |
| |
| 3924 | + | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
| 3931 | + | |
| 3932 | + | |
| 3933 | + | |
| 3934 | + | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
| 3941 | + | |
| 3942 | + | |
| 3943 | + | |
| 3944 | + | |
| 3945 | + | |
| 3946 | + | |
| 3947 | + | |
| 3948 | + | |
| 3949 | + | |
| 3950 | + | |
| 3951 | + | |
| 3952 | + | |
| 3953 | + | |
| 3954 | + | |
| 3955 | + | |
| 3956 | + | |
| 3957 | + | |
| 3958 | + | |
| 3959 | + | |
| 3960 | + | |
| 3961 | + | |
| 3962 | + | |
| 3963 | + | |
| 3964 | + | |
3924 | 3965 |
| |
3925 | 3966 |
| |
3926 | 3967 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1726 | 1726 |
| |
1727 | 1727 |
| |
1728 | 1728 |
| |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
1729 | 1748 |
| |
1730 | 1749 |
| |
1731 | 1750 |
| |
|
0 commit comments
Comments
(0)