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

Commit28d03fe

Browse files
committed
Minor cleanups in the BRIN code
BRIN bloom and minmax-multi opclasses were somewhat inconsistent whendealing with bool variables, assigning to them Datum values etc. Whilenot a bug, it makes the code harder to understand, so fix that.While at it, update an incorrect comment copied to bloom opclass fromminmax, talking about strategies not supported by bloom.Reviewed-by: Heikki LinnakangasDiscussion:https://postgr.es/m/0e1f3350-c9cf-ab62-43a5-5dae314de89c%40enterprisedb.com
1 parent4f49b3f commit28d03fe

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

‎src/backend/access/brin/brin_bloom.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ brin_bloom_consistent(PG_FUNCTION_ARGS)
574574
Oidcolloid=PG_GET_COLLATION();
575575
AttrNumberattno;
576576
Datumvalue;
577-
Datummatches;
577+
boolmatches;
578578
FmgrInfo*finfo;
579579
uint32hashValue;
580580
BloomFilter*filter;
@@ -584,6 +584,10 @@ brin_bloom_consistent(PG_FUNCTION_ARGS)
584584

585585
Assert(filter);
586586

587+
/*
588+
* Assume all scan keys match. We'll be searching for a scan key eliminating
589+
* the page range (we can stop on the first such key).
590+
*/
587591
matches= true;
588592

589593
for (keyno=0;keyno<nkeys;keyno++)
@@ -601,9 +605,8 @@ brin_bloom_consistent(PG_FUNCTION_ARGS)
601605
caseBloomEqualStrategyNumber:
602606

603607
/*
604-
* In the equality case (WHERE col = someval), we want to
605-
* return the current page range if the minimum value in the
606-
* range <= scan key, and the maximum value >= scan key.
608+
* We want to return the current page range if the bloom filter
609+
* seems to contain the value.
607610
*/
608611
finfo=bloom_get_procinfo(bdesc,attno,PROCNUM_HASH);
609612

@@ -614,15 +617,15 @@ brin_bloom_consistent(PG_FUNCTION_ARGS)
614617
default:
615618
/* shouldn't happen */
616619
elog(ERROR,"invalid strategy number %d",key->sk_strategy);
617-
matches=0;
620+
matches=false;
618621
break;
619622
}
620623

621624
if (!matches)
622625
break;
623626
}
624627

625-
PG_RETURN_DATUM(matches);
628+
PG_RETURN_BOOL(matches);
626629
}
627630

628631
/*

‎src/backend/access/brin/brin_minmax_multi.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2602,7 +2602,7 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
26022602

26032603
for (keyno=0;keyno<nkeys;keyno++)
26042604
{
2605-
Datummatches;
2605+
boolmatches;
26062606
ScanKeykey=keys[keyno];
26072607

26082608
/* NULL keys are handled and filtered-out in bringetbitmap */
@@ -2618,7 +2618,7 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
26182618
finfo=minmax_multi_get_strategy_procinfo(bdesc,attno,subtype,
26192619
key->sk_strategy);
26202620
/* first value from the array */
2621-
matches=FunctionCall2Coll(finfo,colloid,minval,value);
2621+
matches=DatumGetBool(FunctionCall2Coll(finfo,colloid,minval,value));
26222622
break;
26232623

26242624
caseBTEqualStrategyNumber:
@@ -2664,18 +2664,18 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
26642664
finfo=minmax_multi_get_strategy_procinfo(bdesc,attno,subtype,
26652665
key->sk_strategy);
26662666
/* last value from the array */
2667-
matches=FunctionCall2Coll(finfo,colloid,maxval,value);
2667+
matches=DatumGetBool(FunctionCall2Coll(finfo,colloid,maxval,value));
26682668
break;
26692669

26702670
default:
26712671
/* shouldn't happen */
26722672
elog(ERROR,"invalid strategy number %d",key->sk_strategy);
2673-
matches=0;
2673+
matches=false;
26742674
break;
26752675
}
26762676

26772677
/* the range has to match all the scan keys */
2678-
matching &=DatumGetBool(matches);
2678+
matching &=matches;
26792679

26802680
/* once we find a non-matching key, we're done */
26812681
if (!matching)
@@ -2686,7 +2686,7 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
26862686
* have we found a range matching all scan keys? if yes, we're done
26872687
*/
26882688
if (matching)
2689-
PG_RETURN_DATUM(BoolGetDatum(true));
2689+
PG_RETURN_BOOL(true);
26902690
}
26912691

26922692
/*
@@ -2703,7 +2703,7 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
27032703

27042704
for (keyno=0;keyno<nkeys;keyno++)
27052705
{
2706-
Datummatches;
2706+
boolmatches;
27072707
ScanKeykey=keys[keyno];
27082708

27092709
/* we've already dealt with NULL keys at the beginning */
@@ -2723,18 +2723,18 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
27232723

27242724
finfo=minmax_multi_get_strategy_procinfo(bdesc,attno,subtype,
27252725
key->sk_strategy);
2726-
matches=FunctionCall2Coll(finfo,colloid,val,value);
2726+
matches=DatumGetBool(FunctionCall2Coll(finfo,colloid,val,value));
27272727
break;
27282728

27292729
default:
27302730
/* shouldn't happen */
27312731
elog(ERROR,"invalid strategy number %d",key->sk_strategy);
2732-
matches=0;
2732+
matches=false;
27332733
break;
27342734
}
27352735

27362736
/* the range has to match all the scan keys */
2737-
matching &=DatumGetBool(matches);
2737+
matching &=matches;
27382738

27392739
/* once we find a non-matching key, we're done */
27402740
if (!matching)
@@ -2743,10 +2743,10 @@ brin_minmax_multi_consistent(PG_FUNCTION_ARGS)
27432743

27442744
/* have we found a range matching all scan keys? if yes, we're done */
27452745
if (matching)
2746-
PG_RETURN_DATUM(BoolGetDatum(true));
2746+
PG_RETURN_BOOL(true);
27472747
}
27482748

2749-
PG_RETURN_DATUM(BoolGetDatum(false));
2749+
PG_RETURN_BOOL(false);
27502750
}
27512751

27522752
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp