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

Commit7157fe8

Browse files
committed
Fix overly-strict assertions in spgtextproc.c.
spg_text_inner_consistent is capable of reconstructing an empty stringto pass down to the next index level; this happens if we have an emptystring coming in, no prefix, and a dummy node label. (In practice, whatis needed to trigger that is insertion of a whole bunch of empty-stringvalues.) Then, we will arrive at the next level with in->level == 0and a non-NULL (but zero length) in->reconstructedValue, which is validbut the Assert tests weren't expecting it.Per report from Andreas Seltenreich. This has no impact in non-Assertbuilds, so should not be a problem in production, but back-patch toall affected branches anyway.In passing, remove a couple of useless variable initializations andshorten the code by not duplicating DatumGetPointer() calls.
1 parentdf35af2 commit7157fe8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎src/backend/access/spgist/spgtextproc.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@ spg_text_inner_consistent(PG_FUNCTION_ARGS)
403403
spgInnerConsistentIn*in= (spgInnerConsistentIn*)PG_GETARG_POINTER(0);
404404
spgInnerConsistentOut*out= (spgInnerConsistentOut*)PG_GETARG_POINTER(1);
405405
boolcollate_is_c=lc_collate_is_c(PG_GET_COLLATION());
406-
text*reconstrText=NULL;
407-
intmaxReconstrLen=0;
406+
text*reconstructedValue;
407+
text*reconstrText;
408+
intmaxReconstrLen;
408409
text*prefixText=NULL;
409410
intprefixSize=0;
410411
inti;
@@ -420,8 +421,9 @@ spg_text_inner_consistent(PG_FUNCTION_ARGS)
420421
* created by a previous invocation of this routine, and we always emit
421422
* long-format reconstructed values.
422423
*/
423-
Assert(in->level==0 ?DatumGetPointer(in->reconstructedValue)==NULL :
424-
VARSIZE_ANY_EXHDR(DatumGetPointer(in->reconstructedValue))==in->level);
424+
reconstructedValue= (text*)DatumGetPointer(in->reconstructedValue);
425+
Assert(reconstructedValue==NULL ?in->level==0 :
426+
VARSIZE_ANY_EXHDR(reconstructedValue)==in->level);
425427

426428
maxReconstrLen=in->level+1;
427429
if (in->hasPrefix)
@@ -436,7 +438,7 @@ spg_text_inner_consistent(PG_FUNCTION_ARGS)
436438

437439
if (in->level)
438440
memcpy(VARDATA(reconstrText),
439-
VARDATA(DatumGetPointer(in->reconstructedValue)),
441+
VARDATA(reconstructedValue),
440442
in->level);
441443
if (prefixSize)
442444
memcpy(((char*)VARDATA(reconstrText))+in->level,
@@ -560,7 +562,7 @@ spg_text_leaf_consistent(PG_FUNCTION_ARGS)
560562
if (DatumGetPointer(in->reconstructedValue))
561563
reconstrValue=DatumGetTextP(in->reconstructedValue);
562564

563-
Assert(level==0 ?reconstrValue==NULL :
565+
Assert(reconstrValue==NULL ?level==0 :
564566
VARSIZE_ANY_EXHDR(reconstrValue)==level);
565567

566568
/* Reconstruct the full string represented by this leaf tuple */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp