Re: PATCH: CITEXT 2.0 - Mailing list pgsql-hackers

From David E. Wheeler
Subject Re: PATCH: CITEXT 2.0
Date
Msg-id C563AF78-6F19-4791-A4FB-44D8C047B16F@kineticode.com
Whole thread Raw
In response to Re: PATCH: CITEXT 2.0  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: PATCH: CITEXT 2.0
List pgsql-hackers
On Jul 3, 2008, at 09:53, Alvaro Herrera wrote:

>> Thanks. What would citext_hash() look like? I don't see a  
>> text_hash() to
>> borrow from anywhere in src/.
>
> See hash_any().  I assume the difficulty is making sure that
> hash("FOO") = hash("foo") ...

Great, big help, thank you. So does this look sensible?

Datum
citext_hash(PG_FUNCTION_ARGS)
{    char       *txt;    char       *str;    Datum       result;
    txt = cilower( PG_GETARG_TEXT_PP(0) );    str = VARDATA_ANY(txt);
    result = hash_any((unsigned char *) str, VARSIZE_ANY_EXHDR(txt));
    /* Avoid leaking memory for toasted inputs */    PG_FREE_IF_COPY(txt, 0);    pfree( str );
    return result;
}

And how might I be able to test that it actually works?

Best,

David


pgsql-hackers by date:

Previous
From: "Heikki Linnakangas"
Date:
Subject: Re: gsoc, text search selectivity and dllist enhancments
Next
From: "David E. Wheeler"
Date:
Subject: Re: PATCH: CITEXT 2.0