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

Commit 5c80642

Browse files
committed
Remove unnecessary int2vector-specific hash function and equality operator.
These functions were originally added in commit d8cedf6 to support use of int2vector columns as catcache lookup keys. However, there are no catcaches that use such columns. (Indeed I now think it must always have been dead code: a catcache with such a key column would need an underlying unique index on the column, but we've never had an int2vector btree opclass.) Getting rid of the int2vector-specific operator and function does not lose any functionality, because operations on int2vectors will now fall back to the generic anyarray support. This avoids a wart that a btree index on an int2vector column (made using anyarray_ops) would fail to match equality searches, because int2vectoreq wasn't a member of the opclass. We don't really care much about that, since int2vector is not meant as a type for users to use, but it's silly to have extra code and less functionality. If we ever do want a catcache to be indexed by an int2vector column, we'd need to put back full btree and hash opclasses for int2vector, comparable to the support for oidvector. (The anyarray code can't be used at such a low level, because it needs to do catcache lookups.) But we'll deal with that if/when the need arises. Also worth noting is that removal of the hash int2vector_ops opclass will break any user-created hash indexes on int2vector columns. While hash anyarray_ops would serve the same purpose, it would probably not compute the same hash values and thus wouldn't be on-disk-compatible. Given that int2vector isn't a user-facing type and we're planning other incompatible changes in hash indexes for v10 anyway, this doesn't seem like something to worry about, but it's probably worth mentioning here. Amit Langote Discussion: <d9bb74f8-b194-7307-9ebd-90645d377e45@lab.ntt.co.jp>
1 parent 8518583 commit 5c80642

File tree

12 files changed

+1
-41
lines changed

12 files changed

+1
-41
lines changed

src/backend/access/hash/hashfunc.c

-8
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,6 @@ hashoidvector(PG_FUNCTION_ARGS)
130130
return hash_any((unsigned char *) key->values, key->dim1 * sizeof(Oid));
131131
}
132132

133-
Datum
134-
hashint2vector(PG_FUNCTION_ARGS)
135-
{
136-
int2vector *key = (int2vector *) PG_GETARG_POINTER(0);
137-
138-
return hash_any((unsigned char *) key->values, key->dim1 * sizeof(int16));
139-
}
140-
141133
Datum
142134
hashname(PG_FUNCTION_ARGS)
143135
{

src/backend/utils/adt/int.c

-15
Original file line numberDiff line numberDiff line change
@@ -254,21 +254,6 @@ int2vectorsend(PG_FUNCTION_ARGS)
254254
return array_send(fcinfo);
255255
}
256256

257-
/*
258-
* We don't have a complete set of int2vector support routines,
259-
* but we need int2vectoreq for catcache indexing.
260-
*/
261-
Datum
262-
int2vectoreq(PG_FUNCTION_ARGS)
263-
{
264-
int2vector *a = (int2vector *) PG_GETARG_POINTER(0);
265-
int2vector *b = (int2vector *) PG_GETARG_POINTER(1);
266-
267-
if (a->dim1 != b->dim1)
268-
PG_RETURN_BOOL(false);
269-
PG_RETURN_BOOL(memcmp(a->values, b->values, a->dim1 * sizeof(int16)) == 0);
270-
}
271-
272257

273258
/*****************************************************************************
274259
* PUBLIC ROUTINES *

src/backend/utils/cache/catcache.c

-5
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ GetCCHashEqFuncs(Oid keytype, PGFunction *hashfunc, RegProcedure *eqfunc)
126126

127127
*eqfunc = F_INT2EQ;
128128
break;
129-
case INT2VECTOROID:
130-
*hashfunc = hashint2vector;
131-
132-
*eqfunc = F_INT2VECTOREQ;
133-
break;
134129
case INT4OID:
135130
*hashfunc = hashint4;
136131

src/include/access/hash.h

-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ extern Datum hashenum(PG_FUNCTION_ARGS);
283283
extern Datum hashfloat4(PG_FUNCTION_ARGS);
284284
extern Datum hashfloat8(PG_FUNCTION_ARGS);
285285
extern Datum hashoidvector(PG_FUNCTION_ARGS);
286-
extern Datum hashint2vector(PG_FUNCTION_ARGS);
287286
extern Datum hashname(PG_FUNCTION_ARGS);
288287
extern Datum hashtext(PG_FUNCTION_ARGS);
289288
extern Datum hashvarlena(PG_FUNCTION_ARGS);

src/include/catalog/catversion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201609261
56+
#define CATALOG_VERSION_NO 201610121
5757

5858
#endif

src/include/catalog/pg_amop.h

-2
Original file line numberDiff line numberDiff line change
@@ -573,8 +573,6 @@ DATA(insert ( 2040 1114 1114 1 s 2060 405 0 ));
573573
DATA(insert ( 2222 16 16 1 s 91 405 0 ));
574574
/* bytea_ops */
575575
DATA(insert ( 2223 17 17 1 s 1955 405 0 ));
576-
/* int2vector_ops */
577-
DATA(insert ( 2224 22 22 1 s 386 405 0 ));
578576
/* xid_ops */
579577
DATA(insert ( 2225 28 28 1 s 352 405 0 ));
580578
/* cid_ops */

src/include/catalog/pg_amproc.h

-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ DATA(insert ( 2001 1266 1266 1 1696 ));
173173
DATA(insert ( 2040 1114 1114 1 2039 ));
174174
DATA(insert ( 2222 16 16 1 454 ));
175175
DATA(insert ( 2223 17 17 1 456 ));
176-
DATA(insert ( 2224 22 22 1 398 ));
177176
DATA(insert ( 2225 28 28 1 450 ));
178177
DATA(insert ( 2226 29 29 1 450 ));
179178
DATA(insert ( 2227 702 702 1 450 ));

src/include/catalog/pg_opclass.h

-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ DATA(insert ( 403 bpchar_pattern_ops PGNSP PGUID 2097 1042 f 0 ));
168168
DATA(insert ( 403 money_ops PGNSP PGUID 2099 790 t 0 ));
169169
DATA(insert ( 405 bool_ops PGNSP PGUID 2222 16 t 0 ));
170170
DATA(insert ( 405 bytea_ops PGNSP PGUID 2223 17 t 0 ));
171-
DATA(insert ( 405 int2vector_ops PGNSP PGUID 2224 22 t 0 ));
172171
DATA(insert ( 403 tid_ops PGNSP PGUID 2789 27 t 0 ));
173172
DATA(insert ( 405 xid_ops PGNSP PGUID 2225 28 t 0 ));
174173
DATA(insert ( 405 cid_ops PGNSP PGUID 2226 29 t 0 ));

src/include/catalog/pg_operator.h

-2
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ DATA(insert OID = 389 ( "!!" PGNSP PGUID l f f 0 20 1700 0 0 numeric_fac
156156
DESCR("deprecated, use ! instead");
157157
DATA(insert OID = 385 ( "=" PGNSP PGUID b f t 29 29 16 385 0 cideq eqsel eqjoinsel ));
158158
DESCR("equal");
159-
DATA(insert OID = 386 ( "=" PGNSP PGUID b f t 22 22 16 386 0 int2vectoreq eqsel eqjoinsel ));
160-
DESCR("equal");
161159

162160
DATA(insert OID = 387 ( "=" PGNSP PGUID b t f 27 27 16 387 402 tideq eqsel eqjoinsel ));
163161
DESCR("equal");

src/include/catalog/pg_opfamily.h

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ DATA(insert OID = 2099 ( 403 money_ops PGNSP PGUID ));
117117
DATA(insert OID = 2222 ( 405 bool_ops PGNSP PGUID ));
118118
#define BOOL_HASH_FAM_OID 2222
119119
DATA(insert OID = 2223 ( 405 bytea_ops PGNSP PGUID ));
120-
DATA(insert OID = 2224 ( 405 int2vector_ops PGNSP PGUID ));
121120
DATA(insert OID = 2789 ( 403 tid_ops PGNSP PGUID ));
122121
DATA(insert OID = 2225 ( 405 xid_ops PGNSP PGUID ));
123122
DATA(insert OID = 2226 ( 405 cid_ops PGNSP PGUID ));

src/include/catalog/pg_proc.h

-3
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ DATA(insert OID = 313 ( int4 PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 23
540540
DESCR("convert int2 to int4");
541541
DATA(insert OID = 314 ( int2 PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 21 "23" _null_ _null_ _null_ _null_ _null_ i4toi2 _null_ _null_ _null_ ));
542542
DESCR("convert int4 to int2");
543-
DATA(insert OID = 315 ( int2vectoreq PGNSP PGUID 12 1 0 0 0 f f f f t f i s 2 0 16 "22 22" _null_ _null_ _null_ _null_ _null_ int2vectoreq _null_ _null_ _null_ ));
544543
DATA(insert OID = 316 ( float8 PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 701 "23" _null_ _null_ _null_ _null_ _null_ i4tod _null_ _null_ _null_ ));
545544
DESCR("convert int4 to float8");
546545
DATA(insert OID = 317 ( int4 PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 23 "701" _null_ _null_ _null_ _null_ _null_ dtoi4 _null_ _null_ _null_ ));
@@ -687,8 +686,6 @@ DATA(insert OID = 457 ( hashoidvector PGNSP PGUID 12 1 0 0 0 f f f f t f i s
687686
DESCR("hash");
688687
DATA(insert OID = 329 ( hash_aclitem PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 23 "1033" _null_ _null_ _null_ _null_ _null_ hash_aclitem _null_ _null_ _null_ ));
689688
DESCR("hash");
690-
DATA(insert OID = 398 ( hashint2vector PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 23 "22" _null_ _null_ _null_ _null_ _null_ hashint2vector _null_ _null_ _null_ ));
691-
DESCR("hash");
692689
DATA(insert OID = 399 ( hashmacaddr PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 23 "829" _null_ _null_ _null_ _null_ _null_ hashmacaddr _null_ _null_ _null_ ));
693690
DESCR("hash");
694691
DATA(insert OID = 422 ( hashinet PGNSP PGUID 12 1 0 0 0 f f f f t f i s 1 0 23 "869" _null_ _null_ _null_ _null_ _null_ hashinet _null_ _null_ _null_ ));

src/include/utils/builtins.h

-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,6 @@ extern Datum int2vectorin(PG_FUNCTION_ARGS);
192192
extern Datum int2vectorout(PG_FUNCTION_ARGS);
193193
extern Datum int2vectorrecv(PG_FUNCTION_ARGS);
194194
extern Datum int2vectorsend(PG_FUNCTION_ARGS);
195-
extern Datum int2vectoreq(PG_FUNCTION_ARGS);
196195
extern Datum int4in(PG_FUNCTION_ARGS);
197196
extern Datum int4out(PG_FUNCTION_ARGS);
198197
extern Datum int4recv(PG_FUNCTION_ARGS);

0 commit comments

Comments
 (0)