forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcabe0f2
committed
Fix "ANALYZE t, t" inside a transaction block.
This failed with either "tuple already updated by self" or "duplicatekey value violates unique constraint", depending on whether the tablehad previously been analyzed or not. The reason is that ANALYZE triedto insert or update the same pg_statistic rows twice, and there was noCommandCounterIncrement between. So add one. The same case works fineoutside a transaction block, because then there's a whole transactionboundary between, as a consequence of the way VACUUM works.This issue has been latent all along, but the problem was unreachablebefore commit11d8d72 added the ability to specify multiple tablesin ANALYZE. We could, perhaps, alternatively fix it by adding code tode-duplicate the list of VacuumRelations --- but that would add alot of overhead to work around dumb commands, so it's not attractive.Per bug #15946 from Yaroslav Schekin. Back-patch to v11.(Note: in v11 I also back-patched the test added by commit2322456;otherwise the problem doesn't manifest in the test I added, because"vactst" is empty when the tests for multiple ANALYZE targets arereached. That seems like not a very good thing anyway, so I did thisrather than rethinking the choice of test case.)Discussion:https://postgr.es/m/15946-5c7570a2884a26cf@postgresql.org1 parentd8cd68c commitcabe0f2
File tree
3 files changed
+17
-0
lines changed- src
- backend/commands
- test/regress
- expected
- sql
3 files changed
+17
-0
lines changedLines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
418 | 418 |
| |
419 | 419 |
| |
420 | 420 |
| |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
421 | 430 |
| |
422 | 431 |
| |
423 | 432 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
180 | 180 |
| |
181 | 181 |
| |
182 | 182 |
| |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
183 | 187 |
| |
184 | 188 |
| |
185 | 189 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
147 | 147 |
| |
148 | 148 |
| |
149 | 149 |
| |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
150 | 154 |
| |
151 | 155 |
| |
152 | 156 |
| |
|
0 commit comments
Comments
(0)