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

Commit0cfa34c

Browse files
committed
Rename GinLogicValue to GinTernaryValue.
It's more descriptive. Also, get rid of the enum, and use #defines instead,per Greg Stark's suggestion.
1 parent7317d8d commit0cfa34c

File tree

7 files changed

+56
-52
lines changed

7 files changed

+56
-52
lines changed

‎src/backend/access/gin/ginarrayproc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ ginarrayconsistent(PG_FUNCTION_ARGS)
225225
Datum
226226
ginarraytriconsistent(PG_FUNCTION_ARGS)
227227
{
228-
GinLogicValue*check= (GinLogicValue*)PG_GETARG_POINTER(0);
228+
GinTernaryValue*check= (GinTernaryValue*)PG_GETARG_POINTER(0);
229229
StrategyNumberstrategy=PG_GETARG_UINT16(1);
230230

231231
/* ArrayType *query = PG_GETARG_ARRAYTYPE_P(2); */
@@ -234,7 +234,7 @@ ginarraytriconsistent(PG_FUNCTION_ARGS)
234234
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
235235
/* Datum *queryKeys = (Datum *) PG_GETARG_POINTER(5); */
236236
bool*nullFlags= (bool*)PG_GETARG_POINTER(6);
237-
GinLogicValueres;
237+
GinTernaryValueres;
238238
int32i;
239239

240240
switch (strategy)
@@ -300,5 +300,5 @@ ginarraytriconsistent(PG_FUNCTION_ARGS)
300300
res= false;
301301
}
302302

303-
PG_RETURN_GIN_LOGIC_VALUE(res);
303+
PG_RETURN_GIN_TERNARY_VALUE(res);
304304
}

‎src/backend/access/gin/ginget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key,
873873
uint32i;
874874
boolhaveLossyEntry;
875875
GinScanEntryentry;
876-
GinLogicValueres;
876+
GinTernaryValueres;
877877
MemoryContextoldCtx;
878878
boolallFinished;
879879

‎src/backend/access/gin/ginlogic.c

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ trueConsistentFn(GinScanKey key)
5858
key->recheckCurItem= false;
5959
return true;
6060
}
61-
staticGinLogicValue
61+
staticGinTernaryValue
6262
trueTriConsistentFn(GinScanKeykey)
6363
{
6464
returnGIN_TRUE;
@@ -91,17 +91,18 @@ directBoolConsistentFn(GinScanKey key)
9191
/*
9292
* A helper function for calling a native ternary logic consistent function.
9393
*/
94-
staticGinLogicValue
94+
staticGinTernaryValue
9595
directTriConsistentFn(GinScanKeykey)
9696
{
97-
returnDatumGetGinLogicValue(FunctionCall7Coll(key->triConsistentFmgrInfo,
98-
key->collation,
99-
PointerGetDatum(key->entryRes),
100-
UInt16GetDatum(key->strategy),
101-
key->query,
102-
UInt32GetDatum(key->nuserentries),
103-
PointerGetDatum(key->extra_data),
104-
PointerGetDatum(key->queryValues),
97+
returnDatumGetGinTernaryValue(FunctionCall7Coll(
98+
key->triConsistentFmgrInfo,
99+
key->collation,
100+
PointerGetDatum(key->entryRes),
101+
UInt16GetDatum(key->strategy),
102+
key->query,
103+
UInt32GetDatum(key->nuserentries),
104+
PointerGetDatum(key->extra_data),
105+
PointerGetDatum(key->queryValues),
105106
PointerGetDatum(key->queryCategories)));
106107
}
107108

@@ -113,15 +114,16 @@ directTriConsistentFn(GinScanKey key)
113114
staticbool
114115
shimBoolConsistentFn(GinScanKeykey)
115116
{
116-
GinLogicValueresult;
117-
result=DatumGetGinLogicValue(FunctionCall7Coll(key->triConsistentFmgrInfo,
118-
key->collation,
119-
PointerGetDatum(key->entryRes),
120-
UInt16GetDatum(key->strategy),
121-
key->query,
122-
UInt32GetDatum(key->nuserentries),
123-
PointerGetDatum(key->extra_data),
124-
PointerGetDatum(key->queryValues),
117+
GinTernaryValueresult;
118+
result=DatumGetGinTernaryValue(FunctionCall7Coll(
119+
key->triConsistentFmgrInfo,
120+
key->collation,
121+
PointerGetDatum(key->entryRes),
122+
UInt16GetDatum(key->strategy),
123+
key->query,
124+
UInt32GetDatum(key->nuserentries),
125+
PointerGetDatum(key->extra_data),
126+
PointerGetDatum(key->queryValues),
125127
PointerGetDatum(key->queryCategories)));
126128
if (result==GIN_MAYBE)
127129
{
@@ -147,15 +149,15 @@ shimBoolConsistentFn(GinScanKey key)
147149
*
148150
* NB: This function modifies the key->entryRes array!
149151
*/
150-
staticGinLogicValue
152+
staticGinTernaryValue
151153
shimTriConsistentFn(GinScanKeykey)
152154
{
153155
intnmaybe;
154156
intmaybeEntries[MAX_MAYBE_ENTRIES];
155157
inti;
156158
boolboolResult;
157159
boolrecheck= false;
158-
GinLogicValuecurResult;
160+
GinTernaryValuecurResult;
159161

160162
/*
161163
* Count how many MAYBE inputs there are, and store their indexes in

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -288,12 +288,12 @@ gin_consistent_jsonb(PG_FUNCTION_ARGS)
288288
Datum
289289
gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
290290
{
291-
GinLogicValue*check= (GinLogicValue*)PG_GETARG_POINTER(0);
291+
GinTernaryValue*check= (GinTernaryValue*)PG_GETARG_POINTER(0);
292292
StrategyNumberstrategy=PG_GETARG_UINT16(1);
293293
/* Jsonb *query = PG_GETARG_JSONB(2); */
294294
int32nkeys=PG_GETARG_INT32(3);
295295
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
296-
GinLogicValueres=GIN_TRUE;
296+
GinTernaryValueres=GIN_TRUE;
297297

298298
int32i;
299299

@@ -366,7 +366,7 @@ gin_triconsistent_jsonb(PG_FUNCTION_ARGS)
366366
else
367367
elog(ERROR,"unrecognized strategy number: %d",strategy);
368368

369-
PG_RETURN_GIN_LOGIC_VALUE(res);
369+
PG_RETURN_GIN_TERNARY_VALUE(res);
370370
}
371371

372372
/*
@@ -414,12 +414,12 @@ gin_consistent_jsonb_hash(PG_FUNCTION_ARGS)
414414
Datum
415415
gin_triconsistent_jsonb_hash(PG_FUNCTION_ARGS)
416416
{
417-
GinLogicValue*check= (GinLogicValue*)PG_GETARG_POINTER(0);
417+
GinTernaryValue*check= (GinTernaryValue*)PG_GETARG_POINTER(0);
418418
StrategyNumberstrategy=PG_GETARG_UINT16(1);
419419
/* Jsonb *query = PG_GETARG_JSONB(2); */
420420
int32nkeys=PG_GETARG_INT32(3);
421421
/* Pointer *extra_data = (Pointer *) PG_GETARG_POINTER(4); */
422-
GinLogicValueres=GIN_TRUE;
422+
GinTernaryValueres=GIN_TRUE;
423423
int32i;
424424
boolhas_maybe= false;
425425

@@ -455,7 +455,7 @@ gin_triconsistent_jsonb_hash(PG_FUNCTION_ARGS)
455455
if (!has_maybe&&res==GIN_TRUE)
456456
res=GIN_MAYBE;
457457

458-
PG_RETURN_GIN_LOGIC_VALUE(res);
458+
PG_RETURN_GIN_TERNARY_VALUE(res);
459459
}
460460

461461
Datum

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ gin_extract_tsquery(PG_FUNCTION_ARGS)
173173
typedefstruct
174174
{
175175
QueryItem*first_item;
176-
GinLogicValue*check;
176+
GinTernaryValue*check;
177177
int*map_item_operand;
178178
bool*need_recheck;
179179
}GinChkVal;
180180

181-
staticGinLogicValue
181+
staticGinTernaryValue
182182
checkcondition_gin(void*checkval,QueryOperand*val)
183183
{
184184
GinChkVal*gcv= (GinChkVal*)checkval;
@@ -202,11 +202,11 @@ checkcondition_gin(void *checkval, QueryOperand *val)
202202
* checkval can be used to pass information to the callback. TS_execute doesn't
203203
* do anything with it.
204204
*/
205-
staticGinLogicValue
205+
staticGinTernaryValue
206206
TS_execute_ternary(QueryItem*curitem,void*checkval,
207-
GinLogicValue (*chkcond) (void*checkval,QueryOperand*val))
207+
GinTernaryValue (*chkcond) (void*checkval,QueryOperand*val))
208208
{
209-
GinLogicValueval1,val2,result;
209+
GinTernaryValueval1,val2,result;
210210
/* since this function recurses, it could be driven to stack overflow */
211211
check_stack_depth();
212212

@@ -297,14 +297,14 @@ gin_tsquery_consistent(PG_FUNCTION_ARGS)
297297
Datum
298298
gin_tsquery_triconsistent(PG_FUNCTION_ARGS)
299299
{
300-
GinLogicValue*check= (GinLogicValue*)PG_GETARG_POINTER(0);
300+
GinTernaryValue*check= (GinTernaryValue*)PG_GETARG_POINTER(0);
301301

302302
/* StrategyNumber strategy = PG_GETARG_UINT16(1); */
303303
TSQueryquery=PG_GETARG_TSQUERY(2);
304304

305305
/* int32nkeys = PG_GETARG_INT32(3); */
306306
Pointer*extra_data= (Pointer*)PG_GETARG_POINTER(4);
307-
GinLogicValueres=GIN_FALSE;
307+
GinTernaryValueres=GIN_FALSE;
308308
boolrecheck;
309309

310310
/* The query requires recheck only if it involves weights */
@@ -332,7 +332,7 @@ gin_tsquery_triconsistent(PG_FUNCTION_ARGS)
332332
res=GIN_MAYBE;
333333
}
334334

335-
PG_RETURN_GIN_LOGIC_VALUE(res);
335+
PG_RETURN_GIN_TERNARY_VALUE(res);
336336
}
337337

338338
/*

‎src/include/access/gin.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,22 @@ typedef struct GinStatsData
4747
int32ginVersion;
4848
}GinStatsData;
4949

50-
/* ginlogic.c */
51-
enumGinLogicValueEnum
52-
{
53-
GIN_FALSE=0,/* item is not present / does not match */
54-
GIN_TRUE=1,/* item is present / matches */
55-
GIN_MAYBE=2/* don't know if item is present / don't know if
56-
* matches */
57-
};
50+
/*
51+
* A ternary value used by tri-consistent functions.
52+
*
53+
* For convenience, this is compatible with booleans. A boolean can be
54+
* safely cast to a GinTernaryValue.
55+
*/
56+
typedefcharGinTernaryValue;
5857

59-
typedefcharGinLogicValue;
58+
#defineGIN_FALSE0/* item is not present / does not match */
59+
#defineGIN_TRUE1/* item is present / matches */
60+
#defineGIN_MAYBE2/* don't know if item is present / don't know if
61+
* matches */
6062

61-
#defineDatumGetGinLogicValue(X) ((GinLogicValue)(X))
62-
#defineGinLogicValueGetDatum(X) ((Datum)(X))
63-
#definePG_RETURN_GIN_LOGIC_VALUE(x) returnGinLogicValueGetDatum(x)
63+
#defineDatumGetGinTernaryValue(X) ((GinTernaryValue)(X))
64+
#defineGinTernaryValueGetDatum(X) ((Datum)(X))
65+
#definePG_RETURN_GIN_TERNARY_VALUE(x) returnGinTernaryValueGetDatum(x)
6466

6567
/* GUC parameter */
6668
externPGDLLIMPORTintGinFuzzySearchLimit;

‎src/include/access/gin_private.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ typedef struct GinScanKeyData
763763
/* array of check flags, reported to consistentFn */
764764
bool*entryRes;
765765
bool(*boolConsistentFn) (GinScanKeykey);
766-
GinLogicValue (*triConsistentFn) (GinScanKeykey);
766+
GinTernaryValue (*triConsistentFn) (GinScanKeykey);
767767
FmgrInfo*consistentFmgrInfo;
768768
FmgrInfo*triConsistentFmgrInfo;
769769
Oidcollation;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp