~ubuntu-branches/ubuntu/trusty/postgresql-8.4/trusty

« back to all changes in this revision

Viewing changes to contrib/pg_trgm/trgm_gist.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-11 16:59:35 UTC
  • mfrom: (5.1.1 karmic)
  • Revision ID: james.westby@ubuntu.com-20090711165935-jfwin6gfrxf0gfsi
Tags: 8.4.0-2
* debian/libpq-dev.install: Ship catalog/genbki.h. (Closes: #536139)
* debian/rules: Drop --enable-cassert for final release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * $PostgreSQL: pgsql/contrib/pg_trgm/trgm_gist.c,v 1.15 2008/07/11 11:56:48 teodor Exp $ 
 
2
 * $PostgreSQL: pgsql/contrib/pg_trgm/trgm_gist.c,v 1.16 2009/06/11 14:48:51 momjian Exp $
3
3
 */
4
4
#include "trgm.h"
5
5
 
75
75
}
76
76
 
77
77
static void
78
 
makesign(BITVECP sign, TRGM * a)
 
78
makesign(BITVECP sign, TRGM *a)
79
79
{
80
80
        int4            k,
81
81
                                len = ARRNELEM(a);
164
164
{
165
165
        GISTENTRY  *entry = (GISTENTRY *) PG_GETARG_POINTER(0);
166
166
        text       *query = PG_GETARG_TEXT_P(1);
 
167
 
167
168
        /* StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2); */
168
169
        /* Oid          subtype = PG_GETARG_OID(3); */
169
170
        bool       *recheck = (bool *) PG_GETARG_POINTER(4);
170
171
        TRGM       *key = (TRGM *) DatumGetPointer(entry->key);
171
172
        TRGM       *qtrg;
172
173
        bool            res = false;
173
 
        char            *cache  = (char*) fcinfo->flinfo->fn_extra;
 
174
        char       *cache = (char *) fcinfo->flinfo->fn_extra;
174
175
 
175
176
        /* All cases served by this function are exact */
176
177
        *recheck = false;
177
178
 
178
 
        if ( cache == NULL || VARSIZE(cache) != VARSIZE(query) || memcmp( cache, query, VARSIZE(query) ) !=0  )
 
179
        if (cache == NULL || VARSIZE(cache) != VARSIZE(query) || memcmp(cache, query, VARSIZE(query)) != 0)
179
180
        {
180
 
                qtrg = generate_trgm(VARDATA(query), VARSIZE(query) - VARHDRSZ);    
 
181
                qtrg = generate_trgm(VARDATA(query), VARSIZE(query) - VARHDRSZ);
181
182
 
182
183
                if (cache)
183
184
                        pfree(cache);
184
185
 
185
186
                fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
186
 
                                                        MAXALIGN(VARSIZE(query)) + VARSIZE(qtrg) );
187
 
                cache = (char*) fcinfo->flinfo->fn_extra;
 
187
                                                                   MAXALIGN(VARSIZE(query)) + VARSIZE(qtrg));
 
188
                cache = (char *) fcinfo->flinfo->fn_extra;
188
189
 
189
 
                memcpy( cache, query, VARSIZE(query) );
190
 
                memcpy( cache + MAXALIGN(VARSIZE(query)), qtrg, VARSIZE(qtrg) );
 
190
                memcpy(cache, query, VARSIZE(query));
 
191
                memcpy(cache + MAXALIGN(VARSIZE(query)), qtrg, VARSIZE(qtrg));
191
192
        }
192
193
 
193
 
        qtrg = (TRGM*)( cache + MAXALIGN(VARSIZE(query)) );
 
194
        qtrg = (TRGM *) (cache + MAXALIGN(VARSIZE(query)));
194
195
 
195
196
        if (GIST_LEAF(entry))
196
197
        {                                                       /* all leafs contains orig trgm */
228
229
}
229
230
 
230
231
static int4
231
 
unionkey(BITVECP sbase, TRGM * add)
 
232
unionkey(BITVECP sbase, TRGM *add)
232
233
{
233
234
        int4            i;
234
235
 
375
376
}
376
377
 
377
378
static int
378
 
hemdist(TRGM * a, TRGM * b)
 
379
hemdist(TRGM *a, TRGM *b)
379
380
{
380
381
        if (ISALLTRUE(a))
381
382
        {
425
426
} CACHESIGN;
426
427
 
427
428
static void
428
 
fillcache(CACHESIGN *item, TRGM * key)
 
429
fillcache(CACHESIGN *item, TRGM *key)
429
430
{
430
431
        item->allistrue = false;
431
432
        if (ISARRKEY(key))