Re: tsearch refactorings - Mailing list pgsql-patches

From Heikki Linnakangas
Subject Re: tsearch refactorings
Date
Msg-id 46DEDF68.8040802@enterprisedb.com
Whole thread Raw
In response to Re: tsearch refactorings  (Teodor Sigaev <teodor@sigaev.ru>)
Responses Re: tsearch refactorings  (Teodor Sigaev <teodor@sigaev.ru>)
List pgsql-patches
Teodor Sigaev wrote:
>> Ok. Probably easiest to do that by changing the palloc to palloc0 in
>> parse_tsquery.
>
> and change sizeof to sizeof(QueryItem)

Do you mean the sizeofs in the memcpys in parse_tsquery? You can't
change them. The source structs are allocated in
pushOperand/pushOperator, using sizeof(QueryOperand/QueryOperator), so
if you copy sizeof(QueryItem) bytes from them, you'll copy some random
piece of memory. If you just allocate the TSQuery with palloc0, that'll
make sure that any memory area not copied into in the loop will be zero.

BTW, can you explain what the CRC-32 of a value is used for? It looks
like it's used to speed up some operations, by comparing the CRCs before
comparing the values, but I didn't quite figure out how it works. How
much of a performance difference does it make? Would hash_any do a
better/cheaper job?

In any case, I think we need to calculate the CRC/hash in tsqueryrecv,
instead of trusting the client.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

pgsql-patches by date:

Previous
From: Teodor Sigaev
Date:
Subject: Re: tsearch refactorings
Next
From: Tom Lane
Date:
Subject: Re: Lazy xid assignment V4