mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
Add prefix operator for TEXT type.
The prefix operator along with SP-GiST indexes can be used as an alternative for LIKE 'word%' commands and it doesn't have a limitation of string/prefix length as B-Tree has. Bump catalog version Author: Ildus Kurbangaliev with some editorization by me Review by: Arthur Zakirov, Alexander Korotkov, and me Discussion: https://www.postgresql.org/message-id/flat/20180202180327.222b04b3@wp.localdomain
This commit is contained in:
@ -1761,6 +1761,34 @@ text_ge(PG_FUNCTION_ARGS)
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
text_starts_with(PG_FUNCTION_ARGS)
|
||||
{
|
||||
Datum arg1 = PG_GETARG_DATUM(0);
|
||||
Datum arg2 = PG_GETARG_DATUM(1);
|
||||
bool result;
|
||||
Size len1,
|
||||
len2;
|
||||
|
||||
len1 = toast_raw_datum_size(arg1);
|
||||
len2 = toast_raw_datum_size(arg2);
|
||||
if (len2 > len1)
|
||||
result = false;
|
||||
else
|
||||
{
|
||||
text *targ1 = DatumGetTextPP(arg1);
|
||||
text *targ2 = DatumGetTextPP(arg2);
|
||||
|
||||
result = (memcmp(VARDATA_ANY(targ1), VARDATA_ANY(targ2),
|
||||
VARSIZE_ANY_EXHDR(targ2)) == 0);
|
||||
|
||||
PG_FREE_IF_COPY(targ1, 0);
|
||||
PG_FREE_IF_COPY(targ2, 1);
|
||||
}
|
||||
|
||||
PG_RETURN_BOOL(result);
|
||||
}
|
||||
|
||||
Datum
|
||||
bttextcmp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
|
Reference in New Issue
Block a user