LINE 1: SELECT count(*) FROM dbms_stats.stats WHERE false;
^
RESET SESSION AUTHORIZATION;
+/*
+ * No.19-2 regression for skipping empty simple_rel_array entry
+ */
+CREATE TABLE t1 (a int, b int);
+CREATE TABLE t2 (a int);
+CREATE INDEX t1_a10_idx on t1 ((a % 10));
+INSERT INTO t1 (SELECT a, a FROM generate_series(0, 9999) a);
+INSERT INTO t2 VALUES (1), (3), (7), (8);
+ANALYZE t1;
+SELECT dbms_stats.lock_table_stats('t1');
+ lock_table_stats
+------------------
+ t1
+(1 row)
+
+EXPLAIN (COSTS off)
+ SELECT * FROM t1 JOIN t2 on (t1.a % 10 = t2.a); -- Don't crash!
+ QUERY PLAN
+-----------------------------------------
+ Merge Join
+ Merge Cond: ((t1.a % 10) = t2.a)
+ -> Index Scan using t1_a10_idx on t1
+ -> Sort
+ Sort Key: t2.a
+ -> Seq Scan on t2
+(6 rows)
+
+DROP TABLE t1, t2;
+SELECT dbms_stats.clean_up_stats() ORDER BY 1;
+ clean_up_stats
+----------------
+ public.t1,
+ public.t1, 1
+ public.t1, 2
+(3 rows)
+
-- No.20 has been moved out to ut-xx.sql
/*
* No.21 anyarray stuff
for (i = 1 ; i < root->simple_rel_array_size ; i++)
{
ListCell *lc;
+ RelOptInfo *rel = root->simple_rel_array[i];
- foreach (lc, root->simple_rel_array[i]->indexlist)
+ /* there may be empty slots corresponding to non-baserel RTEs */
+ if (rel == NULL)
+ continue;
+
+ foreach (lc, rel->indexlist)
{
IndexOptInfo *index = (IndexOptInfo *) lfirst(lc);
RangeTblEntry *rte;
SELECT count(*) FROM dbms_stats.stats WHERE false;
RESET SESSION AUTHORIZATION;
+/*
+ * No.19-2 regression for skipping empty simple_rel_array entry
+ */
+CREATE TABLE t1 (a int, b int);
+CREATE TABLE t2 (a int);
+CREATE INDEX t1_a10_idx on t1 ((a % 10));
+INSERT INTO t1 (SELECT a, a FROM generate_series(0, 9999) a);
+INSERT INTO t2 VALUES (1), (3), (7), (8);
+ANALYZE t1;
+SELECT dbms_stats.lock_table_stats('t1');
+EXPLAIN (COSTS off)
+ SELECT * FROM t1 JOIN t2 on (t1.a % 10 = t2.a); -- Don't crash!
+DROP TABLE t1, t2;
+SELECT dbms_stats.clean_up_stats() ORDER BY 1;
+
-- No.20 has been moved out to ut-xx.sql
/*