- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit23e2a06
committed
Yet further fixes for multi-row VALUES lists for updatable views.
DEFAULT markers appearing in an INSERT on an updatable viewcould be mis-processed if they were in a multi-row VALUES clause.This would lead to strange errors such as "cache lookup failedfor type NNNN", or in older branches even to crashes.The cause is that commit41531e4 tried to re-use rewriteValuesRTE()to remove any SetToDefault nodes (that hadn't previously been replacedby the view's own default values) appearing in "product" queries,that is DO ALSO queries. That's fundamentally wrong because theDO ALSO queries might not even be INSERTs; and even if they are,their targetlists don't necessarily match the view's column list,so that almost all the logic in rewriteValuesRTE() is inapplicable.What we want is a narrow focus on replacing any such nodes with NULLconstants. (That is, in this context we are interpreting the defaultsas being strictly those of the view itself; and we already replacedany that aren't NULL.) We could add still more !force_nulls teststo further lobotomize rewriteValuesRTE(); but it seems cleaner tosplit out this case to a new function, restoring rewriteValuesRTE()to the charter it had before.Per bug #17633 from jiye_sw. Patch by me, but thanks toRichard Guo and Japin Li for initial investigation.Back-patch to all supported branches, as the previous fix was.Discussion:https://postgr.es/m/17633-98cc85e1fa91e905@postgresql.org1 parent8bf4705 commit23e2a06
File tree
3 files changed
+97
-26
lines changed- src
- backend/rewrite
- test/regress
- expected
- sql
3 files changed
+97
-26
lines changedLines changed: 58 additions & 26 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
75 |
| - | |
| 75 | + | |
| 76 | + | |
76 | 77 |
| |
77 | 78 |
| |
78 | 79 |
| |
| |||
1233 | 1234 |
| |
1234 | 1235 |
| |
1235 | 1236 |
| |
1236 |
| - | |
1237 |
| - | |
1238 |
| - | |
1239 |
| - | |
1240 |
| - | |
1241 |
| - | |
1242 |
| - | |
1243 |
| - | |
1244 |
| - | |
1245 |
| - | |
1246 |
| - | |
1247 | 1237 |
| |
1248 | 1238 |
| |
1249 | 1239 |
| |
| |||
1256 | 1246 |
| |
1257 | 1247 |
| |
1258 | 1248 |
| |
1259 |
| - | |
| 1249 | + | |
1260 | 1250 |
| |
1261 | 1251 |
| |
1262 | 1252 |
| |
| |||
1265 | 1255 |
| |
1266 | 1256 |
| |
1267 | 1257 |
| |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
1268 | 1262 |
| |
1269 | 1263 |
| |
1270 | 1264 |
| |
1271 | 1265 |
| |
1272 |
| - | |
1273 |
| - | |
1274 |
| - | |
1275 | 1266 |
| |
1276 |
| - | |
| 1267 | + | |
1277 | 1268 |
| |
1278 | 1269 |
| |
1279 | 1270 |
| |
| |||
1307 | 1298 |
| |
1308 | 1299 |
| |
1309 | 1300 |
| |
1310 |
| - | |
1311 |
| - | |
| 1301 | + | |
1312 | 1302 |
| |
1313 | 1303 |
| |
1314 |
| - | |
1315 |
| - | |
| 1304 | + | |
1316 | 1305 |
| |
1317 | 1306 |
| |
1318 | 1307 |
| |
| |||
1370 | 1359 |
| |
1371 | 1360 |
| |
1372 | 1361 |
| |
| 1362 | + | |
1373 | 1363 |
| |
1374 | 1364 |
| |
1375 |
| - | |
| 1365 | + | |
1376 | 1366 |
| |
1377 | 1367 |
| |
1378 | 1368 |
| |
| |||
1422 | 1412 |
| |
1423 | 1413 |
| |
1424 | 1414 |
| |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
1425 | 1459 |
| |
1426 | 1460 |
| |
1427 | 1461 |
| |
| |||
3578 | 3612 |
| |
3579 | 3613 |
| |
3580 | 3614 |
| |
3581 |
| - | |
| 3615 | + | |
3582 | 3616 |
| |
3583 | 3617 |
| |
3584 | 3618 |
| |
| |||
3655 | 3689 |
| |
3656 | 3690 |
| |
3657 | 3691 |
| |
3658 |
| - | |
3659 |
| - | |
3660 |
| - | |
| 3692 | + | |
3661 | 3693 |
| |
3662 | 3694 |
| |
3663 | 3695 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
431 | 431 |
| |
432 | 432 |
| |
433 | 433 |
| |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
434 | 455 |
| |
435 | 456 |
| |
| 457 | + | |
436 | 458 |
| |
437 | 459 |
| |
438 | 460 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
145 | 145 |
| |
146 | 146 |
| |
147 | 147 |
| |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
148 | 164 |
| |
| 165 | + | |
149 | 166 |
| |
150 | 167 |
| |
151 | 168 |
| |
|
0 commit comments
Comments
(0)