1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-28 23:42:10 +03:00

Add support of bool, bpchar, name and uuid to btree_gin

Mostly for completeness, but I believe there are cases to use that in
multicolumn GIN indexes.

Bump btree_gin module version

Author: Matheus Oliveira
Reviewed by: Tomas Vondra
Discussion: https://www.postgresql.org/message-id/flat/CAJghg4LMJf6Z13fnZD-MBNiGxzd0cA2=F3TDjNkX3eQH58hktQ@mail.gmail.com
This commit is contained in:
Teodor Sigaev
2018-04-05 18:19:10 +03:00
parent 0a64b45152
commit f4cd7102b5
13 changed files with 690 additions and 5 deletions

View File

@ -14,6 +14,7 @@
#include "utils/numeric.h"
#include "utils/timestamp.h"
#include "utils/varbit.h"
#include "utils/uuid.h"
PG_MODULE_MAGIC;
@ -350,6 +351,8 @@ leftmostvalue_text(void)
GIN_SUPPORT(text, true, leftmostvalue_text, bttextcmp)
GIN_SUPPORT(bpchar, true, leftmostvalue_text, bpcharcmp)
static Datum
leftmostvalue_char(void)
{
@ -437,7 +440,6 @@ GIN_SUPPORT(numeric, true, leftmostvalue_numeric, gin_numeric_cmp)
* routines it needs it, so we can't use DirectFunctionCall2.
*/
#define ENUM_IS_LEFTMOST(x) ((x) == InvalidOid)
PG_FUNCTION_INFO_V1(gin_enum_cmp);
@ -477,3 +479,30 @@ leftmostvalue_enum(void)
}
GIN_SUPPORT(anyenum, false, leftmostvalue_enum, gin_enum_cmp)
static Datum
leftmostvalue_uuid(void)
{
/* palloc0 will create the UUID with all zeroes: "00000000-0000-0000-0000-000000000000" */
pg_uuid_t *retval = (pg_uuid_t *) palloc0(sizeof(pg_uuid_t));
return UUIDPGetDatum(retval);
}
GIN_SUPPORT(uuid, false, leftmostvalue_uuid, uuid_cmp)
static Datum
leftmostvalue_name(void)
{
NameData* result = (NameData *) palloc0(NAMEDATALEN);
return NameGetDatum(result);
}
GIN_SUPPORT(name, false, leftmostvalue_name, btnamecmp)
static Datum
leftmostvalue_bool(void)
{
return BoolGetDatum(false);
}
GIN_SUPPORT(bool, false, leftmostvalue_bool, btboolcmp)