Re: PATCH: CITEXT 2.0

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PATCH: CITEXT 2.0
Date: 2008-07-05 05:39:54
Message-ID: C563AF78-6F19-4791-A4FB-44D8C047B16F@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David E. Wheeler 2008-07-05 05:54:45 Re: PATCH: CITEXT 2.0
Previous Message Heikki Linnakangas 2008-07-04 19:20:08 Re: gsoc, text search selectivity and dllist enhancments