Skip to content

Commit 7528fd2

Browse files
committed
Add btree indexing of boolean values
Don Baccus
1 parent ede72c2 commit 7528fd2

File tree

8 files changed

+53
-10
lines changed

8 files changed

+53
-10
lines changed

src/backend/access/nbtree/nbtcompare.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.32 2000/01/28 17:23:47 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.33 2000/02/10 19:51:38 momjian Exp $
1212
*
1313
* NOTES
1414
* These functions are stored in pg_amproc. For each operator class
@@ -207,3 +207,9 @@ bttextcmp(struct varlena * a, struct varlena * b)
207207
else
208208
return 1;
209209
}
210+
211+
int32
212+
btboolcmp(bool a, bool b)
213+
{
214+
return (int32) ((uint8) a - (uint8) b);
215+
}

src/backend/utils/adt/bool.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.21 2000/01/26 05:57:13 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.22 2000/02/10 19:51:39 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -119,6 +119,18 @@ boolgt(bool arg1, bool arg2)
119119
return arg1 > arg2;
120120
}
121121

122+
bool
123+
boolle(bool arg1, bool arg2)
124+
{
125+
return arg1 <= arg2;
126+
}
127+
128+
bool
129+
boolge(bool arg1, bool arg2)
130+
{
131+
return arg1 >= arg2;
132+
}
133+
122134
bool
123135
istrue(bool arg1)
124136
{

src/include/catalog/pg_amop.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_amop.h,v 1.29 2000/01/26 05:57:56 momjian Exp $
11+
* $Id: pg_amop.h,v 1.30 2000/02/10 19:51:42 momjian Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -344,6 +344,16 @@ DATA(insert OID = 0 ( 403 1768 1752 3 ));
344344
DATA(insert OID = 0 ( 403 1768 1757 4 ));
345345
DATA(insert OID = 0 ( 403 1768 1756 5 ));
346346

347+
/*
348+
* nbtree bool
349+
*/
350+
351+
DATA(insert OID = 0 ( 403 1690 58 1 ));
352+
DATA(insert OID = 0 ( 403 1690 1694 2 ));
353+
DATA(insert OID = 0 ( 403 1690 91 3 ));
354+
DATA(insert OID = 0 ( 403 1690 1695 4 ));
355+
DATA(insert OID = 0 ( 403 1690 59 5 ));
356+
347357
/*
348358
* hash table _ops
349359
*/

src/include/catalog/pg_amproc.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
13-
* $Id: pg_amproc.h,v 1.19 2000/01/26 05:57:56 momjian Exp $
13+
* $Id: pg_amproc.h,v 1.20 2000/02/10 19:51:45 momjian Exp $
1414
*
1515
* NOTES
1616
* the genbki.sh script reads this file and generates .bki
@@ -99,6 +99,7 @@ DATA(insert OID = 0 (403 810 836 1));
9999
DATA(insert OID = 0 (403 935 926 1));
100100
DATA(insert OID = 0 (403 652 926 1));
101101
DATA(insert OID = 0 (403 1768 1769 1));
102+
DATA(insert OID = 0 (403 1690 1693 1));
102103

103104

104105
/* hash */

src/include/catalog/pg_opclass.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_opclass.h,v 1.27 2000/01/26 05:57:57 momjian Exp $
11+
* $Id: pg_opclass.h,v 1.28 2000/02/10 19:51:45 momjian Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -118,5 +118,7 @@ DATA(insert OID = 652 ( cidr_ops 650 ));
118118
DESCR("");
119119
DATA(insert OID = 1768 ( numeric_ops 1700 ));
120120
DESCR("");
121+
DATA(insert OID = 1690 ( bool_ops 16 ));
122+
DESCR("");
121123

122124
#endif /* PG_OPCLASS_H */

src/include/catalog/pg_operator.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
99
* Portions Copyright (c) 1994, Regents of the University of California
1010
*
11-
* $Id: pg_operator.h,v 1.66 2000/01/26 05:57:58 momjian Exp $
11+
* $Id: pg_operator.h,v 1.67 2000/02/10 19:51:45 momjian Exp $
1212
*
1313
* NOTES
1414
* the genbki.sh script reads this file and generates .bki
@@ -96,11 +96,13 @@ DATA(insert OID = 76 ( ">" PGUID 0 b t f 23 20 16 418 80 0 0 int48g
9696
DATA(insert OID = 80 ( "<=" PGUID 0 b t f 23 20 16 430 76 0 0 int48le scalarltsel scalarltjoinsel ));
9797
DATA(insert OID = 82 ( ">=" PGUID 0 b t f 23 20 16 420 37 0 0 int48ge scalargtsel scalargtjoinsel ));
9898

99-
DATA(insert OID = 58 ( "<" PGUID 0 b t f 16 16 16 59 0 0 0 boollt scalarltsel scalarltjoinsel ));
100-
DATA(insert OID = 59 ( ">" PGUID 0 b t f 16 16 16 58 0 0 0 boolgt scalargtsel scalargtjoinsel ));
99+
DATA(insert OID = 58 ( "<" PGUID 0 b t f 16 16 16 59 1695 0 0 boollt scalarltsel scalarltjoinsel ));
100+
DATA(insert OID = 59 ( ">" PGUID 0 b t f 16 16 16 58 1694 0 0 boolgt scalargtsel scalargtjoinsel ));
101101
DATA(insert OID = 85 ( "<>" PGUID 0 b t f 16 16 16 85 91 0 0 boolne neqsel neqjoinsel ));
102102
DATA(insert OID = 91 ( "=" PGUID 0 b t t 16 16 16 91 85 58 58 booleq eqsel eqjoinsel ));
103103
#define BooleanEqualOperator 91
104+
DATA(insert OID = 1694 ( "<=" PGUID 0 b t f 16 16 16 1695 59 0 0 boolle scalarltsel scalarltjoinsel ));
105+
DATA(insert OID = 1695 ( ">=" PGUID 0 b t f 16 16 16 1694 58 0 0 boolge scalargtsel scalargtjoinsel ));
104106

105107
DATA(insert OID = 92 ( "=" PGUID 0 b t t 18 18 16 92 630 631 631 chareq eqsel eqjoinsel ));
106108
DATA(insert OID = 93 ( "=" PGUID 0 b t t 19 19 16 93 643 660 660 nameeq eqsel eqjoinsel ));

src/include/catalog/pg_proc.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: pg_proc.h,v 1.119 2000/01/31 14:02:27 wieck Exp $
10+
* $Id: pg_proc.h,v 1.120 2000/02/10 19:51:46 momjian Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -2230,6 +2230,13 @@ DESCR("host address");
22302230
DATA(insert OID = 683 ( network PGUID 11 f t t 1 f 25 "869" 100 0 0 100 network_network - ));
22312231
DESCR("network address");
22322232

2233+
DATA(insert OID = 1691 ( boolle PGUID 11 f t t 2 f 16 "16 16" 100 0 0 100 boolle - ));
2234+
DESCR("less-than-or-equal");
2235+
DATA(insert OID = 1692 ( boolge PGUID 11 f t t 2 f 16 "16 16" 100 0 0 100 boolge - ));
2236+
DESCR("greater-than-or-equal");
2237+
DATA(insert OID = 1693 ( btboolcmp PGUID 11 f t t 2 f 23 "16 16" 100 0 0 100 btboolcmp - ));
2238+
DESCR("btree less-equal-greater");
2239+
22332240
/* OID's 1700 - 1799 NUMERIC data type */
22342241
DATA(insert OID = 1701 ( numeric_in PGUID 11 f t t 3 f 1700 "0 0 23" 100 0 0 100 numeric_in - ));
22352242
DESCR("(internal)");

src/include/utils/builtins.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: builtins.h,v 1.99 2000/01/26 05:58:37 momjian Exp $
10+
* $Id: builtins.h,v 1.100 2000/02/10 19:51:52 momjian Exp $
1111
*
1212
* NOTES
1313
* This should normally only be included by fmgr.h.
@@ -44,6 +44,8 @@ extern bool booleq(bool arg1, bool arg2);
4444
extern bool boolne(bool arg1, bool arg2);
4545
extern bool boollt(bool arg1, bool arg2);
4646
extern bool boolgt(bool arg1, bool arg2);
47+
extern bool boolle(bool arg1, bool arg2);
48+
extern bool boolge(bool arg1, bool arg2);
4749
extern bool istrue(bool arg1);
4850
extern bool isfalse(bool arg1);
4951

@@ -181,6 +183,7 @@ extern int32 btabstimecmp(AbsoluteTime a, AbsoluteTime b);
181183
extern int32 btcharcmp(char a, char b);
182184
extern int32 btnamecmp(NameData *a, NameData *b);
183185
extern int32 bttextcmp(struct varlena * a, struct varlena * b);
186+
extern int32 btboolcmp(bool a, bool b);
184187

185188
/* support routines for the rtree access method, by opclass */
186189
extern BOX *rt_box_union(BOX *a, BOX *b);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy