- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit54b1cb7
committed
Fix results of index-only scans on btree_gist char(N) indexes.
If contrib/btree_gist is used to make a GIST index on a char(N)(bpchar) column, and that column is retrieved via an index-onlyscan, what came out had all trailing spaces removed. Sincethat doesn't happen in any other kind of table scan, this isclearly a bug. The cause is that gbt_bpchar_compress() stripstrailing spaces (using rtrim1) before a new index entry is made.That was probably a good idea when this code was first written,but since we invented index-only scans, it's not so good.One answer could be to mark this opclass as incapable of index-onlyscans. But to do so, we'd need an extension module version bump,followed by manual action by DBAs to install the updated versionof btree_gist. And it's not really a desirable place to end up,anyway.Instead, let's fix the code by removing the unwanted space-strippingaction and adjusting the opclass's comparison logic to ignoretrailing spaces as bpchar normally does. This will not hindercases that work today, since index searches with this logic willact the same whether trailing spaces are stored or not. It willnot by itself fix the problem of getting space-stripped resultsfrom index-only scans, of course. Users who care about that canREINDEX affected indexes after installing this update, to immediatelyreplace all improperly-truncated index entries. Otherwise, it canbe expected that the index's behavior will change incrementally asold entries are replaced by new ones.Per report from Alexander Lakhin. Back-patch to all supported branches.Discussion:https://postgr.es/m/696c995b-b37f-5526-f45d-04abe713179f@gmail.com1 parentf1e9085 commit54b1cb7
3 files changed
+82
-34
lines changedLines changed: 76 additions & 28 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
90 | 90 |
| |
91 | 91 |
| |
92 | 92 |
| |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
93 | 163 |
| |
94 | 164 |
| |
95 | 165 |
| |
| |||
112 | 182 |
| |
113 | 183 |
| |
114 | 184 |
| |
115 |
| - | |
116 |
| - | |
117 |
| - | |
118 |
| - | |
119 |
| - | |
120 |
| - | |
121 |
| - | |
122 |
| - | |
123 |
| - | |
124 |
| - | |
125 |
| - | |
126 |
| - | |
127 |
| - | |
128 |
| - | |
129 |
| - | |
130 |
| - | |
131 |
| - | |
132 |
| - | |
133 |
| - | |
134 |
| - | |
135 |
| - | |
136 |
| - | |
137 |
| - | |
| 185 | + | |
| 186 | + | |
138 | 187 |
| |
139 | 188 |
| |
140 | 189 |
| |
| |||
179 | 228 |
| |
180 | 229 |
| |
181 | 230 |
| |
182 |
| - | |
183 | 231 |
| |
184 | 232 |
| |
185 | 233 |
| |
186 | 234 |
| |
187 |
| - | |
| 235 | + | |
188 | 236 |
| |
189 |
| - | |
| 237 | + | |
190 | 238 |
| |
191 | 239 |
| |
192 |
| - | |
193 |
| - | |
| 240 | + | |
| 241 | + | |
194 | 242 |
| |
195 | 243 |
| |
196 | 244 |
| |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
75 | 75 |
| |
76 | 76 |
| |
77 | 77 |
| |
78 |
| - | |
79 |
| - | |
80 |
| - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
81 | 81 |
| |
82 | 82 |
|
Lines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
75 | 75 |
| |
76 | 76 |
| |
77 | 77 |
| |
78 |
| - | |
79 |
| - | |
80 |
| - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
81 | 81 |
| |
82 | 82 |
|
0 commit comments
Comments
(0)