summaryrefslogtreecommitdiff
path: root/contrib/hstore/hstore_gist.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/hstore/hstore_gist.c')
-rw-r--r--contrib/hstore/hstore_gist.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c
index b036fa932f2..db58fb62ddf 100644
--- a/contrib/hstore/hstore_gist.c
+++ b/contrib/hstore/hstore_gist.c
@@ -1,5 +1,5 @@
/*
- * $PostgreSQL: pgsql/contrib/hstore/hstore_gist.c,v 1.11 2009/09/30 19:50:22 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/hstore/hstore_gist.c,v 1.12 2010/02/26 02:00:32 momjian Exp $
*/
#include "postgres.h"
@@ -118,20 +118,20 @@ ghstore_compress(PG_FUNCTION_ARGS)
HStore *val = DatumGetHStoreP(entry->key);
HEntry *hsent = ARRPTR(val);
char *ptr = STRPTR(val);
- int count = HS_COUNT(val);
- int i;
+ int count = HS_COUNT(val);
+ int i;
SET_VARSIZE(res, CALCGTSIZE(0));
for (i = 0; i < count; ++i)
{
- int h;
+ int h;
- h = crc32_sz((char *) HS_KEY(hsent,ptr,i), HS_KEYLEN(hsent,i));
+ h = crc32_sz((char *) HS_KEY(hsent, ptr, i), HS_KEYLEN(hsent, i));
HASH(GETSIGN(res), h);
- if (!HS_VALISNULL(hsent,i))
+ if (!HS_VALISNULL(hsent, i))
{
- h = crc32_sz((char *) HS_VAL(hsent,ptr,i), HS_VALLEN(hsent,i));
+ h = crc32_sz((char *) HS_VAL(hsent, ptr, i), HS_VALLEN(hsent, i));
HASH(GETSIGN(res), h);
}
}
@@ -511,6 +511,7 @@ ghstore_consistent(PG_FUNCTION_ARGS)
{
GISTTYPE *entry = (GISTTYPE *) DatumGetPointer(((GISTENTRY *) PG_GETARG_POINTER(0))->key);
StrategyNumber strategy = (StrategyNumber) PG_GETARG_UINT16(2);
+
/* Oid subtype = PG_GETARG_OID(3); */
bool *recheck = (bool *) PG_GETARG_POINTER(4);
bool res = true;
@@ -530,18 +531,18 @@ ghstore_consistent(PG_FUNCTION_ARGS)
HStore *query = PG_GETARG_HS(1);
HEntry *qe = ARRPTR(query);
char *qv = STRPTR(query);
- int count = HS_COUNT(query);
- int i;
+ int count = HS_COUNT(query);
+ int i;
for (i = 0; res && i < count; ++i)
{
- int crc = crc32_sz((char *) HS_KEY(qe,qv,i), HS_KEYLEN(qe,i));
+ int crc = crc32_sz((char *) HS_KEY(qe, qv, i), HS_KEYLEN(qe, i));
if (GETBIT(sign, HASHVAL(crc)))
{
- if (!HS_VALISNULL(qe,i))
+ if (!HS_VALISNULL(qe, i))
{
- crc = crc32_sz((char *) HS_VAL(qe,qv,i), HS_VALLEN(qe,i));
+ crc = crc32_sz((char *) HS_VAL(qe, qv, i), HS_VALLEN(qe, i));
if (!GETBIT(sign, HASHVAL(crc)))
res = false;
}
@@ -559,11 +560,11 @@ ghstore_consistent(PG_FUNCTION_ARGS)
}
else if (strategy == HStoreExistsAllStrategyNumber)
{
- ArrayType *query = PG_GETARG_ARRAYTYPE_P(1);
- Datum *key_datums;
- bool *key_nulls;
- int key_count;
- int i;
+ ArrayType *query = PG_GETARG_ARRAYTYPE_P(1);
+ Datum *key_datums;
+ bool *key_nulls;
+ int key_count;
+ int i;
deconstruct_array(query,
TEXTOID, -1, false, 'i',
@@ -571,7 +572,8 @@ ghstore_consistent(PG_FUNCTION_ARGS)
for (i = 0; res && i < key_count; ++i)
{
- int crc;
+ int crc;
+
if (key_nulls[i])
continue;
crc = crc32_sz(VARDATA(key_datums[i]), VARSIZE(key_datums[i]) - VARHDRSZ);
@@ -581,11 +583,11 @@ ghstore_consistent(PG_FUNCTION_ARGS)
}
else if (strategy == HStoreExistsAnyStrategyNumber)
{
- ArrayType *query = PG_GETARG_ARRAYTYPE_P(1);
- Datum *key_datums;
- bool *key_nulls;
- int key_count;
- int i;
+ ArrayType *query = PG_GETARG_ARRAYTYPE_P(1);
+ Datum *key_datums;
+ bool *key_nulls;
+ int key_count;
+ int i;
deconstruct_array(query,
TEXTOID, -1, false, 'i',
@@ -595,7 +597,8 @@ ghstore_consistent(PG_FUNCTION_ARGS)
for (i = 0; !res && i < key_count; ++i)
{
- int crc;
+ int crc;
+
if (key_nulls[i])
continue;
crc = crc32_sz(VARDATA(key_datums[i]), VARSIZE(key_datums[i]) - VARHDRSZ);