mirror of
https://github.com/postgres/postgres.git
synced 2025-06-13 07:41:39 +03:00
Fix contrib/btree_gist to handle collations properly.
Make use of the collation attached to the index column, instead of hard-wiring DEFAULT_COLLATION_OID. (Note: in theory this could require reindexing btree_gist indexes on textual columns, but I rather doubt anyone has one with a non-default declared collation as yet.)
This commit is contained in:
@ -32,41 +32,51 @@ Datum gbt_numeric_same(PG_FUNCTION_ARGS);
|
||||
/* define for comparison */
|
||||
|
||||
static bool
|
||||
gbt_numeric_gt(const void *a, const void *b)
|
||||
gbt_numeric_gt(const void *a, const void *b, Oid collation)
|
||||
{
|
||||
return (DatumGetBool(DirectFunctionCall2(numeric_gt, PointerGetDatum(a), PointerGetDatum(b))));
|
||||
return DatumGetBool(DirectFunctionCall2(numeric_gt,
|
||||
PointerGetDatum(a),
|
||||
PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool
|
||||
gbt_numeric_ge(const void *a, const void *b)
|
||||
gbt_numeric_ge(const void *a, const void *b, Oid collation)
|
||||
{
|
||||
return (DatumGetBool(DirectFunctionCall2(numeric_ge, PointerGetDatum(a), PointerGetDatum(b))));
|
||||
return DatumGetBool(DirectFunctionCall2(numeric_ge,
|
||||
PointerGetDatum(a),
|
||||
PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool
|
||||
gbt_numeric_eq(const void *a, const void *b)
|
||||
gbt_numeric_eq(const void *a, const void *b, Oid collation)
|
||||
{
|
||||
return (DatumGetBool(DirectFunctionCall2(numeric_eq, PointerGetDatum(a), PointerGetDatum(b))));
|
||||
return DatumGetBool(DirectFunctionCall2(numeric_eq,
|
||||
PointerGetDatum(a),
|
||||
PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool
|
||||
gbt_numeric_le(const void *a, const void *b)
|
||||
gbt_numeric_le(const void *a, const void *b, Oid collation)
|
||||
{
|
||||
return (DatumGetBool(DirectFunctionCall2(numeric_le, PointerGetDatum(a), PointerGetDatum(b))));
|
||||
return DatumGetBool(DirectFunctionCall2(numeric_le,
|
||||
PointerGetDatum(a),
|
||||
PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
static bool
|
||||
gbt_numeric_lt(const void *a, const void *b)
|
||||
gbt_numeric_lt(const void *a, const void *b, Oid collation)
|
||||
{
|
||||
return (DatumGetBool(DirectFunctionCall2(numeric_lt, PointerGetDatum(a), PointerGetDatum(b))));
|
||||
return DatumGetBool(DirectFunctionCall2(numeric_lt,
|
||||
PointerGetDatum(a),
|
||||
PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
|
||||
static int32
|
||||
gbt_numeric_cmp(const bytea *a, const bytea *b)
|
||||
gbt_numeric_cmp(const void *a, const void *b, Oid collation)
|
||||
{
|
||||
return
|
||||
(DatumGetInt32(DirectFunctionCall2(numeric_cmp, PointerGetDatum(a), PointerGetDatum(b))));
|
||||
return DatumGetInt32(DirectFunctionCall2(numeric_cmp,
|
||||
PointerGetDatum(a),
|
||||
PointerGetDatum(b)));
|
||||
}
|
||||
|
||||
|
||||
@ -116,7 +126,8 @@ gbt_numeric_consistent(PG_FUNCTION_ARGS)
|
||||
/* All cases served by this function are exact */
|
||||
*recheck = false;
|
||||
|
||||
retval = gbt_var_consistent(&r, query, &strategy, GIST_LEAF(entry), &tinfo);
|
||||
retval = gbt_var_consistent(&r, query, strategy, PG_GET_COLLATION(),
|
||||
GIST_LEAF(entry), &tinfo);
|
||||
PG_RETURN_BOOL(retval);
|
||||
}
|
||||
|
||||
@ -128,7 +139,8 @@ gbt_numeric_union(PG_FUNCTION_ARGS)
|
||||
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
|
||||
int32 *size = (int *) PG_GETARG_POINTER(1);
|
||||
|
||||
PG_RETURN_POINTER(gbt_var_union(entryvec, size, &tinfo));
|
||||
PG_RETURN_POINTER(gbt_var_union(entryvec, size, PG_GET_COLLATION(),
|
||||
&tinfo));
|
||||
}
|
||||
|
||||
|
||||
@ -139,7 +151,8 @@ gbt_numeric_same(PG_FUNCTION_ARGS)
|
||||
Datum d2 = PG_GETARG_DATUM(1);
|
||||
bool *result = (bool *) PG_GETARG_POINTER(2);
|
||||
|
||||
PG_RETURN_POINTER(gbt_var_same(result, d1, d2, &tinfo));
|
||||
*result = gbt_var_same(d1, d2, PG_GET_COLLATION(), &tinfo);
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
|
||||
@ -163,7 +176,7 @@ gbt_numeric_penalty(PG_FUNCTION_ARGS)
|
||||
|
||||
rk = gbt_var_key_readable(org);
|
||||
uni = PointerGetDatum(gbt_var_key_copy(&rk, TRUE));
|
||||
gbt_var_bin_union(&uni, newe, &tinfo);
|
||||
gbt_var_bin_union(&uni, newe, PG_GET_COLLATION(), &tinfo);
|
||||
ok = gbt_var_key_readable(org);
|
||||
uk = gbt_var_key_readable((GBT_VARKEY *) DatumGetPointer(uni));
|
||||
|
||||
@ -224,6 +237,7 @@ gbt_numeric_picksplit(PG_FUNCTION_ARGS)
|
||||
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
|
||||
GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
|
||||
|
||||
gbt_var_picksplit(entryvec, v, &tinfo);
|
||||
gbt_var_picksplit(entryvec, v, PG_GET_COLLATION(),
|
||||
&tinfo);
|
||||
PG_RETURN_POINTER(v);
|
||||
}
|
||||
|
Reference in New Issue
Block a user