From 817a3e6d394227f715e55ec7e71ee737e9bdb9aa Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sun, 14 Mar 1999 05:09:05 +0000 Subject: [PATCH] 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 --- src/backend/access/hash/hashfunc.c | 8 +++++++- src/backend/access/nbtree/nbtcompare.c | 13 ++++++++++++- src/include/catalog/pg_amop.h | 14 +++++++++++++- src/include/catalog/pg_amproc.h | 3 ++- src/include/catalog/pg_opclass.h | 4 +++- src/include/catalog/pg_proc.h | 6 +++++- src/include/utils/builtins.h | 3 ++- 7 files changed, 44 insertions(+), 7 deletions(-) diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index 7233685a22..a4eba181a7 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.13 1999/02/13 23:14:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.14 1999/03/14 05:08:55 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -32,6 +32,12 @@ hashint4(uint32 key) return ~key; } +uint32 +hashint8(uint64 *key) +{ + return ~((uint32)key); +} + /* Hash function from Chris Torek. */ uint32 hashfloat4(float32 keyp) diff --git a/src/backend/access/nbtree/nbtcompare.c b/src/backend/access/nbtree/nbtcompare.c index 108166fc44..127f2b0357 100644 --- a/src/backend/access/nbtree/nbtcompare.c +++ b/src/backend/access/nbtree/nbtcompare.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.21 1999/02/13 23:14:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.22 1999/03/14 05:08:56 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -39,6 +39,17 @@ btint4cmp(int32 a, int32 b) return a - b; } +int32 +btint8cmp(int64 *a, int64 *b) +{ + if (*a > *b) + return 1; + else if (*a == *b) + return 0; + else + return -1; +} + int32 btint24cmp(int16 a, int32 b) { diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h index 3491a44db0..b9860030bb 100644 --- a/src/include/catalog/pg_amop.h +++ b/src/include/catalog/pg_amop.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amop.h,v 1.19 1999/02/13 23:21:05 momjian Exp $ + * $Id: pg_amop.h,v 1.20 1999/03/14 05:08:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -167,6 +167,16 @@ DATA(insert OID = 0 ( 403 426 96 3 btreesel btreenpage )); DATA(insert OID = 0 ( 403 426 525 4 btreesel btreenpage )); DATA(insert OID = 0 ( 403 426 521 5 btreesel btreenpage )); +/* + * nbtree int8_ops + */ + +DATA(insert OID = 0 ( 403 754 412 1 btreesel btreenpage )); +DATA(insert OID = 0 ( 403 754 414 2 btreesel btreenpage )); +DATA(insert OID = 0 ( 403 754 410 3 btreesel btreenpage )); +DATA(insert OID = 0 ( 403 754 415 4 btreesel btreenpage )); +DATA(insert OID = 0 ( 403 754 413 5 btreesel btreenpage )); + /* * nbtree oid_ops */ @@ -338,6 +348,8 @@ DATA(insert OID = 0 ( 405 421 94 1 hashsel hashnpage )); DATA(insert OID = 0 ( 405 423 670 1 hashsel hashnpage )); /* int4_ops */ DATA(insert OID = 0 ( 405 426 96 1 hashsel hashnpage )); +/* int8_ops */ +DATA(insert OID = 0 ( 405 426 96 1 hashsel hashnpage )); /* oid_ops */ DATA(insert OID = 0 ( 405 427 607 1 hashsel hashnpage )); /* oid8_ops */ diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h index 47395fdbdb..6e7cb589f6 100644 --- a/src/include/catalog/pg_amproc.h +++ b/src/include/catalog/pg_amproc.h @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amproc.h,v 1.12 1999/02/13 23:21:06 momjian Exp $ + * $Id: pg_amproc.h,v 1.13 1999/03/14 05:08:58 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -92,6 +92,7 @@ DATA(insert OID = 0 (403 432 357 1)); DATA(insert OID = 0 (403 435 404 1)); DATA(insert OID = 0 (403 436 948 1)); DATA(insert OID = 0 (403 437 828 1)); +DATA(insert OID = 0 (403 754 842 1)); DATA(insert OID = 0 (403 1076 1078 1)); DATA(insert OID = 0 (403 1077 1079 1)); DATA(insert OID = 0 (403 1114 1092 1)); diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h index 5ced96a404..7b66fe284a 100644 --- a/src/include/catalog/pg_opclass.h +++ b/src/include/catalog/pg_opclass.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_opclass.h,v 1.16 1999/02/13 23:21:11 momjian Exp $ + * $Id: pg_opclass.h,v 1.17 1999/03/14 05:08:59 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -93,6 +93,8 @@ DATA(insert OID = 435 ( oid8_ops 30 )); DESCR(""); DATA(insert OID = 714 ( circle_ops 718 )); DESCR(""); +DATA(insert OID = 754 ( int8_ops 20 )); +DESCR(""); DATA(insert OID = 1076 ( bpchar_ops 1042 )); DESCR(""); DATA(insert OID = 1077 ( varchar_ops 1043 )); diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index a71f1ef526..c0225a83c2 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.90 1999/03/10 05:02:33 tgl Exp $ + * $Id: pg_proc.h,v 1.91 1999/03/14 05:09:00 momjian Exp $ * * NOTES * 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 DESCR("btree less-equal-greater"); DATA(insert OID = 351 ( btint4cmp PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100 foo bar )); DESCR("btree less-equal-greater"); +DATA(insert OID = 842 ( btint8cmp PGUID 11 f t f 2 f 23 "20 20" 100 0 0 100 foo bar )); +DESCR("btree less-equal-greater"); DATA(insert OID = 352 ( btint42cmp PGUID 11 f t f 2 f 23 "23 21" 100 0 0 100 foo bar )); DESCR("btree less-equal-greater"); 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 DESCR("hash"); DATA(insert OID = 450 ( hashint4 PGUID 11 f t f 2 f 23 "23 23" 100 0 0 100 foo bar )); DESCR("hash"); +DATA(insert OID = 949 ( hashint8 PGUID 11 f t f 2 f 23 "20 20" 100 0 0 100 foo bar )); +DESCR("hash"); DATA(insert OID = 451 ( hashfloat4 PGUID 11 f t f 2 f 23 "700 700" 100 0 0 100 foo bar )); DESCR("hash"); DATA(insert OID = 452 ( hashfloat8 PGUID 11 f t f 2 f 23 "701 701" 100 0 0 100 foo bar )); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 896729573b..f947dff613 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.74 1999/02/13 23:22:15 momjian Exp $ + * $Id: builtins.h,v 1.75 1999/03/14 05:09:05 momjian Exp $ * * NOTES * This should normally only be included by fmgr.h. @@ -163,6 +163,7 @@ extern void ltoa(int32 l, char *a); */ extern int32 btint2cmp(int16 a, int16 b); extern int32 btint4cmp(int32 a, int32 b); +extern int32 btint8cmp(int64 *a, int64 *b); extern int32 btint24cmp(int16 a, int32 b); extern int32 btint42cmp(int32 a, int16 b); extern int32 btfloat4cmp(float32 a, float32 b); -- 2.40.0