diff --git a/src/parray_gin.c b/src/parray_gin.c index 69e01f5..6f337f7 100644 --- a/src/parray_gin.c +++ b/src/parray_gin.c @@ -645,6 +645,7 @@ parray_gin_extract_query(PG_FUNCTION_ARGS) bool **pmatch = (bool **) PG_GETARG_POINTER(3); Pointer **extra_data = (Pointer **) PG_GETARG_POINTER(4); bool **nullFlags = (bool **) PG_GETARG_POINTER(5); + int32 *searchMode = (int32 *) PG_GETARG_POINTER(6); Datum *keys; bool is_partial; @@ -671,6 +672,12 @@ parray_gin_extract_query(PG_FUNCTION_ARGS) *nullFlags = NULL; *pmatch = NULL; + /* + * If no trigram was extracted then we have to scan all the index. + */ + if (*nkeys == 0) + *searchMode = GIN_SEARCH_MODE_ALL; + PG_RETURN_POINTER(keys); } diff --git a/test/expected/index.out b/test/expected/index.out index 5625688..b8bc636 100644 --- a/test/expected/index.out +++ b/test/expected/index.out @@ -71,7 +71,7 @@ select count(*) from test_table where val @> array['%']; 0 -- 0 select count(*) from test_table where val @@> array['%']; -0 +32 -- 3 select count(*) from test_table where val <@ array['foo4', 'bar4', 'baz4']; 3