Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit94f565d

Browse files
committed
Fix erroneous range-union logic for varlena types in contrib/btree_gist.
gbt_var_bin_union() failed to do the right thing when the existing rangeneeded to be widened at both ends rather than just one end. This couldresult in an invalid index in which keys that are present would not befound by searches, because the searches would not think they need todescend to the relevant leaf pages. This error affected all the varlenadatatypes supported by btree_gist (text, bytea, bit, numeric).Per investigation of a trouble report from Tomas Vondra. (There is alsoan issue in gbt_var_penalty(), but that should only result in inefficiencynot wrong answers. I'm committing this separately so that we have a gitstate in which it can be tested that bad penalty results don't produceinvalid indexes.) Back-patch to all supported branches.
1 parent166d534 commit94f565d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

‎contrib/btree_gist/btree_utils_var.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,39 +225,40 @@ void
225225
gbt_var_bin_union(Datum*u,GBT_VARKEY*e,Oidcollation,
226226
constgbtree_vinfo*tinfo)
227227
{
228-
GBT_VARKEY*nk=NULL;
229-
GBT_VARKEY*tmp=NULL;
230-
GBT_VARKEY_Rnr;
231228
GBT_VARKEY_Reo=gbt_var_key_readable(e);
229+
GBT_VARKEY_Rnr;
232230

233231
if (eo.lower==eo.upper)/* leaf */
234232
{
233+
GBT_VARKEY*tmp;
234+
235235
tmp=gbt_var_leaf2node(e,tinfo);
236236
if (tmp!=e)
237237
eo=gbt_var_key_readable(tmp);
238238
}
239239

240240
if (DatumGetPointer(*u))
241241
{
242-
243242
GBT_VARKEY_Rro=gbt_var_key_readable((GBT_VARKEY*)DatumGetPointer(*u));
243+
boolupdate= false;
244+
245+
nr.lower=ro.lower;
246+
nr.upper=ro.upper;
244247

245248
if ((*tinfo->f_cmp) (ro.lower,eo.lower,collation)>0)
246249
{
247250
nr.lower=eo.lower;
248-
nr.upper=ro.upper;
249-
nk=gbt_var_key_copy(&nr, TRUE);
251+
update= true;
250252
}
251253

252254
if ((*tinfo->f_cmp) (ro.upper,eo.upper,collation)<0)
253255
{
254256
nr.upper=eo.upper;
255-
nr.lower=ro.lower;
256-
nk=gbt_var_key_copy(&nr, TRUE);
257+
update= true;
257258
}
258259

259-
if (nk)
260-
*u=PointerGetDatum(nk);
260+
if (update)
261+
*u=PointerGetDatum(gbt_var_key_copy(&nr, TRUE));
261262
}
262263
else
263264
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp