~ubuntu-branches/ubuntu/natty/postgresql-8.4/natty-security

« back to all changes in this revision

Viewing changes to src/backend/tsearch/to_tsany.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:
7
7
 *
8
8
 *
9
9
 * IDENTIFICATION
10
 
 *        $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.13 2009/01/01 17:23:48 momjian Exp $
 
10
 *        $PostgreSQL: pgsql/src/backend/tsearch/to_tsany.c,v 1.14 2009/06/11 14:49:03 momjian Exp $
11
11
 *
12
12
 *-------------------------------------------------------------------------
13
13
 */
32
32
static int
33
33
compareWORD(const void *a, const void *b)
34
34
{
35
 
        int res;
 
35
        int                     res;
36
36
 
37
37
        res = tsCompareString(
38
 
                                        ((ParsedWord *) a)->word, ((ParsedWord *) a)->len,
39
 
                                        ((ParsedWord *) b)->word, ((ParsedWord *) b)->len,
40
 
                                        false );
41
 
        
 
38
                                                  ((ParsedWord *) a)->word, ((ParsedWord *) a)->len,
 
39
                                                  ((ParsedWord *) b)->word, ((ParsedWord *) b)->len,
 
40
                                                  false);
 
41
 
42
42
        if (res == 0)
43
43
        {
44
44
                if (((ParsedWord *) a)->pos.pos == ((ParsedWord *) b)->pos.pos)
162
162
        if (lenstr > MAXSTRPOS)
163
163
                ereport(ERROR,
164
164
                                (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
165
 
                                        errmsg("string is too long for tsvector (%d bytes, max %d bytes)", lenstr, MAXSTRPOS)));
 
165
                                 errmsg("string is too long for tsvector (%d bytes, max %d bytes)", lenstr, MAXSTRPOS)));
166
166
 
167
167
        totallen = CALCDATASIZE(prs->curwords, lenstr);
168
168
        in = (TSVector) palloc0(totallen);
301
301
                                while (count < prs.curwords && pos == prs.words[count].pos.pos && variant == prs.words[count].nvariant)
302
302
                                {
303
303
 
304
 
                                        pushValue(state, prs.words[count].word, prs.words[count].len, weight, 
305
 
                                                        (  (prs.words[count].flags & TSL_PREFIX) || prefix  ) ? true : false );
 
304
                                        pushValue(state, prs.words[count].word, prs.words[count].len, weight,
 
305
                                                          ((prs.words[count].flags & TSL_PREFIX) || prefix) ? true : false);
306
306
                                        pfree(prs.words[count].word);
307
307
                                        if (cnt)
308
308
                                                pushOperator(state, OP_AND);
351
351
        }
352
352
        memcpy((void *) GETQUERY(query), (void *) res, len * sizeof(QueryItem));
353
353
 
354
 
        if ( len != query->size ) {
355
 
                char            *oldoperand = GETOPERAND(query);
356
 
                int4 lenoperand = VARSIZE(query) - (oldoperand - (char*)query);
 
354
        if (len != query->size)
 
355
        {
 
356
                char       *oldoperand = GETOPERAND(query);
 
357
                int4            lenoperand = VARSIZE(query) - (oldoperand - (char *) query);
357
358
 
358
 
                Assert( len < query->size );
 
359
                Assert(len < query->size);
359
360
 
360
361
                query->size = len;
361
 
                memcpy((void *) GETOPERAND(query), oldoperand, VARSIZE(query) - (oldoperand - (char*)query) );
362
 
                SET_VARSIZE(query, COMPUTESIZE( len, lenoperand )); 
 
362
                memcpy((void *) GETOPERAND(query), oldoperand, VARSIZE(query) - (oldoperand - (char *) query));
 
363
                SET_VARSIZE(query, COMPUTESIZE(len, lenoperand));
363
364
        }
364
365
 
365
366
        pfree(res);
401
402
        }
402
403
        memcpy((void *) GETQUERY(query), (void *) res, len * sizeof(QueryItem));
403
404
 
404
 
        if ( len != query->size ) {
405
 
                char            *oldoperand = GETOPERAND(query);
406
 
                int4 lenoperand = VARSIZE(query) - (oldoperand - (char*)query);
 
405
        if (len != query->size)
 
406
        {
 
407
                char       *oldoperand = GETOPERAND(query);
 
408
                int4            lenoperand = VARSIZE(query) - (oldoperand - (char *) query);
407
409
 
408
 
                Assert( len < query->size );
 
410
                Assert(len < query->size);
409
411
 
410
412
                query->size = len;
411
 
                memcpy((void *) GETOPERAND(query), oldoperand, lenoperand );
412
 
                SET_VARSIZE(query, COMPUTESIZE( len, lenoperand )); 
 
413
                memcpy((void *) GETOPERAND(query), oldoperand, lenoperand);
 
414
                SET_VARSIZE(query, COMPUTESIZE(len, lenoperand));
413
415
        }
414
416
 
415
417
        pfree(res);