Re: tsvector/tsearch equality and/or portability issue issue ?

From: AgentM <agentm(at)themactionfaction(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: tsvector/tsearch equality and/or portability issue issue ?
Date: 2006-08-24 17:48:52
Message-ID: C083305F-ED80-4A2A-B6A4-C32096D72994@themactionfaction.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Aug 24, 2006, at 12:58 , Andrew J. Kopciuch wrote:

> On Thursday 24 August 2006 10:34, Stefan Kaltenbrunner wrote:
>> We just had a complaint on IRC that:
>>
>> devel=# select 'blah foo bar'::tsvector = 'blah foo bar'::tsvector;
>> ?column?
>> ----------
>> f
>> (1 row)
>>
>
>
> This could be an endianess issue?
>
> This was probably the same person who posted this on the OpenFTS list.
>
> He's compiled from source :
>
> <snip>
> dew=# select version();
> PostgreSQL 8.1.4 on powerpc-apple-darwin8.6.0, compiled by GCC
> powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc.
> build
> 5250)
> </snip>
>
> I don't have any access to an OSX box to verify things ATM. I am
> trying to
> get access to one though. :S Can someone else verify this right
> now?

Stefan said he reproduced on OpenBSD/i386 so it is unlikely to be an
endianness issue. Anyway, here's the comparison code- I guess it
doesn't use strcmp to avoid encoding silliness. (?)

static int
silly_cmp_tsvector(const tsvector * a, const tsvector * b)
{
if (a->len < b->len)
return -1;
else if (a->len > b->len)
return 1;
else if (a->size < b->size)
return -1;
else if (a->size > b->size)
return 1;
else
{
unsigned char *aptr = (unsigned char *) (a->data) +
DATAHDRSIZE;
unsigned char *bptr = (unsigned char *) (b->data) +
DATAHDRSIZE;

while (aptr - ((unsigned char *) (a->data)) < a->len)
{
if (*aptr != *bptr)
return (*aptr < *bptr) ? -1 : 1;
aptr++;
bptr++;
}
}
return 0;
}

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-08-24 17:50:05 Re: tsvector/tsearch equality and/or portability issue issue ?
Previous Message Alvaro Herrera 2006-08-24 17:48:50 Re: Autovacuum on by default?