Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0fc6e45

Browse files
committed
Added int2vector compatibility patch by Teodor.
See PGPRO-1262.
1 parent 4a9c53f commit 0fc6e45

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

contrib/fulleq/fulleq.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,37 @@ fullhash_##type(PG_FUNCTION_ARGS) { \
4242
) ); \
4343
}
4444

45+
static Datum
46+
hashint2vector(PG_FUNCTION_ARGS)
47+
{
48+
int2vector *key = (int2vector *) PG_GETARG_POINTER(0);
49+
50+
return hash_any((unsigned char *) key->values, key->dim1 * sizeof(int16));
51+
}
52+
53+
/*
54+
* We don't have a complete set of int2vector support routines,
55+
* but we need int2vectoreq for catcache indexing.
56+
*/
57+
static Datum
58+
int2vectoreq(PG_FUNCTION_ARGS)
59+
{
60+
int2vector *a = (int2vector *) PG_GETARG_POINTER(0);
61+
int2vector *b = (int2vector *) PG_GETARG_POINTER(1);
62+
63+
if (a->dim1 != b->dim1)
64+
PG_RETURN_BOOL(false);
65+
PG_RETURN_BOOL(memcmp(a->values, b->values, a->dim1 * sizeof(int16)) == 0);
66+
}
67+
68+
4569

4670
FULLEQ_FUNC( bool , booleq , hashchar );
4771
FULLEQ_FUNC( bytea , byteaeq , hashvarlena );
4872
FULLEQ_FUNC( char , chareq , hashchar );
4973
FULLEQ_FUNC( name , nameeq , hashname );
5074
FULLEQ_FUNC( int8 , int8eq , hashint8 );
5175
FULLEQ_FUNC( int2 , int2eq , hashint2 );
52-
/* FULLEQ_FUNC( int2vector , int2vectoreq , hashint2vector );v10 drop
53-
* support for int2vector equality and hash operator in commit
54-
* 5c80642aa8de8393b08cd3cbf612b325cedd98dc */
5576
FULLEQ_FUNC( int4 , int4eq , hashint4 );
5677
FULLEQ_FUNC( text , texteq , hashtext );
5778
FULLEQ_FUNC( oid , oideq , hashoid );
@@ -72,3 +93,10 @@ FULLEQ_FUNC( timestamp , timestamp_eq , hashfloat8 );
7293
FULLEQ_FUNC( timestamptz , timestamp_eq , hashfloat8 );
7394
FULLEQ_FUNC( interval , interval_eq , interval_hash );
7495
FULLEQ_FUNC( timetz , timetz_eq , timetz_hash );
96+
97+
/*
98+
* v10 drop * support for int2vector equality and hash operator in commit
99+
* 5c80642aa8de8393b08cd3cbf612b325cedd98dc, but for compatibility
100+
* we still add this operators
101+
*/
102+
FULLEQ_FUNC( int2vector , int2vectoreq , hashint2vector );

0 commit comments

Comments
 (0)