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

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to