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

Commit7302514

Browse files
committed
Add const qualifiers to internal range type APIs
Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://www.postgresql.org/message-id/flat/dc9b45fa-b950-fadc-4751-85d6f729df55%402ndquadrant.com
1 parentf921ea6 commit7302514

File tree

5 files changed

+86
-86
lines changed

5 files changed

+86
-86
lines changed

‎src/backend/utils/adt/rangetypes.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ elem_contained_by_range(PG_FUNCTION_ARGS)
554554

555555
/* equality (internal version) */
556556
bool
557-
range_eq_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
557+
range_eq_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
558558
{
559559
RangeBoundlower1,
560560
lower2;
@@ -599,7 +599,7 @@ range_eq(PG_FUNCTION_ARGS)
599599

600600
/* inequality (internal version) */
601601
bool
602-
range_ne_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
602+
range_ne_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
603603
{
604604
return (!range_eq_internal(typcache,r1,r2));
605605
}
@@ -645,7 +645,7 @@ range_contained_by(PG_FUNCTION_ARGS)
645645

646646
/* strictly left of? (internal version) */
647647
bool
648-
range_before_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
648+
range_before_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
649649
{
650650
RangeBoundlower1,
651651
lower2;
@@ -683,7 +683,7 @@ range_before(PG_FUNCTION_ARGS)
683683

684684
/* strictly right of? (internal version) */
685685
bool
686-
range_after_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
686+
range_after_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
687687
{
688688
RangeBoundlower1,
689689
lower2;
@@ -779,7 +779,7 @@ bounds_adjacent(TypeCacheEntry *typcache, RangeBound boundA, RangeBound boundB)
779779

780780
/* adjacent to (but not overlapping)? (internal version) */
781781
bool
782-
range_adjacent_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
782+
range_adjacent_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
783783
{
784784
RangeBoundlower1,
785785
lower2;
@@ -822,7 +822,7 @@ range_adjacent(PG_FUNCTION_ARGS)
822822

823823
/* overlaps? (internal version) */
824824
bool
825-
range_overlaps_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
825+
range_overlaps_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
826826
{
827827
RangeBoundlower1,
828828
lower2;
@@ -868,7 +868,7 @@ range_overlaps(PG_FUNCTION_ARGS)
868868

869869
/* does not extend to right of? (internal version) */
870870
bool
871-
range_overleft_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
871+
range_overleft_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
872872
{
873873
RangeBoundlower1,
874874
lower2;
@@ -909,7 +909,7 @@ range_overleft(PG_FUNCTION_ARGS)
909909

910910
/* does not extend to left of? (internal version) */
911911
bool
912-
range_overright_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
912+
range_overright_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
913913
{
914914
RangeBoundlower1,
915915
lower2;
@@ -1696,7 +1696,7 @@ range_serialize(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
16961696
* RangeBound structs will be pointers into the given range object.
16971697
*/
16981698
void
1699-
range_deserialize(TypeCacheEntry*typcache,RangeType*range,
1699+
range_deserialize(TypeCacheEntry*typcache,constRangeType*range,
17001700
RangeBound*lower,RangeBound*upper,bool*empty)
17011701
{
17021702
charflags;
@@ -1711,7 +1711,7 @@ range_deserialize(TypeCacheEntry *typcache, RangeType *range,
17111711
Assert(RangeTypeGetOid(range)==typcache->type_id);
17121712

17131713
/* fetch the flag byte from datum's last byte */
1714-
flags=*((char*)range+VARSIZE(range)-1);
1714+
flags=*((constchar*)range+VARSIZE(range)-1);
17151715

17161716
/* fetch information about range's element type */
17171717
typlen=typcache->rngelemtype->typlen;
@@ -1763,7 +1763,7 @@ range_deserialize(TypeCacheEntry *typcache, RangeType *range,
17631763
* the full results of range_deserialize.
17641764
*/
17651765
char
1766-
range_get_flags(RangeType*range)
1766+
range_get_flags(constRangeType*range)
17671767
{
17681768
/* fetch the flag byte from datum's last byte */
17691769
return*((char*)range+VARSIZE(range)-1);
@@ -1832,7 +1832,7 @@ make_range(TypeCacheEntry *typcache, RangeBound *lower, RangeBound *upper,
18321832
* but one is an upper bound and the other a lower bound.
18331833
*/
18341834
int
1835-
range_cmp_bounds(TypeCacheEntry*typcache,RangeBound*b1,RangeBound*b2)
1835+
range_cmp_bounds(TypeCacheEntry*typcache,constRangeBound*b1,constRangeBound*b2)
18361836
{
18371837
int32result;
18381838

@@ -1906,8 +1906,8 @@ range_cmp_bounds(TypeCacheEntry *typcache, RangeBound *b1, RangeBound *b2)
19061906
* infinity is plus or minus.
19071907
*/
19081908
int
1909-
range_cmp_bound_values(TypeCacheEntry*typcache,RangeBound*b1,
1910-
RangeBound*b2)
1909+
range_cmp_bound_values(TypeCacheEntry*typcache,constRangeBound*b1,
1910+
constRangeBound*b2)
19111911
{
19121912
/*
19131913
* First, handle cases involving infinity, which don't require invoking
@@ -2300,7 +2300,7 @@ range_bound_escape(const char *value)
23002300
* the necessary typcache entry.
23012301
*/
23022302
bool
2303-
range_contains_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
2303+
range_contains_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
23042304
{
23052305
RangeBoundlower1;
23062306
RangeBoundupper1;
@@ -2332,7 +2332,7 @@ range_contains_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
23322332
}
23332333

23342334
bool
2335-
range_contained_by_internal(TypeCacheEntry*typcache,RangeType*r1,RangeType*r2)
2335+
range_contained_by_internal(TypeCacheEntry*typcache,constRangeType*r1,constRangeType*r2)
23362336
{
23372337
returnrange_contains_internal(typcache,r2,r1);
23382338
}
@@ -2341,7 +2341,7 @@ range_contained_by_internal(TypeCacheEntry *typcache, RangeType *r1, RangeType *
23412341
* Test whether range r contains a specific element value.
23422342
*/
23432343
bool
2344-
range_contains_elem_internal(TypeCacheEntry*typcache,RangeType*r,Datumval)
2344+
range_contains_elem_internal(TypeCacheEntry*typcache,constRangeType*r,Datumval)
23452345
{
23462346
RangeBoundlower;
23472347
RangeBoundupper;

‎src/backend/utils/adt/rangetypes_gist.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ typedef struct
137137
staticRangeType*range_super_union(TypeCacheEntry*typcache,RangeType*r1,
138138
RangeType*r2);
139139
staticboolrange_gist_consistent_int(TypeCacheEntry*typcache,
140-
StrategyNumberstrategy,RangeType*key,
140+
StrategyNumberstrategy,constRangeType*key,
141141
Datumquery);
142142
staticboolrange_gist_consistent_leaf(TypeCacheEntry*typcache,
143-
StrategyNumberstrategy,RangeType*key,
143+
StrategyNumberstrategy,constRangeType*key,
144144
Datumquery);
145145
staticvoidrange_gist_fallback_split(TypeCacheEntry*typcache,
146146
GistEntryVector*entryvec,
@@ -764,7 +764,7 @@ range_super_union(TypeCacheEntry *typcache, RangeType *r1, RangeType *r2)
764764
*/
765765
staticbool
766766
range_gist_consistent_int(TypeCacheEntry*typcache,StrategyNumberstrategy,
767-
RangeType*key,Datumquery)
767+
constRangeType*key,Datumquery)
768768
{
769769
switch (strategy)
770770
{
@@ -836,7 +836,7 @@ range_gist_consistent_int(TypeCacheEntry *typcache, StrategyNumber strategy,
836836
*/
837837
staticbool
838838
range_gist_consistent_leaf(TypeCacheEntry*typcache,StrategyNumberstrategy,
839-
RangeType*key,Datumquery)
839+
constRangeType*key,Datumquery)
840840
{
841841
switch (strategy)
842842
{

‎src/backend/utils/adt/rangetypes_selfuncs.c

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,33 +31,33 @@
3131
#include"utils/typcache.h"
3232

3333
staticdoublecalc_rangesel(TypeCacheEntry*typcache,VariableStatData*vardata,
34-
RangeType*constval,Oidoperator);
34+
constRangeType*constval,Oidoperator);
3535
staticdoubledefault_range_selectivity(Oidoperator);
3636
staticdoublecalc_hist_selectivity(TypeCacheEntry*typcache,
37-
VariableStatData*vardata,RangeType*constval,
37+
VariableStatData*vardata,constRangeType*constval,
3838
Oidoperator);
3939
staticdoublecalc_hist_selectivity_scalar(TypeCacheEntry*typcache,
40-
RangeBound*constbound,
41-
RangeBound*hist,inthist_nvalues,
40+
constRangeBound*constbound,
41+
constRangeBound*hist,inthist_nvalues,
4242
boolequal);
43-
staticintrbound_bsearch(TypeCacheEntry*typcache,RangeBound*value,
44-
RangeBound*hist,inthist_length,boolequal);
45-
staticfloat8get_position(TypeCacheEntry*typcache,RangeBound*value,
46-
RangeBound*hist1,RangeBound*hist2);
43+
staticintrbound_bsearch(TypeCacheEntry*typcache,constRangeBound*value,
44+
constRangeBound*hist,inthist_length,boolequal);
45+
staticfloat8get_position(TypeCacheEntry*typcache,constRangeBound*value,
46+
constRangeBound*hist1,constRangeBound*hist2);
4747
staticfloat8get_len_position(doublevalue,doublehist1,doublehist2);
48-
staticfloat8get_distance(TypeCacheEntry*typcache,RangeBound*bound1,
49-
RangeBound*bound2);
48+
staticfloat8get_distance(TypeCacheEntry*typcache,constRangeBound*bound1,
49+
constRangeBound*bound2);
5050
staticintlength_hist_bsearch(Datum*length_hist_values,
5151
intlength_hist_nvalues,doublevalue,boolequal);
5252
staticdoublecalc_length_hist_frac(Datum*length_hist_values,
5353
intlength_hist_nvalues,doublelength1,doublelength2,boolequal);
5454
staticdoublecalc_hist_selectivity_contained(TypeCacheEntry*typcache,
55-
RangeBound*lower,RangeBound*upper,
56-
RangeBound*hist_lower,inthist_nvalues,
55+
constRangeBound*lower,RangeBound*upper,
56+
constRangeBound*hist_lower,inthist_nvalues,
5757
Datum*length_hist_values,intlength_hist_nvalues);
5858
staticdoublecalc_hist_selectivity_contains(TypeCacheEntry*typcache,
59-
RangeBound*lower,RangeBound*upper,
60-
RangeBound*hist_lower,inthist_nvalues,
59+
constRangeBound*lower,constRangeBound*upper,
60+
constRangeBound*hist_lower,inthist_nvalues,
6161
Datum*length_hist_values,intlength_hist_nvalues);
6262

6363
/*
@@ -229,7 +229,7 @@ rangesel(PG_FUNCTION_ARGS)
229229

230230
staticdouble
231231
calc_rangesel(TypeCacheEntry*typcache,VariableStatData*vardata,
232-
RangeType*constval,Oidoperator)
232+
constRangeType*constval,Oidoperator)
233233
{
234234
doublehist_selec;
235235
doubleselec;
@@ -371,7 +371,7 @@ calc_rangesel(TypeCacheEntry *typcache, VariableStatData *vardata,
371371
*/
372372
staticdouble
373373
calc_hist_selectivity(TypeCacheEntry*typcache,VariableStatData*vardata,
374-
RangeType*constval,Oidoperator)
374+
constRangeType*constval,Oidoperator)
375375
{
376376
AttStatsSlothslot;
377377
AttStatsSlotlslot;
@@ -586,8 +586,8 @@ calc_hist_selectivity(TypeCacheEntry *typcache, VariableStatData *vardata,
586586
* is true) a given const in a histogram of range bounds.
587587
*/
588588
staticdouble
589-
calc_hist_selectivity_scalar(TypeCacheEntry*typcache,RangeBound*constbound,
590-
RangeBound*hist,inthist_nvalues,boolequal)
589+
calc_hist_selectivity_scalar(TypeCacheEntry*typcache,constRangeBound*constbound,
590+
constRangeBound*hist,inthist_nvalues,boolequal)
591591
{
592592
Selectivityselec;
593593
intindex;
@@ -618,7 +618,7 @@ calc_hist_selectivity_scalar(TypeCacheEntry *typcache, RangeBound *constbound,
618618
* interpolation of portion of bounds which are less or equal to given bound.
619619
*/
620620
staticint
621-
rbound_bsearch(TypeCacheEntry*typcache,RangeBound*value,RangeBound*hist,
621+
rbound_bsearch(TypeCacheEntry*typcache,constRangeBound*value,constRangeBound*hist,
622622
inthist_length,boolequal)
623623
{
624624
intlower=-1,
@@ -673,8 +673,8 @@ length_hist_bsearch(Datum *length_hist_values, int length_hist_nvalues,
673673
* Get relative position of value in histogram bin in [0,1] range.
674674
*/
675675
staticfloat8
676-
get_position(TypeCacheEntry*typcache,RangeBound*value,RangeBound*hist1,
677-
RangeBound*hist2)
676+
get_position(TypeCacheEntry*typcache,constRangeBound*value,constRangeBound*hist1,
677+
constRangeBound*hist2)
678678
{
679679
boolhas_subdiff=OidIsValid(typcache->rng_subdiff_finfo.fn_oid);
680680
float8position;
@@ -795,7 +795,7 @@ get_len_position(double value, double hist1, double hist2)
795795
* Measure distance between two range bounds.
796796
*/
797797
staticfloat8
798-
get_distance(TypeCacheEntry*typcache,RangeBound*bound1,RangeBound*bound2)
798+
get_distance(TypeCacheEntry*typcache,constRangeBound*bound1,constRangeBound*bound2)
799799
{
800800
boolhas_subdiff=OidIsValid(typcache->rng_subdiff_finfo.fn_oid);
801801

@@ -999,8 +999,8 @@ calc_length_hist_frac(Datum *length_hist_values, int length_hist_nvalues,
999999
*/
10001000
staticdouble
10011001
calc_hist_selectivity_contained(TypeCacheEntry*typcache,
1002-
RangeBound*lower,RangeBound*upper,
1003-
RangeBound*hist_lower,inthist_nvalues,
1002+
constRangeBound*lower,RangeBound*upper,
1003+
constRangeBound*hist_lower,inthist_nvalues,
10041004
Datum*length_hist_values,intlength_hist_nvalues)
10051005
{
10061006
inti,
@@ -1109,8 +1109,8 @@ calc_hist_selectivity_contained(TypeCacheEntry *typcache,
11091109
*/
11101110
staticdouble
11111111
calc_hist_selectivity_contains(TypeCacheEntry*typcache,
1112-
RangeBound*lower,RangeBound*upper,
1113-
RangeBound*hist_lower,inthist_nvalues,
1112+
constRangeBound*lower,constRangeBound*upper,
1113+
constRangeBound*hist_lower,inthist_nvalues,
11141114
Datum*length_hist_values,intlength_hist_nvalues)
11151115
{
11161116
inti,

‎src/backend/utils/adt/rangetypes_spgist.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@
4343
#include"utils/datum.h"
4444
#include"utils/rangetypes.h"
4545

46-
staticint16getQuadrant(TypeCacheEntry*typcache,RangeType*centroid,
47-
RangeType*tst);
46+
staticint16getQuadrant(TypeCacheEntry*typcache,constRangeType*centroid,
47+
constRangeType*tst);
4848
staticintbound_cmp(constvoid*a,constvoid*b,void*arg);
4949

50-
staticintadjacent_inner_consistent(TypeCacheEntry*typcache,
51-
RangeBound*arg,RangeBound*centroid,
52-
RangeBound*prev);
53-
staticintadjacent_cmp_bounds(TypeCacheEntry*typcache,RangeBound*arg,
54-
RangeBound*centroid);
50+
staticintadjacent_inner_consistent(TypeCacheEntry*typcache,
51+
constRangeBound*arg,constRangeBound*centroid,
52+
constRangeBound*prev);
53+
staticintadjacent_cmp_bounds(TypeCacheEntry*typcache,constRangeBound*arg,
54+
constRangeBound*centroid);
5555

5656
/*
5757
* SP-GiST 'config' interface function.
@@ -92,7 +92,7 @@ spg_range_quad_config(PG_FUNCTION_ARGS)
9292
*----------
9393
*/
9494
staticint16
95-
getQuadrant(TypeCacheEntry*typcache,RangeType*centroid,RangeType*tst)
95+
getQuadrant(TypeCacheEntry*typcache,constRangeType*centroid,constRangeType*tst)
9696
{
9797
RangeBoundcentroidLower,
9898
centroidUpper;
@@ -785,8 +785,8 @@ spg_range_quad_inner_consistent(PG_FUNCTION_ARGS)
785785
* For the "left" case, returns -1, and for the "right" case, returns 1.
786786
*/
787787
staticint
788-
adjacent_cmp_bounds(TypeCacheEntry*typcache,RangeBound*arg,
789-
RangeBound*centroid)
788+
adjacent_cmp_bounds(TypeCacheEntry*typcache,constRangeBound*arg,
789+
constRangeBound*centroid)
790790
{
791791
intcmp;
792792

@@ -887,8 +887,8 @@ adjacent_cmp_bounds(TypeCacheEntry *typcache, RangeBound *arg,
887887
*----------
888888
*/
889889
staticint
890-
adjacent_inner_consistent(TypeCacheEntry*typcache,RangeBound*arg,
891-
RangeBound*centroid,RangeBound*prev)
890+
adjacent_inner_consistent(TypeCacheEntry*typcache,constRangeBound*arg,
891+
constRangeBound*centroid,constRangeBound*prev)
892892
{
893893
if (prev)
894894
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp