1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-31 22:04:40 +03:00

Add a 64-bit hash function for type citext.

Amul Sul, reviewed by Hironobu Suzuki

Discussion: https://postgr.es/m/CAAJ_b947JjnNr9Cp45iNjSqKf6PA5mCTmKsRwPjows93YwQrmw@mail.gmail.com
This commit is contained in:
Tom Lane
2018-11-23 13:24:45 -05:00
parent a314c34079
commit 48c41fa974
7 changed files with 69 additions and 2 deletions

View File

@ -153,6 +153,26 @@ citext_hash(PG_FUNCTION_ARGS)
PG_RETURN_DATUM(result);
}
PG_FUNCTION_INFO_V1(citext_hash_extended);
Datum
citext_hash_extended(PG_FUNCTION_ARGS)
{
text *txt = PG_GETARG_TEXT_PP(0);
uint64 seed = PG_GETARG_INT64(1);
char *str;
Datum result;
str = str_tolower(VARDATA_ANY(txt), VARSIZE_ANY_EXHDR(txt), DEFAULT_COLLATION_OID);
result = hash_any_extended((unsigned char *) str, strlen(str), seed);
pfree(str);
/* Avoid leaking memory for toasted inputs */
PG_FREE_IF_COPY(txt, 0);
PG_RETURN_DATUM(result);
}
/*
* ==================
* OPERATOR FUNCTIONS