forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9dfb5b9
committed
Fix multiple bugs in contrib/pgstattuple's pgstatindex() function.
Dead or half-dead index leaf pages were incorrectly reported as live, as aconsequence of a code rearrangement I made (during a moment of severe brainfade, evidently) in commitd287818.The index metapage was not counted in index_size, causing that result tonot agree with the actual index size on-disk.Index root pages were not counted in internal_pages, which is inconsistentcompared to the case of a root that's also a leaf (one-page index), wherethe root would be counted in leaf_pages. Aside from that inconsistency,this could lead to additional transient discrepancies between the reportedpage counts and index_size, since it's possible for pgstatindex's scan tosee zero or multiple pages marked as BTP_ROOT, if the root moves due toa split during the scan. With these fixes, index_size will always beexactly one page more than the sum of the displayed page counts.Also, the index_size result was incorrectly documented as being measured inpages; it's always been measured in bytes. (While fixing that, I couldn'tresist doing some small additional wordsmithing on the pgstattuple docs.)Including the metapage causes the reported index_size to not be zero foran empty index. To preserve the desired property that the pgstattupleregression test results are platform-independent (ie, BLCKSZ configurationindependent), scale the index_size result in the regression tests.The documentation issue was reported by Otsuka Kenji, and the inconsistentroot page counting by Peter Geoghegan; the other problems noted by me.Back-patch to all supported branches, because this has been broken fora long time.1 parentb3ec98c commit9dfb5b9
File tree
4 files changed
+28
-17
lines changed- contrib/pgstattuple
- expected
- sql
- doc/src/sgml
4 files changed
+28
-17
lines changedLines changed: 6 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
17 | 17 |
| |
18 | 18 |
| |
19 | 19 |
| |
20 |
| - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
21 | 25 |
| |
22 | 26 |
| |
23 |
| - | |
| 27 | + | |
24 | 28 |
| |
25 | 29 |
| |
26 | 30 |
| |
|
Lines changed: 6 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
75 |
| - | |
76 | 75 |
| |
77 | 76 |
| |
78 | 77 |
| |
| |||
153 | 152 |
| |
154 | 153 |
| |
155 | 154 |
| |
156 |
| - | |
157 | 155 |
| |
158 | 156 |
| |
159 | 157 |
| |
| |||
186 | 184 |
| |
187 | 185 |
| |
188 | 186 |
| |
189 |
| - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
190 | 192 |
| |
191 | 193 |
| |
192 | 194 |
| |
| |||
203 | 205 |
| |
204 | 206 |
| |
205 | 207 |
| |
206 |
| - | |
207 |
| - | |
208 |
| - | |
209 |
| - | |
210 |
| - | |
211 |
| - | |
212 | 208 |
| |
213 | 209 |
| |
214 | 210 |
| |
| |||
240 | 236 |
| |
241 | 237 |
| |
242 | 238 |
| |
243 |
| - | |
| 239 | + | |
244 | 240 |
| |
245 | 241 |
| |
246 | 242 |
| |
|
Lines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11 | 11 |
| |
12 | 12 |
| |
13 | 13 |
| |
14 |
| - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 |
| |
16 | 20 |
| |
17 | 21 |
| |
|
Lines changed: 11 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
153 | 153 |
| |
154 | 154 |
| |
155 | 155 |
| |
156 |
| - | |
| 156 | + | |
157 | 157 |
| |
158 | 158 |
| |
159 | 159 |
| |
160 | 160 |
| |
161 | 161 |
| |
162 |
| - | |
| 162 | + | |
163 | 163 |
| |
164 | 164 |
| |
165 | 165 |
| |
| |||
193 | 193 |
| |
194 | 194 |
| |
195 | 195 |
| |
196 |
| - | |
| 196 | + | |
197 | 197 |
| |
198 | 198 |
| |
199 | 199 |
| |
200 | 200 |
| |
201 | 201 |
| |
202 |
| - | |
| 202 | + | |
203 | 203 |
| |
204 | 204 |
| |
205 | 205 |
| |
| |||
243 | 243 |
| |
244 | 244 |
| |
245 | 245 |
| |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
246 | 253 |
| |
247 | 254 |
| |
248 | 255 |
| |
|
0 commit comments
Comments
(0)