Skip to content

Commit 4509033

Browse files
committed
Code review for range-types catalog entries.
Fix assorted infelicities, such as dependency on OIDs that aren't hardwired, as well as outright misdeclaration of daterange_canonical(), which resulted in crashes if you invoked it directly. Add some more regression tests to try to catch similar mistakes in future.
1 parent ff4fd4b commit 4509033

File tree

11 files changed

+179
-85
lines changed

11 files changed

+179
-85
lines changed

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 201111141
56+
#define CATALOG_VERSION_NO 201111161
5757

5858
#endif

src/include/catalog/indexing.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ DECLARE_UNIQUE_INDEX(pg_extension_oid_index, 3080, on pg_extension using btree(o
303303
DECLARE_UNIQUE_INDEX(pg_extension_name_index, 3081, on pg_extension using btree(extname name_ops));
304304
#define ExtensionNameIndexId 3081
305305

306-
DECLARE_UNIQUE_INDEX(pg_range_rgntypid_index, 3542, on pg_range using btree(rngtypid oid_ops));
306+
DECLARE_UNIQUE_INDEX(pg_range_rngtypid_index, 3542, on pg_range using btree(rngtypid oid_ops));
307307
#define RangeTypidIndexId 3542
308308

309309
/* last step of initialization script: build the indexes declared above */

src/include/catalog/pg_opclass.h

+15-8
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ typedef FormData_pg_opclass *Form_pg_opclass;
8585
* initial contents of pg_opclass
8686
*
8787
* Note: we hard-wire an OID only for a few entries that have to be explicitly
88-
* referenced in the C code for bootstrapping purposes. The rest get OIDs
88+
* referenced in the C code or in built-in catalog entries. The rest get OIDs
8989
* assigned on-the-fly during initdb.
9090
* ----------------
9191
*/
@@ -102,11 +102,13 @@ DATA(insert ( 403 char_ops PGNSP PGUID 429 18 t 0 ));
102102
DATA(insert ( 405 char_ops PGNSP PGUID 431 18 t 0 ));
103103
DATA(insert ( 403 cidr_ops PGNSP PGUID 1974 869 f 0 ));
104104
DATA(insert ( 405 cidr_ops PGNSP PGUID 1975 869 f 0 ));
105-
DATA(insert ( 403 date_ops PGNSP PGUID 434 1082 t 0 ));
105+
DATA(insert OID = 3122 ( 403 date_ops PGNSP PGUID 434 1082 t 0 ));
106+
#define DATE_BTREE_OPS_OID 3122
106107
DATA(insert ( 405 date_ops PGNSP PGUID 435 1082 t 0 ));
107108
DATA(insert ( 403 float4_ops PGNSP PGUID 1970 700 t 0 ));
108109
DATA(insert ( 405 float4_ops PGNSP PGUID 1971 700 t 0 ));
109-
DATA(insert ( 403 float8_ops PGNSP PGUID 1970 701 t 0 ));
110+
DATA(insert OID = 3123 ( 403 float8_ops PGNSP PGUID 1970 701 t 0 ));
111+
#define FLOAT8_BTREE_OPS_OID 3123
110112
DATA(insert ( 405 float8_ops PGNSP PGUID 1971 701 t 0 ));
111113
DATA(insert ( 403 inet_ops PGNSP PGUID 1974 869 t 0 ));
112114
DATA(insert ( 405 inet_ops PGNSP PGUID 1975 869 t 0 ));
@@ -116,7 +118,8 @@ DATA(insert ( 405 int2_ops PGNSP PGUID 1977 21 t 0 ));
116118
DATA(insert OID = 1978 ( 403 int4_ops PGNSP PGUID 1976 23 t 0 ));
117119
#define INT4_BTREE_OPS_OID 1978
118120
DATA(insert ( 405 int4_ops PGNSP PGUID 1977 23 t 0 ));
119-
DATA(insert ( 403 int8_ops PGNSP PGUID 1976 20 t 0 ));
121+
DATA(insert OID = 3124 ( 403 int8_ops PGNSP PGUID 1976 20 t 0 ));
122+
#define INT8_BTREE_OPS_OID 3124
120123
DATA(insert ( 405 int8_ops PGNSP PGUID 1977 20 t 0 ));
121124
DATA(insert ( 403 interval_ops PGNSP PGUID 1982 1186 t 0 ));
122125
DATA(insert ( 405 interval_ops PGNSP PGUID 1983 1186 t 0 ));
@@ -131,26 +134,30 @@ DATA(insert ( 405 macaddr_ops PGNSP PGUID 1985 829 t 0 ));
131134
*/
132135
DATA(insert ( 403 name_ops PGNSP PGUID 1986 19 t 2275 ));
133136
DATA(insert ( 405 name_ops PGNSP PGUID 1987 19 t 0 ));
134-
DATA(insert ( 403 numeric_ops PGNSP PGUID 1988 1700 t 0 ));
137+
DATA(insert OID = 3125 ( 403 numeric_ops PGNSP PGUID 1988 1700 t 0 ));
138+
#define NUMERIC_BTREE_OPS_OID 3125
135139
DATA(insert ( 405 numeric_ops PGNSP PGUID 1998 1700 t 0 ));
136140
DATA(insert OID = 1981 ( 403 oid_ops PGNSP PGUID 1989 26 t 0 ));
137141
#define OID_BTREE_OPS_OID 1981
138142
DATA(insert ( 405 oid_ops PGNSP PGUID 1990 26 t 0 ));
139143
DATA(insert ( 403 oidvector_ops PGNSP PGUID 1991 30 t 0 ));
140144
DATA(insert ( 405 oidvector_ops PGNSP PGUID 1992 30 t 0 ));
141145
DATA(insert ( 403 record_ops PGNSP PGUID 2994 2249 t 0 ));
142-
DATA(insert ( 403 text_ops PGNSP PGUID 1994 25 t 0 ));
146+
DATA(insert OID = 3126 ( 403 text_ops PGNSP PGUID 1994 25 t 0 ));
147+
#define TEXT_BTREE_OPS_OID 3126
143148
DATA(insert ( 405 text_ops PGNSP PGUID 1995 25 t 0 ));
144149
DATA(insert ( 403 time_ops PGNSP PGUID 1996 1083 t 0 ));
145150
DATA(insert ( 405 time_ops PGNSP PGUID 1997 1083 t 0 ));
146-
DATA(insert ( 403 timestamptz_ops PGNSP PGUID 434 1184 t 0 ));
151+
DATA(insert OID = 3127 ( 403 timestamptz_ops PGNSP PGUID 434 1184 t 0 ));
152+
#define TIMESTAMPTZ_BTREE_OPS_OID 3127
147153
DATA(insert ( 405 timestamptz_ops PGNSP PGUID 1999 1184 t 0 ));
148154
DATA(insert ( 403 timetz_ops PGNSP PGUID 2000 1266 t 0 ));
149155
DATA(insert ( 405 timetz_ops PGNSP PGUID 2001 1266 t 0 ));
150156
DATA(insert ( 403 varbit_ops PGNSP PGUID 2002 1562 t 0 ));
151157
DATA(insert ( 403 varchar_ops PGNSP PGUID 1994 25 f 0 ));
152158
DATA(insert ( 405 varchar_ops PGNSP PGUID 1995 25 f 0 ));
153-
DATA(insert ( 403 timestamp_ops PGNSP PGUID 434 1114 t 0 ));
159+
DATA(insert OID = 3128 ( 403 timestamp_ops PGNSP PGUID 434 1114 t 0 ));
160+
#define TIMESTAMP_BTREE_OPS_OID 3128
154161
DATA(insert ( 405 timestamp_ops PGNSP PGUID 2040 1114 t 0 ));
155162
DATA(insert ( 403 text_pattern_ops PGNSP PGUID 2095 25 f 0 ));
156163
DATA(insert ( 403 varchar_pattern_ops PGNSP PGUID 2095 25 f 0 ));

src/include/catalog/pg_operator.h

+20-19
Original file line numberDiff line numberDiff line change
@@ -1674,32 +1674,33 @@ DATA(insert OID = 3886 ( ">=" PGNSP PGUID b f f 3831 3831 16 3885 3884 range
16741674
DESCR("greater than or equal");
16751675
DATA(insert OID = 3887 ( ">" PGNSP PGUID b f f 3831 3831 16 3884 3885 range_gt scalargtsel scalargtjoinsel ));
16761676
DESCR("greater than");
1677-
DATA(insert OID = 3888 ( "&&" PGNSP PGUID b f f 3831 3831 16 3888 0 3857 - - ));
1677+
DATA(insert OID = 3888 ( "&&" PGNSP PGUID b f f 3831 3831 16 3888 0 range_overlaps - - ));
16781678
DESCR("overlaps");
1679-
DATA(insert OID = 3889 ( "@>" PGNSP PGUID b f f 3831 2776 16 3891 0 3858 - - ));
1679+
DATA(insert OID = 3889 ( "@>" PGNSP PGUID b f f 3831 2776 16 3891 0 range_contains_elem - - ));
16801680
DESCR("contains");
1681-
DATA(insert OID = 3890 ( "@>" PGNSP PGUID b f f 3831 3831 16 3892 0 3859 - - ));
1681+
DATA(insert OID = 3890 ( "@>" PGNSP PGUID b f f 3831 3831 16 3892 0 range_contains - - ));
16821682
DESCR("contains");
1683-
DATA(insert OID = 3891 ( "<@" PGNSP PGUID b f f 2776 3831 16 3889 0 3860 - - ));
1684-
DESCR("contained by");
1685-
DATA(insert OID = 3892 ( "<@" PGNSP PGUID b f f 3831 3831 16 3890 0 3861 - - ));
1686-
DESCR("contained by");
1687-
DATA(insert OID = 3893 ( "<<" PGNSP PGUID b f f 3831 3831 16 0 0 before scalarltsel scalarltjoinsel ));
1688-
DESCR("left of");
1689-
DATA(insert OID = 3894 ( ">>" PGNSP PGUID b f f 3831 3831 16 0 0 after scalargtsel scalargtjoinsel ));
1690-
DESCR("right of");
1691-
DATA(insert OID = 3895 ( "&<" PGNSP PGUID b f f 3831 3831 16 0 0 overleft scalarltsel scalarltjoinsel ));
1692-
DESCR("overlaps to left");
1693-
DATA(insert OID = 3896 ( "&>" PGNSP PGUID b f f 3831 3831 16 0 0 overright scalargtsel scalargtjoinsel ));
1694-
DESCR("overlaps to right");
1695-
DATA(insert OID = 3897 ( "-|-" PGNSP PGUID b f f 3831 3831 16 3897 0 adjacent - - ));
1696-
DESCR("adjacent");
1683+
DATA(insert OID = 3891 ( "<@" PGNSP PGUID b f f 2776 3831 16 3889 0 elem_contained_by_range - - ));
1684+
DESCR("is contained by");
1685+
DATA(insert OID = 3892 ( "<@" PGNSP PGUID b f f 3831 3831 16 3890 0 range_contained_by - - ));
1686+
DESCR("is contained by");
1687+
DATA(insert OID = 3893 ( "<<" PGNSP PGUID b f f 3831 3831 16 0 0 range_before scalarltsel scalarltjoinsel ));
1688+
DESCR("is left of");
1689+
DATA(insert OID = 3894 ( ">>" PGNSP PGUID b f f 3831 3831 16 0 0 range_after scalargtsel scalargtjoinsel ));
1690+
DESCR("is right of");
1691+
DATA(insert OID = 3895 ( "&<" PGNSP PGUID b f f 3831 3831 16 0 0 range_overleft scalarltsel scalarltjoinsel ));
1692+
DESCR("overlaps or is left of");
1693+
DATA(insert OID = 3896 ( "&>" PGNSP PGUID b f f 3831 3831 16 0 0 range_overright scalargtsel scalargtjoinsel ));
1694+
DESCR("overlaps or is right of");
1695+
DATA(insert OID = 3897 ( "-|-" PGNSP PGUID b f f 3831 3831 16 3897 0 range_adjacent - - ));
1696+
DESCR("is adjacent to");
16971697
DATA(insert OID = 3898 ( "+" PGNSP PGUID b f f 3831 3831 3831 3898 0 range_union - - ));
16981698
DESCR("range union");
1699-
DATA(insert OID = 3899 ( "-" PGNSP PGUID b f f 3831 3831 3831 0 0 minus - - ));
1699+
DATA(insert OID = 3899 ( "-" PGNSP PGUID b f f 3831 3831 3831 0 0 range_minus - - ));
17001700
DESCR("range difference");
17011701
DATA(insert OID = 3900 ( "*" PGNSP PGUID b f f 3831 3831 3831 3900 0 range_intersect - - ));
1702-
DESCR("intersection");
1702+
DESCR("range intersection");
1703+
17031704

17041705
/*
17051706
* function prototypes

0 commit comments

Comments
 (0)