mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-01 19:45:33 +08:00
Detoast query in g_intbig_consistent and copy query in g_int_consistent.
Minor cleanups.
This commit is contained in:
parent
1750f60ef3
commit
2ba15dbfc3
@ -32,20 +32,24 @@ Datum
|
|||||||
g_int_consistent(PG_FUNCTION_ARGS)
|
g_int_consistent(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
||||||
ArrayType *query = (ArrayType *) PG_GETARG_POINTER(1);
|
ArrayType *query = (ArrayType *) PG_DETOAST_DATUM_COPY(PG_GETARG_POINTER(1));
|
||||||
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
|
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
|
||||||
bool retval;
|
bool retval;
|
||||||
|
|
||||||
if (strategy == BooleanSearchStrategy)
|
if (strategy == BooleanSearchStrategy) {
|
||||||
PG_RETURN_BOOL(execconsistent((QUERYTYPE *) query,
|
retval =execconsistent((QUERYTYPE *) query,
|
||||||
(ArrayType *) DatumGetPointer(entry->key),
|
(ArrayType *) DatumGetPointer(entry->key),
|
||||||
ISLEAFKEY((ArrayType *) DatumGetPointer(entry->key))));
|
ISLEAFKEY((ArrayType *) DatumGetPointer(entry->key)));
|
||||||
|
pfree( query );
|
||||||
|
|
||||||
|
PG_RETURN_BOOL(retval);
|
||||||
|
}
|
||||||
|
|
||||||
/* XXX are we sure it's safe to scribble on the query object here? */
|
|
||||||
/* XXX what about toasted input? */
|
|
||||||
/* sort query for fast search, key is already sorted */
|
/* sort query for fast search, key is already sorted */
|
||||||
if (ARRISVOID(query))
|
if (ARRISVOID(query)) {
|
||||||
|
pfree( query );
|
||||||
PG_RETURN_BOOL(false);
|
PG_RETURN_BOOL(false);
|
||||||
|
}
|
||||||
PREPAREARR(query);
|
PREPAREARR(query);
|
||||||
|
|
||||||
switch (strategy)
|
switch (strategy)
|
||||||
@ -81,6 +85,7 @@ g_int_consistent(PG_FUNCTION_ARGS)
|
|||||||
default:
|
default:
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
}
|
}
|
||||||
|
pfree( query );
|
||||||
PG_RETURN_BOOL(retval);
|
PG_RETURN_BOOL(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,23 +477,28 @@ Datum
|
|||||||
g_intbig_consistent(PG_FUNCTION_ARGS)
|
g_intbig_consistent(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
GISTENTRY *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
|
||||||
ArrayType *query = (ArrayType *) PG_GETARG_POINTER(1);
|
ArrayType *query = (ArrayType *) PG_DETOAST_DATUM(PG_GETARG_POINTER(1));
|
||||||
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
|
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
|
||||||
bool retval;
|
bool retval;
|
||||||
|
|
||||||
if (ISALLTRUE(DatumGetPointer(entry->key)))
|
if (ISALLTRUE(DatumGetPointer(entry->key))) {
|
||||||
|
PG_FREE_IF_COPY(query, 1);
|
||||||
PG_RETURN_BOOL(true);
|
PG_RETURN_BOOL(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (strategy == BooleanSearchStrategy)
|
if (strategy == BooleanSearchStrategy)
|
||||||
{
|
{
|
||||||
PG_RETURN_BOOL(signconsistent((QUERYTYPE *) query,
|
retval = signconsistent((QUERYTYPE *) query,
|
||||||
GETSIGN(DatumGetPointer(entry->key)),
|
GETSIGN(DatumGetPointer(entry->key)),
|
||||||
false));
|
false);
|
||||||
|
PG_FREE_IF_COPY(query, 1);
|
||||||
|
PG_RETURN_BOOL(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX what about toasted input? */
|
if (ARRISVOID(query)) {
|
||||||
if (ARRISVOID(query))
|
PG_FREE_IF_COPY(query, 1);
|
||||||
return FALSE;
|
PG_RETURN_BOOL(retval);
|
||||||
|
}
|
||||||
|
|
||||||
switch (strategy)
|
switch (strategy)
|
||||||
{
|
{
|
||||||
@ -572,5 +577,6 @@ g_intbig_consistent(PG_FUNCTION_ARGS)
|
|||||||
default:
|
default:
|
||||||
retval = FALSE;
|
retval = FALSE;
|
||||||
}
|
}
|
||||||
|
PG_FREE_IF_COPY(query, 1);
|
||||||
PG_RETURN_BOOL(retval);
|
PG_RETURN_BOOL(retval);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user