From 3d660d33aab2f1eb98367a84eb2addf3e0969c05 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 30 Jan 2015 12:30:38 -0500 Subject: Fix assorted oversights in range selectivity estimation. calc_rangesel() failed outright when comparing range variables to empty constant ranges with < or >=, as a result of missing cases in a switch. It also produced a bogus estimate for > comparison to an empty range. On top of that, the >= and > cases were mislabeled throughout. For nonempty constant ranges, they managed to produce the right answers anyway as a result of counterbalancing typos. Also, default_range_selectivity() omitted cases for elem <@ range, range &< range, and range &> range, so that rather dubious defaults were applied for these operators. In passing, rearrange the code in rangesel() so that the elem <@ range case is handled in a less opaque fashion. Report and patch by Emre Hasegeli, some additional work by me --- src/include/catalog/pg_operator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/include') diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index d8a25f841d2..af991d34f72 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -1723,10 +1723,10 @@ DESCR("less than or equal"); #define OID_RANGE_LESS_EQUAL_OP 3885 DATA(insert OID = 3886 ( ">=" PGNSP PGUID b f f 3831 3831 16 3885 3884 range_ge rangesel scalargtjoinsel )); DESCR("greater than or equal"); -#define OID_RANGE_GREATER_OP 3886 +#define OID_RANGE_GREATER_EQUAL_OP 3886 DATA(insert OID = 3887 ( ">" PGNSP PGUID b f f 3831 3831 16 3884 3885 range_gt rangesel scalargtjoinsel )); DESCR("greater than"); -#define OID_RANGE_GREATER_EQUAL_OP 3887 +#define OID_RANGE_GREATER_OP 3887 DATA(insert OID = 3888 ( "&&" PGNSP PGUID b f f 3831 3831 16 3888 0 range_overlaps rangesel areajoinsel )); DESCR("overlaps"); #define OID_RANGE_OVERLAP_OP 3888 -- cgit v1.2.3