Skip to content

Commit 26df706

Browse files
committed
Move strategy numbers to include/access/stratnum.h
For upcoming BRIN opclasses, it's convenient to have strategy numbers defined in a single place. Since there's nothing appropriate, create it. The StrategyNumber typedef now lives there, as well as existing strategy numbers for B-trees (from skey.h) and R-tree-and-friends (from gist.h). skey.h is forced to include stratnum.h because of the StrategyNumber typedef, but gist.h is not; extensions that currently rely on gist.h for rtree strategy numbers might need to add a new A few .c files can stop including skey.h and/or gist.h, which is a nice side benefit. Per discussion: https://www.postgresql.org/message-id/20150514232132.GZ2523@alvh.no-ip.org Authored by Emre Hasegeli and Álvaro. (It's not clear to me why bootscanner.l has any #include lines at all.)
1 parent 1e98fa0 commit 26df706

35 files changed

+129
-95
lines changed

contrib/btree_gin/btree_gin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <limits.h>
77

8-
#include "access/skey.h"
8+
#include "access/stratnum.h"
99
#include "utils/builtins.h"
1010
#include "utils/bytea.h"
1111
#include "utils/cash.h"

contrib/cube/cube.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <math.h>
1313

1414
#include "access/gist.h"
15-
#include "access/skey.h"
15+
#include "access/stratnum.h"
1616
#include "utils/array.h"
1717
#include "utils/builtins.h"
1818

contrib/hstore/hstore_gin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "postgres.h"
55

66
#include "access/gin.h"
7-
#include "access/skey.h"
7+
#include "access/stratnum.h"
88
#include "catalog/pg_type.h"
99

1010
#include "hstore.h"

contrib/hstore/hstore_gist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "postgres.h"
55

66
#include "access/gist.h"
7-
#include "access/skey.h"
7+
#include "access/stratnum.h"
88
#include "catalog/pg_type.h"
99
#include "utils/pg_crc.h"
1010

contrib/intarray/_int_gin.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
#include "postgres.h"
55

66
#include "access/gin.h"
7-
#include "access/gist.h"
8-
#include "access/skey.h"
7+
#include "access/stratnum.h"
98

109
#include "_int.h"
1110

contrib/intarray/_int_gist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <limits.h>
77

88
#include "access/gist.h"
9-
#include "access/skey.h"
9+
#include "access/stratnum.h"
1010

1111
#include "_int.h"
1212

contrib/intarray/_intbig_gist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "postgres.h"
55

66
#include "access/gist.h"
7-
#include "access/skey.h"
7+
#include "access/stratnum.h"
88

99
#include "_int.h"
1010

contrib/ltree/_ltree_gist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "postgres.h"
99

1010
#include "access/gist.h"
11-
#include "access/skey.h"
11+
#include "access/stratnum.h"
1212
#include "crc32.h"
1313
#include "ltree.h"
1414

contrib/ltree/ltree_gist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "postgres.h"
77

88
#include "access/gist.h"
9-
#include "access/skey.h"
9+
#include "access/stratnum.h"
1010
#include "crc32.h"
1111
#include "ltree.h"
1212

contrib/pg_trgm/trgm_gin.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include "trgm.h"
77

88
#include "access/gin.h"
9-
#include "access/skey.h"
9+
#include "access/stratnum.h"
10+
#include "fmgr.h"
1011

1112

1213
PG_FUNCTION_INFO_V1(gin_extract_trgm);

contrib/pg_trgm/trgm_gist.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
#include "trgm.h"
77

8-
#include "access/skey.h"
8+
#include "access/stratnum.h"
9+
#include "fmgr.h"
910

1011

1112
typedef struct

contrib/seg/seg.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
#include <float.h>
1313

1414
#include "access/gist.h"
15-
#include "access/skey.h"
15+
#include "access/stratnum.h"
16+
#include "fmgr.h"
1617

1718
#include "segdata.h"
1819

src/backend/access/brin/brin_minmax.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "access/genam.h"
1414
#include "access/brin_internal.h"
1515
#include "access/brin_tuple.h"
16-
#include "access/skey.h"
16+
#include "access/stratnum.h"
1717
#include "catalog/pg_type.h"
1818
#include "catalog/pg_amop.h"
1919
#include "utils/datum.h"

src/backend/access/gin/ginarrayproc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "postgres.h"
1515

1616
#include "access/gin.h"
17-
#include "access/skey.h"
17+
#include "access/stratnum.h"
1818
#include "utils/array.h"
1919
#include "utils/builtins.h"
2020
#include "utils/lsyscache.h"

src/backend/access/gist/gistproc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "postgres.h"
1919

2020
#include "access/gist.h"
21-
#include "access/skey.h"
21+
#include "access/stratnum.h"
2222
#include "utils/geo_decls.h"
2323

2424

src/backend/access/spgist/spgkdtreeproc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
#include "postgres.h"
1717

18-
#include "access/gist.h" /* for RTree strategy numbers */
1918
#include "access/spgist.h"
19+
#include "access/stratnum.h"
2020
#include "catalog/pg_type.h"
2121
#include "utils/builtins.h"
2222
#include "utils/geo_decls.h"

src/backend/access/spgist/spgquadtreeproc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
#include "postgres.h"
1717

18-
#include "access/gist.h" /* for RTree strategy numbers */
1918
#include "access/spgist.h"
19+
#include "access/stratnum.h"
2020
#include "catalog/pg_type.h"
2121
#include "utils/builtins.h"
2222
#include "utils/geo_decls.h"

src/backend/bootstrap/bootparse.y

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "access/attnum.h"
2222
#include "access/htup.h"
2323
#include "access/itup.h"
24-
#include "access/skey.h"
2524
#include "access/tupdesc.h"
2625
#include "access/xact.h"
2726
#include "bootstrap/bootstrap.h"

src/backend/bootstrap/bootscanner.l

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "access/attnum.h"
1919
#include "access/htup.h"
2020
#include "access/itup.h"
21-
#include "access/skey.h"
2221
#include "access/tupdesc.h"
2322
#include "bootstrap/bootstrap.h"
2423
#include "catalog/pg_am.h"

src/backend/optimizer/path/equivclass.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
#include "postgres.h"
1818

19-
#include "access/skey.h"
19+
#include "access/stratnum.h"
2020
#include "catalog/pg_type.h"
2121
#include "nodes/makefuncs.h"
2222
#include "nodes/nodeFuncs.h"

src/backend/optimizer/path/indxpath.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <math.h>
1919

20-
#include "access/skey.h"
20+
#include "access/stratnum.h"
2121
#include "access/sysattr.h"
2222
#include "catalog/pg_am.h"
2323
#include "catalog/pg_collation.h"

src/backend/optimizer/path/pathkeys.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
#include "postgres.h"
1919

20-
#include "access/skey.h"
20+
#include "access/stratnum.h"
2121
#include "nodes/makefuncs.h"
2222
#include "nodes/nodeFuncs.h"
2323
#include "nodes/plannodes.h"

src/backend/optimizer/plan/createplan.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <limits.h>
2020
#include <math.h>
2121

22-
#include "access/skey.h"
22+
#include "access/stratnum.h"
2323
#include "access/sysattr.h"
2424
#include "catalog/pg_class.h"
2525
#include "catalog/pg_operator.h"

src/backend/optimizer/util/predtest.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1248,7 +1248,7 @@ list_member_strip(List *list, Expr *datum)
12481248
* Define "operator implication tables" for btree operators ("strategies"),
12491249
* and similar tables for refutation.
12501250
*
1251-
* The strategy numbers defined by btree indexes (see access/skey.h) are:
1251+
* The strategy numbers defined by btree indexes (see access/stratnum.h) are:
12521252
* 1 < 2 <= 3 = 4 >= 5 >
12531253
* and in addition we use 6 to represent <>. <> is not a btree-indexable
12541254
* operator, but we assume here that if an equality operator of a btree

src/backend/utils/adt/jsonb_gin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include "access/gin.h"
1717
#include "access/hash.h"
18-
#include "access/skey.h"
18+
#include "access/stratnum.h"
1919
#include "catalog/pg_collation.h"
2020
#include "catalog/pg_type.h"
2121
#include "utils/builtins.h"

src/backend/utils/adt/network_gist.c

+12-12
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,23 @@
4848
#include <sys/socket.h>
4949

5050
#include "access/gist.h"
51-
#include "access/skey.h"
51+
#include "access/stratnum.h"
5252
#include "utils/inet.h"
5353

5454
/*
5555
* Operator strategy numbers used in the GiST inet_ops opclass
5656
*/
57-
#define INETSTRAT_OVERLAPS 3
58-
#define INETSTRAT_EQ 18
59-
#define INETSTRAT_NE 19
60-
#define INETSTRAT_LT 20
61-
#define INETSTRAT_LE 21
62-
#define INETSTRAT_GT 22
63-
#define INETSTRAT_GE 23
64-
#define INETSTRAT_SUB 24
65-
#define INETSTRAT_SUBEQ 25
66-
#define INETSTRAT_SUP 26
67-
#define INETSTRAT_SUPEQ 27
57+
#define INETSTRAT_OVERLAPS RTOverlapStrategyNumber
58+
#define INETSTRAT_EQ RTEqualStrategyNumber
59+
#define INETSTRAT_NE RTNotEqualStrategyNumber
60+
#define INETSTRAT_LT RTLessStrategyNumber
61+
#define INETSTRAT_LE RTLessEqualStrategyNumber
62+
#define INETSTRAT_GT RTGreaterStrategyNumber
63+
#define INETSTRAT_GE RTGreaterEqualStrategyNumber
64+
#define INETSTRAT_SUB RTSubStrategyNumber
65+
#define INETSTRAT_SUBEQ RTSubOrEqualStrategyNumber
66+
#define INETSTRAT_SUP RTSuperStrategyNumber
67+
#define INETSTRAT_SUPEQ RTSuperOrEqualStrategyNumber
6868

6969

7070
/*

src/backend/utils/adt/rangetypes_gist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "postgres.h"
1616

1717
#include "access/gist.h"
18-
#include "access/skey.h"
18+
#include "access/stratnum.h"
1919
#include "utils/builtins.h"
2020
#include "utils/datum.h"
2121
#include "utils/rangetypes.h"

src/backend/utils/adt/rangetypes_spgist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include "postgres.h"
3838

3939
#include "access/spgist.h"
40-
#include "access/skey.h"
40+
#include "access/stratnum.h"
4141
#include "catalog/pg_type.h"
4242
#include "utils/builtins.h"
4343
#include "utils/datum.h"

src/backend/utils/adt/tsginidx.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "postgres.h"
1515

1616
#include "access/gin.h"
17-
#include "access/skey.h"
17+
#include "access/stratnum.h"
1818
#include "miscadmin.h"
1919
#include "tsearch/ts_type.h"
2020
#include "tsearch/ts_utils.h"

src/backend/utils/adt/tsquery_gist.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include "postgres.h"
1616

17-
#include "access/skey.h"
17+
#include "access/stratnum.h"
1818
#include "access/gist.h"
1919
#include "tsearch/ts_utils.h"
2020

src/include/access/gist.h

-20
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,6 @@
3636
#define GIST_FETCH_PROC 9
3737
#define GISTNProcs 9
3838

39-
/*
40-
* strategy numbers for GiST opclasses that want to implement the old
41-
* RTREE behavior.
42-
*/
43-
#define RTLeftStrategyNumber 1
44-
#define RTOverLeftStrategyNumber 2
45-
#define RTOverlapStrategyNumber 3
46-
#define RTOverRightStrategyNumber 4
47-
#define RTRightStrategyNumber 5
48-
#define RTSameStrategyNumber 6
49-
#define RTContainsStrategyNumber 7 /* for @> */
50-
#define RTContainedByStrategyNumber 8 /* for <@ */
51-
#define RTOverBelowStrategyNumber 9
52-
#define RTBelowStrategyNumber 10
53-
#define RTAboveStrategyNumber 11
54-
#define RTOverAboveStrategyNumber 12
55-
#define RTOldContainsStrategyNumber 13 /* for old spelling of @> */
56-
#define RTOldContainedByStrategyNumber 14 /* for old spelling of <@ */
57-
#define RTKNNSearchStrategyNumber 15
58-
5939
/*
6040
* Page opaque data in a GiST index page.
6141
*/

src/include/access/nbtree.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ typedef struct xl_btree_newroot
430430

431431

432432
/*
433-
* Operator strategy numbers for B-tree have been moved to access/skey.h,
433+
* Operator strategy numbers for B-tree have been moved to access/stratnum.h,
434434
* because many places need to use them in ScanKeyInit() calls.
435435
*
436436
* The strategy numbers are chosen so that we can commute them by

src/include/access/skey.h

+1-22
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,10 @@
1515
#define SKEY_H
1616

1717
#include "access/attnum.h"
18+
#include "access/stratnum.h"
1819
#include "fmgr.h"
1920

2021

21-
/*
22-
* Strategy numbers identify the semantics that particular operators have
23-
* with respect to particular operator classes. In some cases a strategy
24-
* subtype (an OID) is used as further information.
25-
*/
26-
typedef uint16 StrategyNumber;
27-
28-
#define InvalidStrategy ((StrategyNumber) 0)
29-
30-
/*
31-
* We define the strategy numbers for B-tree indexes here, to avoid having
32-
* to import access/nbtree.h into a lot of places that shouldn't need it.
33-
*/
34-
#define BTLessStrategyNumber 1
35-
#define BTLessEqualStrategyNumber 2
36-
#define BTEqualStrategyNumber 3
37-
#define BTGreaterEqualStrategyNumber 4
38-
#define BTGreaterStrategyNumber 5
39-
40-
#define BTMaxStrategyNumber 5
41-
42-
4322
/*
4423
* A ScanKey represents the application of a comparison operator between
4524
* a table or index column and a constant. When it's part of an array of

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