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

Commit45b315e

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 parent932ab74 commit45b315e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

‎contrib/btree_gist/btree_utils_var.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,40 +233,40 @@ gbt_var_node_truncate(const GBT_VARKEY *node, int32 cpf_length, const gbtree_vin
233233
void
234234
gbt_var_bin_union(Datum*u,GBT_VARKEY*e,constgbtree_vinfo*tinfo)
235235
{
236-
237-
GBT_VARKEY*nk=NULL;
238-
GBT_VARKEY*tmp=NULL;
239-
GBT_VARKEY_Rnr;
240236
GBT_VARKEY_Reo=gbt_var_key_readable(e);
237+
GBT_VARKEY_Rnr;
241238

242239
if (eo.lower==eo.upper)/* leaf */
243240
{
241+
GBT_VARKEY*tmp;
242+
244243
tmp=gbt_var_leaf2node(e,tinfo);
245244
if (tmp!=e)
246245
eo=gbt_var_key_readable(tmp);
247246
}
248247

249248
if (DatumGetPointer(*u))
250249
{
251-
252250
GBT_VARKEY_Rro=gbt_var_key_readable((GBT_VARKEY*)DatumGetPointer(*u));
251+
boolupdate= false;
252+
253+
nr.lower=ro.lower;
254+
nr.upper=ro.upper;
253255

254256
if ((*tinfo->f_cmp) ((bytea*)ro.lower, (bytea*)eo.lower)>0)
255257
{
256258
nr.lower=eo.lower;
257-
nr.upper=ro.upper;
258-
nk=gbt_var_key_copy(&nr, TRUE);
259+
update= true;
259260
}
260261

261262
if ((*tinfo->f_cmp) ((bytea*)ro.upper, (bytea*)eo.upper)<0)
262263
{
263264
nr.upper=eo.upper;
264-
nr.lower=ro.lower;
265-
nk=gbt_var_key_copy(&nr, TRUE);
265+
update= true;
266266
}
267267

268-
if (nk)
269-
*u=PointerGetDatum(nk);
268+
if (update)
269+
*u=PointerGetDatum(gbt_var_key_copy(&nr, TRUE));
270270
}
271271
else
272272
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp