Skip to content

Commit 4b1c68d

Browse files
committed
Use CallerFInfoFunctionCall with btree_gist for numeric types
None of the existing types actually need to use this mechanism, but this will allow support for enum types which will need it. A separate patch will adjust the varlena types support for consistency. Reviewed by Tom Lane and Anastasia Lubennikova Discussion: http://postgr.es/m/27220.1478360811@sss.pgh.pa.us
1 parent eb2a613 commit 4b1c68d

17 files changed

+219
-217
lines changed

contrib/btree_gist/btree_cash.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@ PG_FUNCTION_INFO_V1(gbt_cash_penalty);
2626
PG_FUNCTION_INFO_V1(gbt_cash_same);
2727

2828
static bool
29-
gbt_cashgt(const void *a, const void *b)
29+
gbt_cashgt(const void *a, const void *b, FmgrInfo *flinfo)
3030
{
3131
return (*((const Cash *) a) > *((const Cash *) b));
3232
}
3333
static bool
34-
gbt_cashge(const void *a, const void *b)
34+
gbt_cashge(const void *a, const void *b, FmgrInfo *flinfo)
3535
{
3636
return (*((const Cash *) a) >= *((const Cash *) b));
3737
}
3838
static bool
39-
gbt_casheq(const void *a, const void *b)
39+
gbt_casheq(const void *a, const void *b, FmgrInfo *flinfo)
4040
{
4141
return (*((const Cash *) a) == *((const Cash *) b));
4242
}
4343
static bool
44-
gbt_cashle(const void *a, const void *b)
44+
gbt_cashle(const void *a, const void *b, FmgrInfo *flinfo)
4545
{
4646
return (*((const Cash *) a) <= *((const Cash *) b));
4747
}
4848
static bool
49-
gbt_cashlt(const void *a, const void *b)
49+
gbt_cashlt(const void *a, const void *b, FmgrInfo *flinfo)
5050
{
5151
return (*((const Cash *) a) < *((const Cash *) b));
5252
}
5353

5454
static int
55-
gbt_cashkey_cmp(const void *a, const void *b)
55+
gbt_cashkey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
5656
{
5757
cashKEY *ia = (cashKEY *) (((const Nsrt *) a)->t);
5858
cashKEY *ib = (cashKEY *) (((const Nsrt *) b)->t);
@@ -69,7 +69,7 @@ gbt_cashkey_cmp(const void *a, const void *b)
6969
}
7070

7171
static float8
72-
gbt_cash_dist(const void *a, const void *b)
72+
gbt_cash_dist(const void *a, const void *b, FmgrInfo *flinfo)
7373
{
7474
return GET_FLOAT_DISTANCE(Cash, a, b);
7575
}
@@ -151,7 +151,7 @@ gbt_cash_consistent(PG_FUNCTION_ARGS)
151151
key.upper = (GBT_NUMKEY *) &kkk->upper;
152152

153153
PG_RETURN_BOOL(
154-
gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)
154+
gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
155155
);
156156
}
157157

@@ -170,7 +170,7 @@ gbt_cash_distance(PG_FUNCTION_ARGS)
170170
key.upper = (GBT_NUMKEY *) &kkk->upper;
171171

172172
PG_RETURN_FLOAT8(
173-
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
173+
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
174174
);
175175
}
176176

@@ -182,7 +182,7 @@ gbt_cash_union(PG_FUNCTION_ARGS)
182182
void *out = palloc(sizeof(cashKEY));
183183

184184
*(int *) PG_GETARG_POINTER(1) = sizeof(cashKEY);
185-
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
185+
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo, fcinfo->flinfo));
186186
}
187187

188188

@@ -205,7 +205,7 @@ gbt_cash_picksplit(PG_FUNCTION_ARGS)
205205
PG_RETURN_POINTER(gbt_num_picksplit(
206206
(GistEntryVector *) PG_GETARG_POINTER(0),
207207
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
208-
&tinfo
208+
&tinfo, fcinfo->flinfo
209209
));
210210
}
211211

@@ -216,6 +216,6 @@ gbt_cash_same(PG_FUNCTION_ARGS)
216216
cashKEY *b2 = (cashKEY *) PG_GETARG_POINTER(1);
217217
bool *result = (bool *) PG_GETARG_POINTER(2);
218218

219-
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo);
219+
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
220220
PG_RETURN_POINTER(result);
221221
}

contrib/btree_gist/btree_date.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,39 @@ PG_FUNCTION_INFO_V1(gbt_date_penalty);
2727
PG_FUNCTION_INFO_V1(gbt_date_same);
2828

2929
static bool
30-
gbt_dategt(const void *a, const void *b)
30+
gbt_dategt(const void *a, const void *b, FmgrInfo *flinfo)
3131
{
3232
return DatumGetBool(
3333
DirectFunctionCall2(date_gt, DateADTGetDatum(*((const DateADT *) a)), DateADTGetDatum(*((const DateADT *) b)))
3434
);
3535
}
3636

3737
static bool
38-
gbt_datege(const void *a, const void *b)
38+
gbt_datege(const void *a, const void *b, FmgrInfo *flinfo)
3939
{
4040
return DatumGetBool(
4141
DirectFunctionCall2(date_ge, DateADTGetDatum(*((const DateADT *) a)), DateADTGetDatum(*((const DateADT *) b)))
4242
);
4343
}
4444

4545
static bool
46-
gbt_dateeq(const void *a, const void *b)
46+
gbt_dateeq(const void *a, const void *b, FmgrInfo *flinfo)
4747
{
4848
return DatumGetBool(
4949
DirectFunctionCall2(date_eq, DateADTGetDatum(*((const DateADT *) a)), DateADTGetDatum(*((const DateADT *) b)))
5050
);
5151
}
5252

5353
static bool
54-
gbt_datele(const void *a, const void *b)
54+
gbt_datele(const void *a, const void *b, FmgrInfo *flinfo)
5555
{
5656
return DatumGetBool(
5757
DirectFunctionCall2(date_le, DateADTGetDatum(*((const DateADT *) a)), DateADTGetDatum(*((const DateADT *) b)))
5858
);
5959
}
6060

6161
static bool
62-
gbt_datelt(const void *a, const void *b)
62+
gbt_datelt(const void *a, const void *b, FmgrInfo *flinfo)
6363
{
6464
return DatumGetBool(
6565
DirectFunctionCall2(date_lt, DateADTGetDatum(*((const DateADT *) a)), DateADTGetDatum(*((const DateADT *) b)))
@@ -69,7 +69,7 @@ gbt_datelt(const void *a, const void *b)
6969

7070

7171
static int
72-
gbt_datekey_cmp(const void *a, const void *b)
72+
gbt_datekey_cmp(const void *a, const void *b, FmgrInfo *flinfo)
7373
{
7474
dateKEY *ia = (dateKEY *) (((const Nsrt *) a)->t);
7575
dateKEY *ib = (dateKEY *) (((const Nsrt *) b)->t);
@@ -83,7 +83,7 @@ gbt_datekey_cmp(const void *a, const void *b)
8383
}
8484

8585
static float8
86-
gdb_date_dist(const void *a, const void *b)
86+
gdb_date_dist(const void *a, const void *b, FmgrInfo *flinfo)
8787
{
8888
/* we assume the difference can't overflow */
8989
Datum diff = DirectFunctionCall2(date_mi,
@@ -163,7 +163,7 @@ gbt_date_consistent(PG_FUNCTION_ARGS)
163163
key.upper = (GBT_NUMKEY *) &kkk->upper;
164164

165165
PG_RETURN_BOOL(
166-
gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)
166+
gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
167167
);
168168
}
169169

@@ -182,7 +182,7 @@ gbt_date_distance(PG_FUNCTION_ARGS)
182182
key.upper = (GBT_NUMKEY *) &kkk->upper;
183183

184184
PG_RETURN_FLOAT8(
185-
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
185+
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
186186
);
187187
}
188188

@@ -194,7 +194,7 @@ gbt_date_union(PG_FUNCTION_ARGS)
194194
void *out = palloc(sizeof(dateKEY));
195195

196196
*(int *) PG_GETARG_POINTER(1) = sizeof(dateKEY);
197-
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
197+
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo, fcinfo->flinfo));
198198
}
199199

200200

@@ -244,7 +244,7 @@ gbt_date_picksplit(PG_FUNCTION_ARGS)
244244
PG_RETURN_POINTER(gbt_num_picksplit(
245245
(GistEntryVector *) PG_GETARG_POINTER(0),
246246
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
247-
&tinfo
247+
&tinfo, fcinfo->flinfo
248248
));
249249
}
250250

@@ -255,6 +255,6 @@ gbt_date_same(PG_FUNCTION_ARGS)
255255
dateKEY *b2 = (dateKEY *) PG_GETARG_POINTER(1);
256256
bool *result = (bool *) PG_GETARG_POINTER(2);
257257

258-
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo);
258+
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
259259
PG_RETURN_POINTER(result);
260260
}

contrib/btree_gist/btree_float4.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,33 @@ PG_FUNCTION_INFO_V1(gbt_float4_penalty);
2525
PG_FUNCTION_INFO_V1(gbt_float4_same);
2626

2727
static bool
28-
gbt_float4gt(const void *a, const void *b)
28+
gbt_float4gt(const void *a, const void *b, FmgrInfo *flinfo)
2929
{
3030
return (*((const float4 *) a) > *((const float4 *) b));
3131
}
3232
static bool
33-
gbt_float4ge(const void *a, const void *b)
33+
gbt_float4ge(const void *a, const void *b, FmgrInfo *flinfo)
3434
{
3535
return (*((const float4 *) a) >= *((const float4 *) b));
3636
}
3737
static bool
38-
gbt_float4eq(const void *a, const void *b)
38+
gbt_float4eq(const void *a, const void *b, FmgrInfo *flinfo)
3939
{
4040
return (*((const float4 *) a) == *((const float4 *) b));
4141
}
4242
static bool
43-
gbt_float4le(const void *a, const void *b)
43+
gbt_float4le(const void *a, const void *b, FmgrInfo *flinfo)
4444
{
4545
return (*((const float4 *) a) <= *((const float4 *) b));
4646
}
4747
static bool
48-
gbt_float4lt(const void *a, const void *b)
48+
gbt_float4lt(const void *a, const void *b, FmgrInfo *flinfo)
4949
{
5050
return (*((const float4 *) a) < *((const float4 *) b));
5151
}
5252

5353
static int
54-
gbt_float4key_cmp(const void *a, const void *b)
54+
gbt_float4key_cmp(const void *a, const void *b, FmgrInfo *flinfo)
5555
{
5656
float4KEY *ia = (float4KEY *) (((const Nsrt *) a)->t);
5757
float4KEY *ib = (float4KEY *) (((const Nsrt *) b)->t);
@@ -68,7 +68,7 @@ gbt_float4key_cmp(const void *a, const void *b)
6868
}
6969

7070
static float8
71-
gbt_float4_dist(const void *a, const void *b)
71+
gbt_float4_dist(const void *a, const void *b, FmgrInfo *flinfo)
7272
{
7373
return GET_FLOAT_DISTANCE(float4, a, b);
7474
}
@@ -144,7 +144,7 @@ gbt_float4_consistent(PG_FUNCTION_ARGS)
144144
key.upper = (GBT_NUMKEY *) &kkk->upper;
145145

146146
PG_RETURN_BOOL(
147-
gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)
147+
gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
148148
);
149149
}
150150

@@ -163,7 +163,7 @@ gbt_float4_distance(PG_FUNCTION_ARGS)
163163
key.upper = (GBT_NUMKEY *) &kkk->upper;
164164

165165
PG_RETURN_FLOAT8(
166-
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
166+
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
167167
);
168168
}
169169

@@ -175,7 +175,7 @@ gbt_float4_union(PG_FUNCTION_ARGS)
175175
void *out = palloc(sizeof(float4KEY));
176176

177177
*(int *) PG_GETARG_POINTER(1) = sizeof(float4KEY);
178-
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
178+
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo, fcinfo->flinfo));
179179
}
180180

181181

@@ -198,7 +198,7 @@ gbt_float4_picksplit(PG_FUNCTION_ARGS)
198198
PG_RETURN_POINTER(gbt_num_picksplit(
199199
(GistEntryVector *) PG_GETARG_POINTER(0),
200200
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
201-
&tinfo
201+
&tinfo, fcinfo->flinfo
202202
));
203203
}
204204

@@ -209,6 +209,6 @@ gbt_float4_same(PG_FUNCTION_ARGS)
209209
float4KEY *b2 = (float4KEY *) PG_GETARG_POINTER(1);
210210
bool *result = (bool *) PG_GETARG_POINTER(2);
211211

212-
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo);
212+
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
213213
PG_RETURN_POINTER(result);
214214
}

contrib/btree_gist/btree_float8.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,33 @@ PG_FUNCTION_INFO_V1(gbt_float8_same);
2626

2727

2828
static bool
29-
gbt_float8gt(const void *a, const void *b)
29+
gbt_float8gt(const void *a, const void *b, FmgrInfo *flinfo)
3030
{
3131
return (*((const float8 *) a) > *((const float8 *) b));
3232
}
3333
static bool
34-
gbt_float8ge(const void *a, const void *b)
34+
gbt_float8ge(const void *a, const void *b, FmgrInfo *flinfo)
3535
{
3636
return (*((const float8 *) a) >= *((const float8 *) b));
3737
}
3838
static bool
39-
gbt_float8eq(const void *a, const void *b)
39+
gbt_float8eq(const void *a, const void *b, FmgrInfo *flinfo)
4040
{
4141
return (*((const float8 *) a) == *((const float8 *) b));
4242
}
4343
static bool
44-
gbt_float8le(const void *a, const void *b)
44+
gbt_float8le(const void *a, const void *b, FmgrInfo *flinfo)
4545
{
4646
return (*((const float8 *) a) <= *((const float8 *) b));
4747
}
4848
static bool
49-
gbt_float8lt(const void *a, const void *b)
49+
gbt_float8lt(const void *a, const void *b, FmgrInfo *flinfo)
5050
{
5151
return (*((const float8 *) a) < *((const float8 *) b));
5252
}
5353

5454
static int
55-
gbt_float8key_cmp(const void *a, const void *b)
55+
gbt_float8key_cmp(const void *a, const void *b, FmgrInfo *flinfo)
5656
{
5757
float8KEY *ia = (float8KEY *) (((const Nsrt *) a)->t);
5858
float8KEY *ib = (float8KEY *) (((const Nsrt *) b)->t);
@@ -69,7 +69,7 @@ gbt_float8key_cmp(const void *a, const void *b)
6969
}
7070

7171
static float8
72-
gbt_float8_dist(const void *a, const void *b)
72+
gbt_float8_dist(const void *a, const void *b, FmgrInfo *flinfo)
7373
{
7474
float8 arg1 = *(const float8 *) a;
7575
float8 arg2 = *(const float8 *) b;
@@ -151,7 +151,7 @@ gbt_float8_consistent(PG_FUNCTION_ARGS)
151151
key.upper = (GBT_NUMKEY *) &kkk->upper;
152152

153153
PG_RETURN_BOOL(
154-
gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo)
154+
gbt_num_consistent(&key, (void *) &query, &strategy, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
155155
);
156156
}
157157

@@ -170,7 +170,7 @@ gbt_float8_distance(PG_FUNCTION_ARGS)
170170
key.upper = (GBT_NUMKEY *) &kkk->upper;
171171

172172
PG_RETURN_FLOAT8(
173-
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo)
173+
gbt_num_distance(&key, (void *) &query, GIST_LEAF(entry), &tinfo, fcinfo->flinfo)
174174
);
175175
}
176176

@@ -182,7 +182,7 @@ gbt_float8_union(PG_FUNCTION_ARGS)
182182
void *out = palloc(sizeof(float8KEY));
183183

184184
*(int *) PG_GETARG_POINTER(1) = sizeof(float8KEY);
185-
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo));
185+
PG_RETURN_POINTER(gbt_num_union((void *) out, entryvec, &tinfo, fcinfo->flinfo));
186186
}
187187

188188

@@ -205,7 +205,7 @@ gbt_float8_picksplit(PG_FUNCTION_ARGS)
205205
PG_RETURN_POINTER(gbt_num_picksplit(
206206
(GistEntryVector *) PG_GETARG_POINTER(0),
207207
(GIST_SPLITVEC *) PG_GETARG_POINTER(1),
208-
&tinfo
208+
&tinfo, fcinfo->flinfo
209209
));
210210
}
211211

@@ -216,6 +216,6 @@ gbt_float8_same(PG_FUNCTION_ARGS)
216216
float8KEY *b2 = (float8KEY *) PG_GETARG_POINTER(1);
217217
bool *result = (bool *) PG_GETARG_POINTER(2);
218218

219-
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo);
219+
*result = gbt_num_same((void *) b1, (void *) b2, &tinfo, fcinfo->flinfo);
220220
PG_RETURN_POINTER(result);
221221
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy