mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Allow GIN's extractQuery method to signal that nothing can satisfy the query.
In this case extractQuery should returns -1 as nentries. This changes prototype of extractQuery method to use int32* instead of uint32* for nentries argument. Based on that gincostestimate may see two corner cases: nothing will be found or seqscan should be used. Per proposal at http://archives.postgresql.org/pgsql-hackers/2007-01/msg01581.php PS tsearch_core patch should be sightly modified to support changes, but I'm waiting a verdict about reviewing of tsearch_core patch.
This commit is contained in:
@ -6,7 +6,7 @@ Datum ginint4_queryextract(PG_FUNCTION_ARGS);
|
||||
Datum
|
||||
ginint4_queryextract(PG_FUNCTION_ARGS)
|
||||
{
|
||||
uint32 *nentries = (uint32 *) PG_GETARG_POINTER(1);
|
||||
int32 *nentries = (int32 *) PG_GETARG_POINTER(1);
|
||||
StrategyNumber strategy = PG_GETARG_UINT16(2);
|
||||
Datum *res = NULL;
|
||||
|
||||
@ -57,6 +57,19 @@ ginint4_queryextract(PG_FUNCTION_ARGS)
|
||||
}
|
||||
}
|
||||
|
||||
if ( nentries == 0 )
|
||||
{
|
||||
switch( strategy )
|
||||
{
|
||||
case BooleanSearchStrategy:
|
||||
case RTOverlapStrategyNumber:
|
||||
*nentries = -1; /* nobody can be found */
|
||||
break;
|
||||
default: /* require fullscan: GIN can't find void arrays */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PG_RETURN_POINTER(res);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user