mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Fix default signature length for gist_ltree_ops
911e702077
implemented operator class parameters including the signature length in ltree. Previously, the signature length for gist_ltree_ops was 8. Because of bug911e702077
the default signature length for gist_ltree_ops became 28 for ltree 1.1 (where options method is NOT provided) and 8 for ltree 1.2 (where options method is provided). This commit changes the default signature length for ltree 1.1 to 8. Existing gist_ltree_ops indexes might be corrupted in various scenarios. Thus, we have to recommend reindexing all the gist_ltree_ops indexes after the upgrade. Reported-by: Victor Yegorov Reviewed-by: Tomas Vondra, Tom Lane, Andres Freund, Nikita Glukhov Reviewed-by: Andrew Dunstan Author: Tomas Vondra, Alexander Korotkov Discussion: https://postgr.es/m/17406-71e02820ae79bb40%40postgresql.org Discussion: https://postgr.es/m/d80e0a55-6c3e-5b26-53e3-3c4f973f737c%40enterprisedb.com
This commit is contained in:
parent
46d9bfb0a6
commit
7e74aafc43
@ -229,11 +229,13 @@ int ltree_strncasecmp(const char *a, const char *b, size_t s);
|
||||
|
||||
/* GiST support for ltree */
|
||||
|
||||
#define SIGLEN_MAX GISTMaxIndexKeySize
|
||||
#define SIGLEN_DEFAULT (2 * sizeof(int32))
|
||||
#define BITBYTE 8
|
||||
#define SIGLEN (sizeof(int32) * SIGLENINT)
|
||||
#define SIGLENBIT(siglen) ((siglen) * BITBYTE)
|
||||
#define LTREE_SIGLEN_DEFAULT (2 * sizeof(int32))
|
||||
#define LTREE_SIGLEN_MAX GISTMaxIndexKeySize
|
||||
#define LTREE_GET_SIGLEN() (PG_HAS_OPCLASS_OPTIONS() ? \
|
||||
((LtreeGistOptions *) PG_GET_OPCLASS_OPTIONS())->siglen : \
|
||||
LTREE_SIGLEN_DEFAULT)
|
||||
|
||||
typedef unsigned char *BITVECP;
|
||||
|
||||
|
@ -130,7 +130,7 @@ ltree_same(PG_FUNCTION_ARGS)
|
||||
ltree_gist *a = (ltree_gist *) PG_GETARG_POINTER(0);
|
||||
ltree_gist *b = (ltree_gist *) PG_GETARG_POINTER(1);
|
||||
bool *result = (bool *) PG_GETARG_POINTER(2);
|
||||
int siglen = LTREE_GET_ASIGLEN();
|
||||
int siglen = LTREE_GET_SIGLEN();
|
||||
|
||||
*result = false;
|
||||
if (LTG_ISONENODE(a) != LTG_ISONENODE(b))
|
||||
@ -190,7 +190,7 @@ ltree_union(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
|
||||
int *size = (int *) PG_GETARG_POINTER(1);
|
||||
int siglen = LTREE_GET_ASIGLEN();
|
||||
int siglen = LTREE_GET_SIGLEN();
|
||||
BITVECP base = palloc0(siglen);
|
||||
int32 i,
|
||||
j;
|
||||
@ -260,7 +260,7 @@ ltree_penalty(PG_FUNCTION_ARGS)
|
||||
ltree_gist *origval = (ltree_gist *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
|
||||
ltree_gist *newval = (ltree_gist *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(1))->key);
|
||||
float *penalty = (float *) PG_GETARG_POINTER(2);
|
||||
int siglen = LTREE_GET_ASIGLEN();
|
||||
int siglen = LTREE_GET_SIGLEN();
|
||||
int32 cmpr,
|
||||
cmpl;
|
||||
|
||||
@ -292,7 +292,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
|
||||
{
|
||||
GistEntryVector *entryvec = (GistEntryVector *) PG_GETARG_POINTER(0);
|
||||
GIST_SPLITVEC *v = (GIST_SPLITVEC *) PG_GETARG_POINTER(1);
|
||||
int siglen = LTREE_GET_ASIGLEN();
|
||||
int siglen = LTREE_GET_SIGLEN();
|
||||
OffsetNumber j;
|
||||
int32 i;
|
||||
RIX *array;
|
||||
@ -618,7 +618,7 @@ ltree_consistent(PG_FUNCTION_ARGS)
|
||||
|
||||
/* Oid subtype = PG_GETARG_OID(3); */
|
||||
bool *recheck = (bool *) PG_GETARG_POINTER(4);
|
||||
int siglen = LTREE_GET_ASIGLEN();
|
||||
int siglen = LTREE_GET_SIGLEN();
|
||||
ltree_gist *key = (ltree_gist *) DatumGetPointer(entry->key);
|
||||
void *query = NULL;
|
||||
bool res = false;
|
||||
@ -724,7 +724,7 @@ ltree_gist_options(PG_FUNCTION_ARGS)
|
||||
init_local_reloptions(relopts, sizeof(LtreeGistOptions));
|
||||
add_local_int_reloption(relopts, "siglen",
|
||||
"signature length in bytes",
|
||||
SIGLEN_DEFAULT, 1, SIGLEN_MAX,
|
||||
LTREE_SIGLEN_DEFAULT, 1, LTREE_SIGLEN_MAX,
|
||||
offsetof(LtreeGistOptions, siglen));
|
||||
|
||||
PG_RETURN_VOID();
|
||||
|
Loading…
Reference in New Issue
Block a user