- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit4604928
committed
Fix failure for generated column with a not-null domain constraint.
If a GENERATED column is declared to have a domain data type wherethe domain's constraints disallow null values, INSERT commands failedbecause we built a targetlist that included coercing a null constantto the domain's type. The failure occurred even when the generatedvalue would have been perfectly OK. This is adjacent to the issuesfixed in0da39aa, but we didn't notice for lack of testing a domainwith such a constraint.We aren't going to use the result of the targetlist entry for thegenerated column --- ExecComputeStoredGenerated will overwrite it.So it's not really necessary that it have the exact datatype ofthe generated column. This patch fixes the problem by changingthe targetlist entry to be a null Const of the domain's base type,which should be sufficiently legal. (We do have to tweakExecCheckPlanOutput to accept the situation, though.)This has been broken since we implemented generated columns.However, this patch only applies easily as far back as v14, partlybecause I (tgl) only carried0da39aa back that far, but mostlybecause v14 significantly refactored the handling of INSERT/UPDATEtargetlists. Given the lack of field complaints and the shortremaining support lifetime of v13, I judge the cost-benefit rationot good for devising a version that would work in v13.Reported-by: jian he <jian.universality@gmail.com>Author: jian he <jian.universality@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/CACJufxG59tip2+9h=rEv-ykOFjt0cbsPVchhi0RTij8bABBA0Q@mail.gmail.comBackpatch-through: 141 parent1b47a11 commit4604928
File tree
4 files changed
+80
-27
lines changed- src
- backend
- executor
- optimizer/prep
- test/regress
- expected
- sql
4 files changed
+80
-27
lines changedLines changed: 32 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
129 | 129 |
| |
130 | 130 |
| |
131 | 131 |
| |
132 |
| - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
133 | 136 |
| |
134 |
| - | |
135 |
| - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
136 | 144 |
| |
137 | 145 |
| |
138 | 146 |
| |
139 |
| - | |
140 |
| - | |
141 |
| - | |
142 |
| - | |
| 147 | + | |
| 148 | + | |
143 | 149 |
| |
144 |
| - | |
| 150 | + | |
145 | 151 |
| |
146 | 152 |
| |
147 |
| - | |
148 |
| - | |
149 |
| - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
150 | 158 |
| |
151 | 159 |
| |
152 | 160 |
| |
153 | 161 |
| |
154 | 162 |
| |
155 | 163 |
| |
156 |
| - | |
| 164 | + | |
157 | 165 |
| |
158 | 166 |
| |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
159 | 179 |
| |
160 | 180 |
| |
161 | 181 |
| |
|
Lines changed: 38 additions & 15 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
44 | 44 |
| |
45 | 45 |
| |
46 | 46 |
| |
| 47 | + | |
47 | 48 |
| |
48 | 49 |
| |
49 | 50 |
| |
| |||
334 | 335 |
| |
335 | 336 |
| |
336 | 337 |
| |
337 |
| - | |
338 |
| - | |
339 |
| - | |
| 338 | + | |
| 339 | + | |
340 | 340 |
| |
341 | 341 |
| |
342 | 342 |
| |
| |||
346 | 346 |
| |
347 | 347 |
| |
348 | 348 |
| |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
349 | 356 |
| |
350 | 357 |
| |
351 | 358 |
| |
352 |
| - | |
353 |
| - | |
354 |
| - | |
355 |
| - | |
356 |
| - | |
357 |
| - | |
358 |
| - | |
359 |
| - | |
360 |
| - | |
361 |
| - | |
362 |
| - | |
363 |
| - | |
| 359 | + | |
364 | 360 |
| |
365 | 361 |
| |
366 | 362 |
| |
| |||
371 | 367 |
| |
372 | 368 |
| |
373 | 369 |
| |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
374 | 397 |
| |
375 | 398 |
| |
376 | 399 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
685 | 685 |
| |
686 | 686 |
| |
687 | 687 |
| |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
688 | 693 |
| |
689 | 694 |
| |
690 | 695 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
361 | 361 |
| |
362 | 362 |
| |
363 | 363 |
| |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
364 | 369 |
| |
365 | 370 |
| |
366 | 371 |
| |
|
0 commit comments
Comments
(0)