Skip to content

Commit

Permalink
Fix bug #1, when the query contains no trigrams.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffjanes committed Oct 13, 2015
1 parent 61990a2 commit e051c02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/parray_gin.c
Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion test/expected/index.out
Expand Up @@ -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
Expand Down

0 comments on commit e051c02

Please sign in to comment.