OSDN Git Service

Fix bug in enable_recheck with gin_key_limit = 1.
authorMasaoFujii <masao.fujii@gmail.com>
Sat, 28 Sep 2013 00:24:46 +0000 (09:24 +0900)
committerMasaoFujii <masao.fujii@gmail.com>
Sat, 28 Sep 2013 00:30:17 +0000 (09:30 +0900)
Beena Emerson, slightly modified by me

bigm_gin.c
expected/pg_bigm.out
sql/pg_bigm.sql

index 242c2e7..5bcbd4b 100644 (file)
@@ -192,15 +192,16 @@ gin_bigm_consistent(PG_FUNCTION_ARGS)
        bool            res;
        int32           i;
 
+       Assert(nkeys > 0);
+
        /*
         * Don't recheck the heap tuple against the query if either
         * pg_bigm.enable_recheck is disabled or the search word is
         * the special one so that the index can return the exact
         * result.
         */
-       *recheck = bigm_enable_recheck;
-       if (nkeys == 1)
-               *recheck = *((bool *) extra_data);
+       *recheck = bigm_enable_recheck &&
+               ((nkeys > 1) || *((bool *) extra_data));
 
        switch (strategy)
        {
index ef8c141..e4fc7d9 100644 (file)
@@ -551,8 +551,25 @@ SELECT col1 FROM test_bigm WHERE col1 LIKE likequery('she tore');
  It was a trivial mistake
 (11 rows)
 
---SET pg_bigm.gin_key_limit = 1;
---SELECT col1 FROM test_bigm WHERE col1 LIKE likequery('she tore');
+SET pg_bigm.gin_key_limit = 1;
+SELECT col1 FROM test_bigm WHERE col1 LIKE likequery('she tore');
+                                     col1                                      
+-------------------------------------------------------------------------------
+ pg_trgm - Tool that provides 3-gram full text search capability in PostgreSQL
+ pg_bigm - Tool that provides 2-gram full text search capability in PostgreSQL
+ pg_bigm has improved the full text search performance by 200%
+ You can create an index for full text search by using GIN index.
+ \w FILE outputs the current query buffer to the file specified
+ And she tore the dress in anger
+ She sells sea shells on the sea shore
+ Those orchids are very special to her
+ Did you not see the wet floor sign?
+ The stylist refused them politely
+ You will get into deep trouble for staying out late
+ He is awaiting trial
+ It was a trivial mistake
+(13 rows)
+
 SET pg_bigm.enable_recheck = on;
 SET pg_bigm.gin_key_limit = 0;
 -- tests with standard_conforming_strings disabled
index 6a64b50..4def229 100644 (file)
@@ -136,8 +136,8 @@ SET pg_bigm.gin_key_limit = 3;
 SELECT col1 FROM test_bigm WHERE col1 LIKE likequery('she tore');
 SET pg_bigm.gin_key_limit = 2;
 SELECT col1 FROM test_bigm WHERE col1 LIKE likequery('she tore');
---SET pg_bigm.gin_key_limit = 1;
---SELECT col1 FROM test_bigm WHERE col1 LIKE likequery('she tore');
+SET pg_bigm.gin_key_limit = 1;
+SELECT col1 FROM test_bigm WHERE col1 LIKE likequery('she tore');
 
 SET pg_bigm.enable_recheck = on;
 SET pg_bigm.gin_key_limit = 0;