Skip to content

Commit 817a3e6

Browse files
committed
Enclosed below I have a patch to allow a btree index on the int8 type.
I would like some feedback on what the hash function for the int8 hash function in the ./backend/access/hash/hashfunc.c should return. Also, could someone (maybe Tomas Lockhart?) look-over the patch and make sure the system table entries are correct? I've tried to research them as much as I could, but some of them are still not clear to me. Thanks, -Ryan
1 parent f9f458b commit 817a3e6

File tree

7 files changed

+44
-7
lines changed

7 files changed

+44
-7
lines changed

src/backend/access/hash/hashfunc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.13 1999/02/13 23:14:18 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.14 1999/03/14 05:08:55 momjian Exp $
1111
*
1212
* NOTES
1313
* These functions are stored in pg_amproc. For each operator class
@@ -32,6 +32,12 @@ hashint4(uint32 key)
3232
return ~key;
3333
}
3434

35+
uint32
36+
hashint8(uint64 *key)
37+
{
38+
return ~((uint32)key);
39+
}
40+
3541
/* Hash function from Chris Torek. */
3642
uint32
3743
hashfloat4(float32 keyp)

src/backend/access/nbtree/nbtcompare.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.21 1999/02/13 23:14:31 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.22 1999/03/14 05:08:56 momjian Exp $
1111
*
1212
* NOTES
1313
* These functions are stored in pg_amproc. For each operator class
@@ -39,6 +39,17 @@ btint4cmp(int32 a, int32 b)
3939
return a - b;
4040
}
4141

42+
int32
43+
btint8cmp(int64 *a, int64 *b)
44+
{
45+
if (*a > *b)
46+
return 1;
47+
else if (*a == *b)
48+
return 0;
49+
else
50+
return -1;
51+
}
52+
4253
int32
4354
btint24cmp(int16 a, int32 b)
4455
{

src/include/catalog/pg_amop.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_amop.h,v 1.19 1999/02/13 23:21:05 momjian Exp $
10+
* $Id: pg_amop.h,v 1.20 1999/03/14 05:08:57 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -167,6 +167,16 @@ DATA(insert OID = 0 ( 403 426 96 3 btreesel btreenpage ));
167167
DATA(insert OID = 0 ( 403 426 525 4 btreesel btreenpage ));
168168
DATA(insert OID = 0 ( 403 426 521 5 btreesel btreenpage ));
169169

170+
/*
171+
* nbtree int8_ops
172+
*/
173+
174+
DATA(insert OID = 0 ( 403 754 412 1 btreesel btreenpage ));
175+
DATA(insert OID = 0 ( 403 754 414 2 btreesel btreenpage ));
176+
DATA(insert OID = 0 ( 403 754 410 3 btreesel btreenpage ));
177+
DATA(insert OID = 0 ( 403 754 415 4 btreesel btreenpage ));
178+
DATA(insert OID = 0 ( 403 754 413 5 btreesel btreenpage ));
179+
170180
/*
171181
* nbtree oid_ops
172182
*/
@@ -338,6 +348,8 @@ DATA(insert OID = 0 ( 405 421 94 1 hashsel hashnpage ));
338348
DATA(insert OID = 0 ( 405 423 670 1 hashsel hashnpage ));
339349
/* int4_ops */
340350
DATA(insert OID = 0 ( 405 426 96 1 hashsel hashnpage ));
351+
/* int8_ops */
352+
DATA(insert OID = 0 ( 405 426 96 1 hashsel hashnpage ));
341353
/* oid_ops */
342354
DATA(insert OID = 0 ( 405 427 607 1 hashsel hashnpage ));
343355
/* oid8_ops */

src/include/catalog/pg_amproc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* Copyright (c) 1994, Regents of the University of California
1111
*
12-
* $Id: pg_amproc.h,v 1.12 1999/02/13 23:21:06 momjian Exp $
12+
* $Id: pg_amproc.h,v 1.13 1999/03/14 05:08:58 momjian Exp $
1313
*
1414
* NOTES
1515
* the genbki.sh script reads this file and generates .bki
@@ -92,6 +92,7 @@ DATA(insert OID = 0 (403 432 357 1));
9292
DATA(insert OID = 0 (403 435 404 1));
9393
DATA(insert OID = 0 (403 436 948 1));
9494
DATA(insert OID = 0 (403 437 828 1));
95+
DATA(insert OID = 0 (403 754 842 1));
9596
DATA(insert OID = 0 (403 1076 1078 1));
9697
DATA(insert OID = 0 (403 1077 1079 1));
9798
DATA(insert OID = 0 (403 1114 1092 1));

src/include/catalog/pg_opclass.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_opclass.h,v 1.16 1999/02/13 23:21:11 momjian Exp $
10+
* $Id: pg_opclass.h,v 1.17 1999/03/14 05:08:59 momjian Exp $
1111
*
1212
* NOTES
1313
* the genbki.sh script reads this file and generates .bki
@@ -93,6 +93,8 @@ DATA(insert OID = 435 ( oid8_ops 30 ));
9393
DESCR("");
9494
DATA(insert OID = 714 ( circle_ops 718 ));
9595
DESCR("");
96+
DATA(insert OID = 754 ( int8_ops 20 ));
97+
DESCR("");
9698
DATA(insert OID = 1076 ( bpchar_ops 1042 ));
9799
DESCR("");
98100
DATA(insert OID = 1077 ( varchar_ops 1043 ));

src/include/catalog/pg_proc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: pg_proc.h,v 1.90 1999/03/10 05:02:33 tgl Exp $
9+
* $Id: pg_proc.h,v 1.91 1999/03/14 05:09:00 momjian Exp $
1010
*
1111
* NOTES
1212
* The script catalog/genbki.sh reads this file and generates .bki
@@ -735,6 +735,8 @@ DATA(insert OID = 350 ( btint2cmp PGUID 11 f t f 2 f 23 "21 21" 100 0 0 100
735735
DESCR("btree less-equal-greater");
736736
DATA(insert OID = 351 ( btint4cmp PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100 foo bar ));
737737
DESCR("btree less-equal-greater");
738+
DATA(insert OID = 842 ( btint8cmp PGUID 11 f t f 2 f 23 "20 20" 100 0 0 100 foo bar ));
739+
DESCR("btree less-equal-greater");
738740
DATA(insert OID = 352 ( btint42cmp PGUID 11 f t f 2 f 23 "23 21" 100 0 0 100 foo bar ));
739741
DESCR("btree less-equal-greater");
740742
DATA(insert OID = 353 ( btint24cmp PGUID 11 f t f 2 f 23 "21 23" 100 0 0 100 foo bar ));
@@ -821,6 +823,8 @@ DATA(insert OID = 449 ( hashint2 PGUID 11 f t f 2 f 23 "21 21" 100 0 0 100
821823
DESCR("hash");
822824
DATA(insert OID = 450 ( hashint4 PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100 foo bar ));
823825
DESCR("hash");
826+
DATA(insert OID = 949 ( hashint8 PGUID 11 f t f 2 f 23 "20 20" 100 0 0 100 foo bar ));
827+
DESCR("hash");
824828
DATA(insert OID = 451 ( hashfloat4 PGUID 11 f t f 2 f 23 "700 700" 100 0 0 100 foo bar ));
825829
DESCR("hash");
826830
DATA(insert OID = 452 ( hashfloat8 PGUID 11 f t f 2 f 23 "701 701" 100 0 0 100 foo bar ));

src/include/utils/builtins.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: builtins.h,v 1.74 1999/02/13 23:22:15 momjian Exp $
9+
* $Id: builtins.h,v 1.75 1999/03/14 05:09:05 momjian Exp $
1010
*
1111
* NOTES
1212
* This should normally only be included by fmgr.h.
@@ -163,6 +163,7 @@ extern void ltoa(int32 l, char *a);
163163
*/
164164
extern int32 btint2cmp(int16 a, int16 b);
165165
extern int32 btint4cmp(int32 a, int32 b);
166+
extern int32 btint8cmp(int64 *a, int64 *b);
166167
extern int32 btint24cmp(int16 a, int32 b);
167168
extern int32 btint42cmp(int32 a, int16 b);
168169
extern int32 btfloat4cmp(float32 a, float32 b);

0 commit comments

Comments
 (0)