OSDN Git Service

Support PostgreSQL 13.
[pghintplan/pg_hint_plan.git] / expected / pg_hint_plan.out
index 40eadec..dbcee84 100644 (file)
@@ -1,4 +1,6 @@
 SET search_path TO public;
+SET client_min_messages TO log;
+\set SHOW_CONTEXT always
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
               QUERY PLAN              
 --------------------------------------
@@ -9,18 +11,17 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
 (4 rows)
 
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val;
-                QUERY PLAN                 
--------------------------------------------
Merge Join
-   Merge Cond: (t2.val = t1.val)
-   ->  Index Scan using t2_val on t2
-   ->  Materialize
-         ->  Index Scan using t1_val on t1
+           QUERY PLAN           
+--------------------------------
Hash Join
+   Hash Cond: (t2.val = t1.val)
+   ->  Seq Scan on t2
+   ->  Hash
+         ->  Seq Scan on t1
 (5 rows)
 
 LOAD 'pg_hint_plan';
 SET pg_hint_plan.debug_print TO on;
-SET client_min_messages TO LOG;
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
               QUERY PLAN              
 --------------------------------------
@@ -31,18 +32,18 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
 (4 rows)
 
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val;
-                QUERY PLAN                 
--------------------------------------------
Merge Join
-   Merge Cond: (t2.val = t1.val)
-   ->  Index Scan using t2_val on t2
-   ->  Materialize
-         ->  Index Scan using t1_val on t1
+           QUERY PLAN           
+--------------------------------
Hash Join
+   Hash Cond: (t2.val = t1.val)
+   ->  Seq Scan on t2
+   ->  Hash
+         ->  Seq Scan on t1
 (5 rows)
 
 /*+ Test (t1 t2) */
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
-INFO:  hint syntax error at or near "Test (t1 t2) "
+INFO:  pg_hint_plan: hint syntax error at or near "Test (t1 t2) "
 DETAIL:  Unrecognized hint keyword "Test".
               QUERY PLAN              
 --------------------------------------
@@ -86,7 +87,7 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
 
 /*+Set(enable_indexscan off) /* nest comment */ */
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
-INFO:  hint syntax error at or near "/* nest comment */ */
+INFO:  pg_hint_plan: hint syntax error at or near "/* nest comment */ */
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;"
 DETAIL:  Nested block comments are not supported.
               QUERY PLAN              
@@ -211,20 +212,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                QUERY PLAN                
-------------------------------------------
- Nested Loop
-   ->  Index Scan using t2_pkey on t2
-   ->  Bitmap Heap Scan on t1
-         Recheck Cond: (id = t2.id)
-         ->  Bitmap Index Scan on t1_pkey
-               Index Cond: (id = t2.id)
-(6 rows)
+                 QUERY PLAN                 
+--------------------------------------------
+ Hash Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1
+   ->  Hash
+         ->  Index Scan using t2_pkey on t2
+(5 rows)
 
 /*+Set(work_mem "1M")*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
 INFO:  invalid value for parameter "work_mem": "1M"
-HINT:  Valid units for this parameter are "kB", "MB", and "GB".
+HINT:  Valid units for this parameter are "B", "kB", "MB", "GB", and "TB".
 LOG:  pg_hint_plan:
 used hint:
 not used hint:
@@ -259,7 +259,7 @@ error hint:
 
 /*+Set(work_mem TO "1MB")*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
-INFO:  hint syntax error at or near "Set(work_mem TO "1MB")"
+INFO:  pg_hint_plan: hint syntax error at or near "Set(work_mem TO "1MB")"
 DETAIL:  Set hint requires name and value of GUC parameter.
 LOG:  pg_hint_plan:
 used hint:
@@ -276,9 +276,24 @@ Set(work_mem TO 1MB)
    ->  Index Scan using t2_pkey on t2
 (4 rows)
 
+/*+SeqScan() */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near " "
+DETAIL:  SeqScan hint requires a relation.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+SeqScan()
+
+ ?column? 
+----------
+        1
+(1 row)
+
 /*+SeqScan(t1 t2)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
-INFO:  hint syntax error at or near ""
+INFO:  pg_hint_plan: hint syntax error at or near ""
 DETAIL:  SeqScan hint accepts only one relation.
 LOG:  pg_hint_plan:
 used hint:
@@ -445,6 +460,36 @@ error hint:
          Index Cond: (id = t1.id)
 (5 rows)
 
+/*+ NestLoop() */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near " "
+DETAIL:  NestLoop hint requires at least two relations.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+NestLoop()
+
+ ?column? 
+----------
+        1
+(1 row)
+
+/*+ NestLoop(x) */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near " "
+DETAIL:  NestLoop hint requires at least two relations.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+NestLoop(x)
+
+ ?column? 
+----------
+        1
+(1 row)
+
 /*+HashJoin(t1 t2)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
 LOG:  pg_hint_plan:
@@ -563,18 +608,19 @@ error hint:
                     QUERY PLAN                    
 --------------------------------------------------
  Merge Join
-   Merge Cond: (t1.id = t4.id)
+   Merge Cond: (t1.id = t3.id)
    ->  Merge Join
-         Merge Cond: (t1.id = t3.id)
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t2_pkey on t2
+   ->  Materialize
          ->  Merge Join
-               Merge Cond: (t1.id = t2.id)
-               ->  Index Scan using t1_pkey on t1
-               ->  Index Scan using t2_pkey on t2
-         ->  Index Scan using t3_pkey on t3
-   ->  Sort
-         Sort Key: t4.id
-         ->  Seq Scan on t4
-(12 rows)
+               Merge Cond: (t3.id = t4.id)
+               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t4.id
+                     ->  Seq Scan on t4
+(13 rows)
 
 /*+HashJoin(t3 t4 t1 t2)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
@@ -640,22 +686,23 @@ error hint:
                     QUERY PLAN                    
 --------------------------------------------------
  Merge Join
-   Merge Cond: (t1.id = t4.id)
+   Merge Cond: (t1.id = t3.id)
    ->  Merge Join
-         Merge Cond: (t1.id = t3.id)
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t2_pkey on t2
+   ->  Materialize
          ->  Merge Join
-               Merge Cond: (t1.id = t2.id)
-               ->  Index Scan using t1_pkey on t1
-               ->  Index Scan using t2_pkey on t2
-         ->  Index Scan using t3_pkey on t3
-   ->  Sort
-         Sort Key: t4.id
-         ->  Seq Scan on t4
-(12 rows)
+               Merge Cond: (t3.id = t4.id)
+               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t4.id
+                     ->  Seq Scan on t4
+(13 rows)
 
 /*+Leading( */
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
-INFO:  hint syntax error at or near ""
+INFO:  pg_hint_plan: hint syntax error at or near ""
 DETAIL:  Closing parenthesis is necessary.
                     QUERY PLAN                    
 --------------------------------------------------
@@ -675,7 +722,7 @@ DETAIL:  Closing parenthesis is necessary.
 
 /*+Leading( )*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
-INFO:  hint syntax error at or near "Leading( )"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading( )"
 DETAIL:  Leading hint requires at least two relations.
 LOG:  pg_hint_plan:
 used hint:
@@ -702,7 +749,7 @@ Leading()
 
 /*+Leading( t3 )*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
-INFO:  hint syntax error at or near "Leading( t3 )"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading( t3 )"
 DETAIL:  Leading hint requires at least two relations.
 LOG:  pg_hint_plan:
 used hint:
@@ -804,7 +851,7 @@ error hint:
 
 /*+Leading(t3 t4 t1 t2 t1)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
-INFO:  hint syntax error at or near "Leading(t3 t4 t1 t2 t1)"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(t3 t4 t1 t2 t1)"
 DETAIL:  Relation name "t1" is duplicated.
 LOG:  pg_hint_plan:
 used hint:
@@ -831,7 +878,7 @@ Leading(t3 t4 t1 t2 t1)
 
 /*+Leading(t3 t4 t4)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id;
-INFO:  hint syntax error at or near "Leading(t3 t4 t4)"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(t3 t4 t4)"
 DETAIL:  Relation name "t4" is duplicated.
 LOG:  pg_hint_plan:
 used hint:
@@ -952,16 +999,16 @@ error hint:
                                QUERY PLAN                               
 ------------------------------------------------------------------------
  Index Only Scan using t1_pkey on t1
-   Index Cond: (id = $2)
-   InitPlan 1 (returns $0)
+   Index Cond: (id = $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Bitmap Heap Scan on t1 v_1
                  Recheck Cond: (id < 10)
                  ->  Bitmap Index Scan on t1_pkey
                        Index Cond: (id < 10)
-   InitPlan 3 (returns $2)
+   InitPlan 3 (returns $3)
      ->  Result
-           InitPlan 2 (returns $1)
+           InitPlan 2 (returns $2)
              ->  Limit
                    ->  Index Only Scan Backward using t1_pkey on t1 v_2
                          Index Cond: ((id IS NOT NULL) AND (id < 10))
@@ -979,14 +1026,14 @@ error hint:
                                QUERY PLAN                               
 ------------------------------------------------------------------------
  Index Only Scan using t1_pkey on t1
-   Index Cond: (id = $2)
+   Index Cond: (id = $3)
    InitPlan 2 (returns $1)
      ->  Result
            InitPlan 1 (returns $0)
              ->  Limit
                    ->  Index Only Scan Backward using t1_pkey on t1 v_1
                          Index Cond: ((id IS NOT NULL) AND (id < 10))
-   InitPlan 3 (returns $2)
+   InitPlan 3 (returns $3)
      ->  Aggregate
            ->  Bitmap Heap Scan on t1 v_2
                  Recheck Cond: (id < 10)
@@ -1036,14 +1083,14 @@ error hint:
                     QUERY PLAN                    
 --------------------------------------------------
  Index Only Scan using t1_pkey on t1
-   Index Cond: (id = $1)
-   InitPlan 1 (returns $0)
+   Index Cond: (id = $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Bitmap Heap Scan on t1 v_1
                  Recheck Cond: (id < 10)
                  ->  Bitmap Index Scan on t1_pkey
                        Index Cond: (id < 10)
-   InitPlan 2 (returns $1)
+   InitPlan 2 (returns $3)
      ->  Aggregate
            ->  Bitmap Heap Scan on t1 v_2
                  Recheck Cond: (id < 10)
@@ -1064,21 +1111,21 @@ error hint:
                                QUERY PLAN                               
 ------------------------------------------------------------------------
  Bitmap Heap Scan on t1
-   Recheck Cond: (id = $2)
-   InitPlan 1 (returns $0)
+   Recheck Cond: (id = $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Bitmap Heap Scan on t1 v_1
                  Recheck Cond: (id < 10)
                  ->  Bitmap Index Scan on t1_pkey
                        Index Cond: (id < 10)
-   InitPlan 3 (returns $2)
+   InitPlan 3 (returns $3)
      ->  Result
-           InitPlan 2 (returns $1)
+           InitPlan 2 (returns $2)
              ->  Limit
                    ->  Index Only Scan Backward using t1_pkey on t1 v_2
                          Index Cond: ((id IS NOT NULL) AND (id < 10))
    ->  Bitmap Index Scan on t1_pkey
-         Index Cond: (id = $2)
+         Index Cond: (id = $3)
 (16 rows)
 
 /*+BitmapScan(v_2)BitmapScan(t1)*/
@@ -1094,21 +1141,21 @@ error hint:
                                QUERY PLAN                               
 ------------------------------------------------------------------------
  Bitmap Heap Scan on t1
-   Recheck Cond: (id = $2)
+   Recheck Cond: (id = $3)
    InitPlan 2 (returns $1)
      ->  Result
            InitPlan 1 (returns $0)
              ->  Limit
                    ->  Index Only Scan Backward using t1_pkey on t1 v_1
                          Index Cond: ((id IS NOT NULL) AND (id < 10))
-   InitPlan 3 (returns $2)
+   InitPlan 3 (returns $3)
      ->  Aggregate
            ->  Bitmap Heap Scan on t1 v_2
                  Recheck Cond: (id < 10)
                  ->  Bitmap Index Scan on t1_pkey
                        Index Cond: (id < 10)
    ->  Bitmap Index Scan on t1_pkey
-         Index Cond: (id = $2)
+         Index Cond: (id = $3)
 (16 rows)
 
 /*+BitmapScan(v_1)BitmapScan(v_2)BitmapScan(t1)*/
@@ -1125,21 +1172,21 @@ error hint:
                     QUERY PLAN                    
 --------------------------------------------------
  Bitmap Heap Scan on t1
-   Recheck Cond: (id = $1)
-   InitPlan 1 (returns $0)
+   Recheck Cond: (id = $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Bitmap Heap Scan on t1 v_1
                  Recheck Cond: (id < 10)
                  ->  Bitmap Index Scan on t1_pkey
                        Index Cond: (id < 10)
-   InitPlan 2 (returns $1)
+   InitPlan 2 (returns $3)
      ->  Aggregate
            ->  Bitmap Heap Scan on t1 v_2
                  Recheck Cond: (id < 10)
                  ->  Bitmap Index Scan on t1_pkey
                        Index Cond: (id < 10)
    ->  Bitmap Index Scan on t1_pkey
-         Index Cond: (id = $1)
+         Index Cond: (id = $3)
 (16 rows)
 
 -- full scan hint pattern test
@@ -1484,10 +1531,10 @@ error hint:
               QUERY PLAN               
 ---------------------------------------
  Nested Loop
+   Join Filter: (t1.id = t2.id)
    ->  Seq Scan on t1
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using t2_pkey on t2
-         Index Cond: (id = t1.id)
+   ->  Seq Scan on t2
          Filter: (ctid = '(1,1)'::tid)
 (6 rows)
 
@@ -2997,6 +3044,7 @@ error hint:
    ->  Index Scan using t2_pkey on t2
 (4 rows)
 
+-- Cannot work
 /*+NestLoop(t1 t2)*/
 EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN  t2 ON (t1.id = t2.id);
 LOG:  pg_hint_plan:
@@ -3006,37 +3054,38 @@ not used hint:
 duplication hint:
 error hint:
 
-              QUERY PLAN              
---------------------------------------
- Merge Full Join
-   Merge Cond: (t1.id = t2.id)
-   ->  Index Scan using t1_pkey on t1
-   ->  Index Scan using t2_pkey on t2
-(4 rows)
+          QUERY PLAN          
+------------------------------
+ Hash Full Join
+   Hash Cond: (t1.id = t2.id)
+   ->  Seq Scan on t1
+   ->  Hash
+         ->  Seq Scan on t2
+(5 rows)
 
--- inherite table test
+-- inheritance tables test
 SET constraint_exclusion TO off;
 EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)';
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
 (19 rows)
 
@@ -3045,13 +3094,13 @@ EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid =
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_3
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_4
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
 (9 rows)
 
@@ -3068,23 +3117,23 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
 (19 rows)
 
@@ -3097,34 +3146,34 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p1_pkey on p1
+   ->  Index Scan using p1_pkey on p1 p1_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c1_pkey on p1_c1 p1
+   ->  Index Scan using p1_c1_pkey on p1_c1 p1_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c2_pkey on p1_c2 p1
+   ->  Index Scan using p1_c2_pkey on p1_c2 p1_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c3_pkey on p1_c3 p1
+   ->  Index Scan using p1_c3_pkey on p1_c3 p1_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c4_pkey on p1_c4 p1
+   ->  Index Scan using p1_c4_pkey on p1_c4 p1_5
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1
+   ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1_6
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1
+   ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1_7
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c3_c1_pkey on p1_c3_c1 p1
+   ->  Index Scan using p1_c3_c1_pkey on p1_c3_c1 p1_8
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c3_c2_pkey on p1_c3_c2 p1
+   ->  Index Scan using p1_c3_c2_pkey on p1_c3_c2 p1_9
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (28 rows)
@@ -3141,47 +3190,47 @@ error hint:
                       QUERY PLAN                       
 -------------------------------------------------------
  Append
-   ->  Bitmap Heap Scan on p1
+   ->  Bitmap Heap Scan on p1 p1_1
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c1 p1
+   ->  Bitmap Heap Scan on p1_c1 p1_2
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c2 p1
+   ->  Bitmap Heap Scan on p1_c2 p1_3
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c2_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c3 p1
+   ->  Bitmap Heap Scan on p1_c3 p1_4
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c3_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c4 p1
+   ->  Bitmap Heap Scan on p1_c4 p1_5
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c4_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c1_c1 p1
+   ->  Bitmap Heap Scan on p1_c1_c1 p1_6
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c1_c1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c1_c2 p1
+   ->  Bitmap Heap Scan on p1_c1_c2 p1_7
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c1_c2_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c3_c1 p1
+   ->  Bitmap Heap Scan on p1_c3_c1 p1_8
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c3_c1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c3_c2 p1
+   ->  Bitmap Heap Scan on p1_c3_c2 p1_9
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c3_c2_pkey
@@ -3200,31 +3249,31 @@ error hint:
                  QUERY PLAN                  
 ---------------------------------------------
  Append
-   ->  Tid Scan on p1
+   ->  Tid Scan on p1 p1_1
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c1 p1
+   ->  Tid Scan on p1_c1 p1_2
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c2 p1
+   ->  Tid Scan on p1_c2 p1_3
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c3 p1
+   ->  Tid Scan on p1_c3 p1_4
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c4 p1
+   ->  Tid Scan on p1_c4 p1_5
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c1_c1 p1
+   ->  Tid Scan on p1_c1_c1 p1_6
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c1_c2 p1
+   ->  Tid Scan on p1_c1_c2 p1_7
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c3_c1 p1
+   ->  Tid Scan on p1_c3_c1 p1_8
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c3_c2 p1
+   ->  Tid Scan on p1_c3_c2 p1_9
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
 (28 rows)
@@ -3242,13 +3291,13 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_3
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_4
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
 (9 rows)
 
@@ -3261,19 +3310,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p1_pkey on p1
+   ->  Index Scan using p1_pkey on p1 p1_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c1_pkey on p1_c1 p1
+   ->  Index Scan using p1_c1_pkey on p1_c1 p1_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1
+   ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1
+   ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -3290,22 +3339,22 @@ error hint:
                       QUERY PLAN                       
 -------------------------------------------------------
  Append
-   ->  Bitmap Heap Scan on p1
+   ->  Bitmap Heap Scan on p1 p1_1
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c1 p1
+   ->  Bitmap Heap Scan on p1_c1 p1_2
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c1_c1 p1
+   ->  Bitmap Heap Scan on p1_c1_c1 p1_3
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c1_c1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
-   ->  Bitmap Heap Scan on p1_c1_c2 p1
+   ->  Bitmap Heap Scan on p1_c1_c2 p1_4
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_c1_c2_pkey
@@ -3324,16 +3373,16 @@ error hint:
                  QUERY PLAN                  
 ---------------------------------------------
  Append
-   ->  Tid Scan on p1
+   ->  Tid Scan on p1 p1_1
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c1 p1
+   ->  Tid Scan on p1_c1 p1_2
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c1_c1 p1
+   ->  Tid Scan on p1_c1_c1 p1_3
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p1_c1_c2 p1
+   ->  Tid Scan on p1_c1_c2 p1_4
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
 (13 rows)
@@ -3343,27 +3392,27 @@ EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND
                                     QUERY PLAN                                     
 -----------------------------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
+               ->  Seq Scan on p1 p1_1
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
+               ->  Seq Scan on p1_c1 p1_2
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c2 p1
+               ->  Seq Scan on p1_c2 p1_3
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3 p1
+               ->  Seq Scan on p1_c3 p1_4
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c4 p1
+               ->  Seq Scan on p1_c4 p1_5
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
+               ->  Seq Scan on p1_c1_c1 p1_6
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
+               ->  Seq Scan on p1_c1_c2 p1_7
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c1 p1
+               ->  Seq Scan on p1_c3_c1 p1_8
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c2 p1
+               ->  Seq Scan on p1_c3_c2 p1_9
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
@@ -3374,17 +3423,17 @@ EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND
                                     QUERY PLAN                                     
 -----------------------------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
+               ->  Seq Scan on p1 p1_1
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
+               ->  Seq Scan on p1_c1 p1_2
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
+               ->  Seq Scan on p1_c1_c1 p1_3
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
+               ->  Seq Scan on p1_c1_c2 p1_4
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
@@ -3403,27 +3452,27 @@ error hint:
                                     QUERY PLAN                                     
 -----------------------------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
+               ->  Seq Scan on p1 p1_1
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
+               ->  Seq Scan on p1_c1 p1_2
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c2 p1
+               ->  Seq Scan on p1_c2 p1_3
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3 p1
+               ->  Seq Scan on p1_c3 p1_4
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c4 p1
+               ->  Seq Scan on p1_c4 p1_5
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
+               ->  Seq Scan on p1_c1_c1 p1_6
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
+               ->  Seq Scan on p1_c1_c2 p1_7
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c1 p1
+               ->  Seq Scan on p1_c3_c1 p1_8
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c2 p1
+               ->  Seq Scan on p1_c3_c2 p1_9
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
@@ -3438,34 +3487,42 @@ not used hint:
 duplication hint:
 error hint:
 
-                                    QUERY PLAN                                     
------------------------------------------------------------------------------------
+                         QUERY PLAN                          
+-------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
-   ->  Sort
-         Sort Key: public.p1.id
-         ->  Append
-               ->  Seq Scan on p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c4 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   Merge Cond: (p1.id = t1.id)
+   ->  Merge Append
+         Sort Key: p1.id
+         ->  Index Scan using p1_pkey on p1 p1_1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_pkey on p1_c1 p1_2
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c2_pkey on p1_c2 p1_3
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c3_pkey on p1_c3 p1_4
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c4_pkey on p1_c4 p1_5
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1_6
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1_7
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c3_c1_pkey on p1_c3_c1 p1_8
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c3_c2_pkey on p1_c3_c2 p1_9
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
-(25 rows)
+(33 rows)
 
 /*+BitmapScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -3476,34 +3533,61 @@ not used hint:
 duplication hint:
 error hint:
 
-                                    QUERY PLAN                                     
------------------------------------------------------------------------------------
+                            QUERY PLAN                             
+-------------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c4 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Bitmap Heap Scan on p1 p1_1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1 p1_2
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c2 p1_3
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c2_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c3 p1_4
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c3_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c4 p1_5
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c4_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1_c1 p1_6
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1_c2 p1_7
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_c2_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c3_c1 p1_8
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c3_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c3_c2 p1_9
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c3_c2_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
-(25 rows)
+(52 rows)
 
 /*+TidScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -3514,34 +3598,43 @@ not used hint:
 duplication hint:
 error hint:
 
-                                    QUERY PLAN                                     
------------------------------------------------------------------------------------
+                       QUERY PLAN                        
+---------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c4 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Tid Scan on p1 p1_1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1 p1_2
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c2 p1_3
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c3 p1_4
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c4 p1_5
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1_c1 p1_6
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1_c2 p1_7
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c3_c1 p1_8
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c3_c2 p1_9
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
-(25 rows)
+(34 rows)
 
 /*+NestLoop(p1 t1)*/
 EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -3555,25 +3648,25 @@ error hint:
                                  QUERY PLAN                                  
 -----------------------------------------------------------------------------
  Nested Loop
-   Join Filter: (public.p1.id = t1.id)
+   Join Filter: (p1.id = t1.id)
    ->  Append
-         ->  Seq Scan on p1
+         ->  Seq Scan on p1 p1_1
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c1 p1
+         ->  Seq Scan on p1_c1 p1_2
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c2 p1
+         ->  Seq Scan on p1_c2 p1_3
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c3 p1
+         ->  Seq Scan on p1_c3 p1_4
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c4 p1
+         ->  Seq Scan on p1_c4 p1_5
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c1_c1 p1
+         ->  Seq Scan on p1_c1_c1 p1_6
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c1_c2 p1
+         ->  Seq Scan on p1_c1_c2 p1_7
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c3_c1 p1
+         ->  Seq Scan on p1_c3_c1 p1_8
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c3_c2 p1
+         ->  Seq Scan on p1_c3_c2 p1_9
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Materialize
          ->  Index Scan using t1_pkey on t1
@@ -3592,27 +3685,27 @@ error hint:
                                     QUERY PLAN                                     
 -----------------------------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
+               ->  Seq Scan on p1 p1_1
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
+               ->  Seq Scan on p1_c1 p1_2
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c2 p1
+               ->  Seq Scan on p1_c2 p1_3
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3 p1
+               ->  Seq Scan on p1_c3 p1_4
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c4 p1
+               ->  Seq Scan on p1_c4 p1_5
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
+               ->  Seq Scan on p1_c1_c1 p1_6
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
+               ->  Seq Scan on p1_c1_c2 p1_7
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c1 p1
+               ->  Seq Scan on p1_c3_c1 p1_8
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c3_c2 p1
+               ->  Seq Scan on p1_c3_c2 p1_9
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
@@ -3630,25 +3723,25 @@ error hint:
                                  QUERY PLAN                                  
 -----------------------------------------------------------------------------
  Hash Join
-   Hash Cond: (public.p1.id = t1.id)
+   Hash Cond: (p1.id = t1.id)
    ->  Append
-         ->  Seq Scan on p1
+         ->  Seq Scan on p1 p1_1
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c1 p1
+         ->  Seq Scan on p1_c1 p1_2
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c2 p1
+         ->  Seq Scan on p1_c2 p1_3
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c3 p1
+         ->  Seq Scan on p1_c3 p1_4
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c4 p1
+         ->  Seq Scan on p1_c4 p1_5
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c1_c1 p1
+         ->  Seq Scan on p1_c1_c1 p1_6
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c1_c2 p1
+         ->  Seq Scan on p1_c1_c2 p1_7
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c3_c1 p1
+         ->  Seq Scan on p1_c3_c1 p1_8
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-         ->  Seq Scan on p1_c3_c2 p1
+         ->  Seq Scan on p1_c3_c2 p1_9
                Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Hash
          ->  Index Scan using t1_pkey on t1
@@ -3668,17 +3761,17 @@ error hint:
                                     QUERY PLAN                                     
 -----------------------------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
+               ->  Seq Scan on p1 p1_1
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
+               ->  Seq Scan on p1_c1 p1_2
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
+               ->  Seq Scan on p1_c1_c1 p1_3
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
+               ->  Seq Scan on p1_c1_c2 p1_4
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
@@ -3693,24 +3786,27 @@ not used hint:
 duplication hint:
 error hint:
 
-                                    QUERY PLAN                                     
------------------------------------------------------------------------------------
+                         QUERY PLAN                          
+-------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
-   ->  Sort
-         Sort Key: public.p1.id
-         ->  Append
-               ->  Seq Scan on p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   Merge Cond: (p1.id = t1.id)
+   ->  Merge Append
+         Sort Key: p1.id
+         ->  Index Scan using p1_pkey on p1 p1_1
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_pkey on p1_c1 p1_2
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1_3
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
+         ->  Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1_4
+               Index Cond: ((id >= 50) AND (id <= 51))
+               Filter: (ctid = '(1,1)'::tid)
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
-(15 rows)
+(18 rows)
 
 /*+BitmapScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -3721,24 +3817,36 @@ not used hint:
 duplication hint:
 error hint:
 
-                                    QUERY PLAN                                     
------------------------------------------------------------------------------------
+                            QUERY PLAN                             
+-------------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Bitmap Heap Scan on p1 p1_1
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1 p1_2
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1_c1 p1_3
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_c1_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
+               ->  Bitmap Heap Scan on p1_c1_c2 p1_4
+                     Recheck Cond: ((id >= 50) AND (id <= 51))
+                     Filter: (ctid = '(1,1)'::tid)
+                     ->  Bitmap Index Scan on p1_c1_c2_pkey
+                           Index Cond: ((id >= 50) AND (id <= 51))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
-(15 rows)
+(27 rows)
 
 /*+TidScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -3749,24 +3857,28 @@ not used hint:
 duplication hint:
 error hint:
 
-                                    QUERY PLAN                                     
------------------------------------------------------------------------------------
+                       QUERY PLAN                        
+---------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
-                     Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+               ->  Tid Scan on p1 p1_1
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1 p1_2
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1_c1 p1_3
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
+               ->  Tid Scan on p1_c1_c2 p1_4
+                     TID Cond: (ctid = '(1,1)'::tid)
+                     Filter: ((id >= 50) AND (id <= 51))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
-(15 rows)
+(19 rows)
 
 /*+NestLoop(p1 t1)*/
 EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -3780,18 +3892,18 @@ error hint:
                                     QUERY PLAN                                     
 -----------------------------------------------------------------------------------
  Nested Loop
-   Join Filter: (public.p1.id = t1.id)
+   Join Filter: (p1.id = t1.id)
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
    ->  Materialize
          ->  Append
-               ->  Seq Scan on p1
+               ->  Seq Scan on p1 p1_1
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
+               ->  Seq Scan on p1_c1 p1_2
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
+               ->  Seq Scan on p1_c1_c1 p1_3
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
+               ->  Seq Scan on p1_c1_c2 p1_4
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
 (14 rows)
 
@@ -3807,17 +3919,17 @@ error hint:
                                     QUERY PLAN                                     
 -----------------------------------------------------------------------------------
  Merge Join
-   Merge Cond: (public.p1.id = t1.id)
+   Merge Cond: (p1.id = t1.id)
    ->  Sort
-         Sort Key: public.p1.id
+         Sort Key: p1.id
          ->  Append
-               ->  Seq Scan on p1
+               ->  Seq Scan on p1 p1_1
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
+               ->  Seq Scan on p1_c1 p1_2
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
+               ->  Seq Scan on p1_c1_c1 p1_3
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
+               ->  Seq Scan on p1_c1_c2 p1_4
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
@@ -3835,18 +3947,18 @@ error hint:
                                     QUERY PLAN                                     
 -----------------------------------------------------------------------------------
  Hash Join
-   Hash Cond: (t1.id = public.p1.id)
+   Hash Cond: (t1.id = p1.id)
    ->  Index Scan using t1_pkey on t1
          Index Cond: (id < 10)
    ->  Hash
          ->  Append
-               ->  Seq Scan on p1
+               ->  Seq Scan on p1 p1_1
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1 p1
+               ->  Seq Scan on p1_c1 p1_2
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c1 p1
+               ->  Seq Scan on p1_c1_c1 p1_3
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-               ->  Seq Scan on p1_c1_c2 p1
+               ->  Seq Scan on p1_c1_c2 p1_4
                      Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
 (14 rows)
 
@@ -3944,11 +4056,12 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Seq Scan on p1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+         Index Cond: (id < 10)
+(6 rows)
 
 /*+MergeJoin(p1 t1)*/
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -4069,11 +4182,12 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Seq Scan on p1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+         Index Cond: (id < 10)
+(6 rows)
 
 /*+MergeJoin(p1 t1)*/
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -4121,22 +4235,24 @@ EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 5
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Seq Scan on p1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+         Index Cond: (id < 10)
+(6 rows)
 
 SET constraint_exclusion TO on;
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Seq Scan on p1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+         Index Cond: (id < 10)
+(6 rows)
 
 SET constraint_exclusion TO off;
 /*+SeqScan(p1)*/
@@ -4151,11 +4267,12 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Seq Scan on p1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+         Index Cond: (id < 10)
+(6 rows)
 
 /*+IndexScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -4166,15 +4283,16 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
- Nested Loop
+                   QUERY PLAN                    
+-------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
    ->  Index Scan using p1_pkey on p1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(6 rows)
+         Index Cond: (id < 10)
+(7 rows)
 
 /*+BitmapScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -4188,14 +4306,15 @@ error hint:
                       QUERY PLAN                       
 -------------------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Bitmap Heap Scan on p1
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(8 rows)
+         Index Cond: (id < 10)
+(9 rows)
 
 /*+TidScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -4206,15 +4325,16 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                 QUERY PLAN                  
+---------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Tid Scan on p1
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(6 rows)
+         Index Cond: (id < 10)
+(7 rows)
 
 SET constraint_exclusion TO on;
 /*+SeqScan(p1)*/
@@ -4229,11 +4349,12 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Seq Scan on p1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+         Index Cond: (id < 10)
+(6 rows)
 
 /*+IndexScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -4244,15 +4365,16 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
- Nested Loop
+                   QUERY PLAN                    
+-------------------------------------------------
+ Merge Join
+   Merge Cond: (p1.id = t1.id)
    ->  Index Scan using p1_pkey on p1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(6 rows)
+         Index Cond: (id < 10)
+(7 rows)
 
 /*+BitmapScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -4266,14 +4388,15 @@ error hint:
                       QUERY PLAN                       
 -------------------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Bitmap Heap Scan on p1
          Recheck Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
          ->  Bitmap Index Scan on p1_pkey
                Index Cond: ((id >= 50) AND (id <= 51))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(8 rows)
+         Index Cond: (id < 10)
+(9 rows)
 
 /*+TidScan(p1)*/
 EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
@@ -4284,15 +4407,16 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                 QUERY PLAN                  
+---------------------------------------------
  Nested Loop
+   Join Filter: (p1.id = t1.id)
    ->  Tid Scan on p1
          TID Cond: (ctid = '(1,1)'::tid)
          Filter: ((id >= 50) AND (id <= 51))
    ->  Index Scan using t1_pkey on t1
-         Index Cond: ((id = p1.id) AND (id < 10))
-(6 rows)
+         Index Cond: (id < 10)
+(7 rows)
 
 -- quote test
 /*+SeqScan("""t1 )     ")IndexScan("t  2 """)HashJoin("""t1 )  "T3"t   2 """)Leading("""t1 )   "T3"t   2 """)Set(application_name"a    a       a""     a       A")*/
@@ -4324,25 +4448,25 @@ error hint:
 -- duplicate hint test
 /*+SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)';
-INFO:  hint syntax error at or near "SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict scan method hint.
-INFO:  hint syntax error at or near "IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict scan method hint.
-INFO:  hint syntax error at or near "BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict scan method hint.
-INFO:  hint syntax error at or near "SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict scan method hint.
-INFO:  hint syntax error at or near "IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict scan method hint.
-INFO:  hint syntax error at or near "BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict scan method hint.
-INFO:  hint syntax error at or near "HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict join method hint.
-INFO:  hint syntax error at or near "NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict join method hint.
-INFO:  hint syntax error at or near "Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict set hint.
-INFO:  hint syntax error at or near "Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)"
 DETAIL:  Conflict leading hint.
 LOG:  pg_hint_plan:
 used hint:
@@ -4397,18 +4521,7 @@ SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t
                                   QUERY PLAN                                  
 ------------------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t1_5.id = t3_5.id)
-                 ->  Merge Join
-                       Merge Cond: (t1_5.id = t2_5.id)
-                       ->  Index Only Scan using t1_pkey on t1 t1_5
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                 ->  Sort
-                       Sort Key: t3_5.id
-                       ->  Seq Scan on t3 t3_5
-   InitPlan 2 (returns $1)
+   InitPlan 1 (returns $0)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_2.id = t3_2.id)
@@ -4419,7 +4532,7 @@ SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t
                  ->  Sort
                        Sort Key: t3_2.id
                        ->  Seq Scan on t3 t3_2
-   InitPlan 3 (returns $2)
+   InitPlan 2 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_4.id = t3_4.id)
@@ -4436,20 +4549,29 @@ SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t
                      ->  Nested Loop
                            ->  Nested Loop
                                  ->  Index Only Scan using t1_pkey on t1 t1_1
-                                       Index Cond: (id = $2)
+                                       Index Cond: (id = $1)
                                  ->  Index Only Scan using t2_pkey on t2 t2_1
-                                       Index Cond: (id = $2)
+                                       Index Cond: (id = $1)
                            ->  Seq Scan on t3 t3_1
-                                 Filter: (id = $2)
+                                 Filter: (id = $1)
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $2)
+                           Index Cond: (id = $1)
                ->  Index Only Scan using t2_pkey on t2 t2_3
-                     Index Cond: (id = $2)
+                     Index Cond: (id = $1)
          ->  Seq Scan on t3 t3_3
-               Filter: (id = $2)
-   ->  CTE Scan on c1_1
-         Filter: (id = $2)
-(53 rows)
+               Filter: (id = $1)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $1)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Merge Join
+                     Merge Cond: (t1_5.id = t2_5.id)
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
 
 /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/
 EXPLAIN (COSTS false)
@@ -4477,18 +4599,7 @@ error hint:
                                   QUERY PLAN                                  
 ------------------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t1_5.id = t3_5.id)
-                 ->  Nested Loop
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                       ->  Index Only Scan using t1_pkey on t1 t1_5
-                             Index Cond: (id = t2_5.id)
-                 ->  Sort
-                       Sort Key: t3_5.id
-                       ->  Seq Scan on t3 t3_5
-   InitPlan 2 (returns $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_2.id = t3_2.id)
@@ -4499,7 +4610,7 @@ error hint:
                  ->  Sort
                        Sort Key: t3_2.id
                        ->  Seq Scan on t3 t3_2
-   InitPlan 3 (returns $5)
+   InitPlan 2 (returns $3)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_4.id = t3_4.id)
@@ -4516,20 +4627,29 @@ error hint:
                      ->  Nested Loop
                            ->  Nested Loop
                                  ->  Index Only Scan using t1_pkey on t1 t1_1
-                                       Index Cond: (id = $5)
+                                       Index Cond: (id = $3)
                                  ->  Index Only Scan using t2_pkey on t2 t2_1
-                                       Index Cond: (id = $5)
+                                       Index Cond: (id = $3)
                            ->  Seq Scan on t3 t3_1
-                                 Filter: (id = $5)
+                                 Filter: (id = $3)
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Index Only Scan using t2_pkey on t2 t2_3
-                     Index Cond: (id = $5)
+                     Index Cond: (id = $3)
          ->  Seq Scan on t3 t3_3
-               Filter: (id = $5)
-   ->  CTE Scan on c1_1
-         Filter: (id = $5)
-(53 rows)
+               Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
 
 /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/
 EXPLAIN (COSTS false)
@@ -4558,18 +4678,7 @@ error hint:
                                   QUERY PLAN                                  
 ------------------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t1_5.id = t3_5.id)
-                 ->  Nested Loop
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                       ->  Index Only Scan using t1_pkey on t1 t1_5
-                             Index Cond: (id = t2_5.id)
-                 ->  Sort
-                       Sort Key: t3_5.id
-                       ->  Seq Scan on t3 t3_5
-   InitPlan 2 (returns $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_2.id = t3_2.id)
@@ -4580,7 +4689,7 @@ error hint:
                  ->  Sort
                        Sort Key: t3_2.id
                        ->  Seq Scan on t3 t3_2
-   InitPlan 3 (returns $5)
+   InitPlan 2 (returns $3)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_4.id = t3_4.id)
@@ -4597,20 +4706,29 @@ error hint:
                      ->  Nested Loop
                            ->  Nested Loop
                                  ->  Index Only Scan using t1_pkey on t1 t1_1
-                                       Index Cond: (id = $5)
+                                       Index Cond: (id = $3)
                                  ->  Index Only Scan using t2_pkey on t2 t2_1
-                                       Index Cond: (id = $5)
+                                       Index Cond: (id = $3)
                            ->  Seq Scan on t3 t3_1
-                                 Filter: (id = $5)
+                                 Filter: (id = $3)
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Index Only Scan using t2_pkey on t2 t2_3
-                     Index Cond: (id = $5)
+                     Index Cond: (id = $3)
          ->  Seq Scan on t3 t3_3
-               Filter: (id = $5)
-   ->  CTE Scan on c1_1
-         Filter: (id = $5)
-(53 rows)
+               Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
 
 /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/
 EXPLAIN (COSTS false)
@@ -4639,18 +4757,7 @@ error hint:
                                   QUERY PLAN                                  
 ------------------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t1_5.id = t3_5.id)
-                 ->  Nested Loop
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                       ->  Index Only Scan using t1_pkey on t1 t1_5
-                             Index Cond: (id = t2_5.id)
-                 ->  Sort
-                       Sort Key: t3_5.id
-                       ->  Seq Scan on t3 t3_5
-   InitPlan 2 (returns $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_2.id = t3_2.id)
@@ -4661,7 +4768,7 @@ error hint:
                  ->  Sort
                        Sort Key: t3_2.id
                        ->  Seq Scan on t3 t3_2
-   InitPlan 3 (returns $5)
+   InitPlan 2 (returns $3)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_4.id = t3_4.id)
@@ -4678,20 +4785,29 @@ error hint:
                      ->  Nested Loop
                            ->  Nested Loop
                                  ->  Index Only Scan using t1_pkey on t1 t1_1
-                                       Index Cond: (id = $5)
+                                       Index Cond: (id = $3)
                                  ->  Index Only Scan using t2_pkey on t2 t2_1
-                                       Index Cond: (id = $5)
+                                       Index Cond: (id = $3)
                            ->  Seq Scan on t3 t3_1
-                                 Filter: (id = $5)
+                                 Filter: (id = $3)
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Index Only Scan using t2_pkey on t2 t2_3
-                     Index Cond: (id = $5)
+                     Index Cond: (id = $3)
          ->  Seq Scan on t3 t3_3
-               Filter: (id = $5)
-   ->  CTE Scan on c1_1
-         Filter: (id = $5)
-(53 rows)
+               Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
 
 /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/
 EXPLAIN (COSTS false)
@@ -4720,21 +4836,10 @@ NestLoop(t1_5 t2_5)
 duplication hint:
 error hint:
 
-                               QUERY PLAN                               
-------------------------------------------------------------------------
+                                           QUERY PLAN                                           
+------------------------------------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t2_5.id = t1_5.id)
-                 ->  Merge Join
-                       Merge Cond: (t2_5.id = t3_5.id)
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                       ->  Sort
-                             Sort Key: t3_5.id
-                             ->  Seq Scan on t3 t3_5
-                 ->  Index Only Scan using t1_pkey on t1 t1_5
-   InitPlan 2 (returns $1)
+   InitPlan 1 (returns $0)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t2_2.id = t1_2.id)
@@ -4745,7 +4850,7 @@ error hint:
                              Sort Key: t3_2.id
                              ->  Seq Scan on t3 t3_2
                  ->  Index Only Scan using t1_pkey on t1 t1_2
-   InitPlan 3 (returns $2)
+   InitPlan 2 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t2_4.id = t1_4.id)
@@ -4762,20 +4867,29 @@ error hint:
                      ->  Nested Loop
                            ->  Nested Loop
                                  ->  Seq Scan on t3 t3_3
-                                       Filter: (id = $2)
-                                 ->  CTE Scan on c1_1
-                                       Filter: (id = $2)
+                                       Filter: (id = $1)
+                                 ->  Aggregate
+                                       Filter: (max(t1_5.id) = $1)
+                                       ->  Merge Join
+                                             Merge Cond: (t2_5.id = t1_5.id)
+                                             ->  Merge Join
+                                                   Merge Cond: (t2_5.id = t3_5.id)
+                                                   ->  Index Only Scan using t2_pkey on t2 t2_5
+                                                   ->  Sort
+                                                         Sort Key: t3_5.id
+                                                         ->  Seq Scan on t3 t3_5
+                                             ->  Index Only Scan using t1_pkey on t1 t1_5
                            ->  Index Only Scan using t2_pkey on t2 t2_3
-                                 Index Cond: (id = $2)
+                                 Index Cond: (id = $1)
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $2)
+                           Index Cond: (id = $1)
                ->  Seq Scan on t3 t3_1
-                     Filter: (id = $2)
+                     Filter: (id = $1)
          ->  Index Only Scan using t2_pkey on t2 t2_1
-               Index Cond: (id = $2)
+               Index Cond: (id = $1)
    ->  Index Only Scan using t1_pkey on t1 t1_1
-         Index Cond: (id = $2)
-(53 rows)
+         Index Cond: (id = $1)
+(51 rows)
 
 SET from_collapse_limit TO 1;
 EXPLAIN (COSTS false)
@@ -4792,18 +4906,7 @@ SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t
                              QUERY PLAN                             
 --------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t1_5.id = t3_5.id)
-                 ->  Merge Join
-                       Merge Cond: (t1_5.id = t2_5.id)
-                       ->  Index Only Scan using t1_pkey on t1 t1_5
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                 ->  Sort
-                       Sort Key: t3_5.id
-                       ->  Seq Scan on t3 t3_5
-   InitPlan 2 (returns $1)
+   InitPlan 1 (returns $0)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_2.id = t3_2.id)
@@ -4814,7 +4917,7 @@ SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t
                  ->  Sort
                        Sort Key: t3_2.id
                        ->  Seq Scan on t3 t3_2
-   InitPlan 3 (returns $2)
+   InitPlan 2 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_4.id = t3_4.id)
@@ -4829,22 +4932,31 @@ SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t
          ->  Nested Loop
                ->  Nested Loop
                      ->  Index Only Scan using t1_pkey on t1 t1_1
-                           Index Cond: (id = $2)
+                           Index Cond: (id = $1)
                      ->  Index Only Scan using t2_pkey on t2 t2_1
-                           Index Cond: (id = $2)
+                           Index Cond: (id = $1)
                ->  Seq Scan on t3 t3_1
-                     Filter: (id = $2)
+                     Filter: (id = $1)
          ->  Nested Loop
                ->  Nested Loop
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $2)
+                           Index Cond: (id = $1)
                      ->  Index Only Scan using t2_pkey on t2 t2_3
-                           Index Cond: (id = $2)
+                           Index Cond: (id = $1)
                ->  Seq Scan on t3 t3_3
-                     Filter: (id = $2)
-   ->  CTE Scan on c1_1
-         Filter: (id = $2)
-(53 rows)
+                     Filter: (id = $1)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $1)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Merge Join
+                     Merge Cond: (t1_5.id = t2_5.id)
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
 
 /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/
 EXPLAIN (COSTS false)
@@ -4872,18 +4984,7 @@ error hint:
                              QUERY PLAN                             
 --------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t1_5.id = t3_5.id)
-                 ->  Nested Loop
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                       ->  Index Only Scan using t1_pkey on t1 t1_5
-                             Index Cond: (id = t2_5.id)
-                 ->  Sort
-                       Sort Key: t3_5.id
-                       ->  Seq Scan on t3 t3_5
-   InitPlan 2 (returns $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_2.id = t3_2.id)
@@ -4894,7 +4995,7 @@ error hint:
                  ->  Sort
                        Sort Key: t3_2.id
                        ->  Seq Scan on t3 t3_2
-   InitPlan 3 (returns $5)
+   InitPlan 2 (returns $3)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_4.id = t3_4.id)
@@ -4909,22 +5010,31 @@ error hint:
          ->  Nested Loop
                ->  Nested Loop
                      ->  Index Only Scan using t1_pkey on t1 t1_1
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                      ->  Index Only Scan using t2_pkey on t2 t2_1
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Seq Scan on t3 t3_1
-                     Filter: (id = $5)
+                     Filter: (id = $3)
          ->  Nested Loop
                ->  Nested Loop
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                      ->  Index Only Scan using t2_pkey on t2 t2_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Seq Scan on t3 t3_3
-                     Filter: (id = $5)
-   ->  CTE Scan on c1_1
-         Filter: (id = $5)
-(53 rows)
+                     Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
 
 /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/
 EXPLAIN (COSTS false)
@@ -4953,18 +5063,7 @@ error hint:
                              QUERY PLAN                             
 --------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t1_5.id = t3_5.id)
-                 ->  Nested Loop
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                       ->  Index Only Scan using t1_pkey on t1 t1_5
-                             Index Cond: (id = t2_5.id)
-                 ->  Sort
-                       Sort Key: t3_5.id
-                       ->  Seq Scan on t3 t3_5
-   InitPlan 2 (returns $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_2.id = t3_2.id)
@@ -4975,7 +5074,7 @@ error hint:
                  ->  Sort
                        Sort Key: t3_2.id
                        ->  Seq Scan on t3 t3_2
-   InitPlan 3 (returns $5)
+   InitPlan 2 (returns $3)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_4.id = t3_4.id)
@@ -4990,22 +5089,31 @@ error hint:
          ->  Nested Loop
                ->  Nested Loop
                      ->  Index Only Scan using t1_pkey on t1 t1_1
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                      ->  Index Only Scan using t2_pkey on t2 t2_1
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Seq Scan on t3 t3_1
-                     Filter: (id = $5)
+                     Filter: (id = $3)
          ->  Nested Loop
                ->  Nested Loop
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                      ->  Index Only Scan using t2_pkey on t2 t2_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Seq Scan on t3 t3_3
-                     Filter: (id = $5)
-   ->  CTE Scan on c1_1
-         Filter: (id = $5)
-(53 rows)
+                     Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
 
 /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/
 EXPLAIN (COSTS false)
@@ -5034,18 +5142,7 @@ error hint:
                              QUERY PLAN                             
 --------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t1_5.id = t3_5.id)
-                 ->  Nested Loop
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                       ->  Index Only Scan using t1_pkey on t1 t1_5
-                             Index Cond: (id = t2_5.id)
-                 ->  Sort
-                       Sort Key: t3_5.id
-                       ->  Seq Scan on t3 t3_5
-   InitPlan 2 (returns $3)
+   InitPlan 1 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_2.id = t3_2.id)
@@ -5056,7 +5153,7 @@ error hint:
                  ->  Sort
                        Sort Key: t3_2.id
                        ->  Seq Scan on t3 t3_2
-   InitPlan 3 (returns $5)
+   InitPlan 2 (returns $3)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t1_4.id = t3_4.id)
@@ -5071,22 +5168,31 @@ error hint:
          ->  Nested Loop
                ->  Nested Loop
                      ->  Index Only Scan using t1_pkey on t1 t1_1
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                      ->  Index Only Scan using t2_pkey on t2 t2_1
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Seq Scan on t3 t3_1
-                     Filter: (id = $5)
+                     Filter: (id = $3)
          ->  Nested Loop
                ->  Nested Loop
                      ->  Index Only Scan using t1_pkey on t1 t1_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                      ->  Index Only Scan using t2_pkey on t2 t2_3
-                           Index Cond: (id = $5)
+                           Index Cond: (id = $3)
                ->  Seq Scan on t3 t3_3
-                     Filter: (id = $5)
-   ->  CTE Scan on c1_1
-         Filter: (id = $5)
-(53 rows)
+                     Filter: (id = $3)
+   ->  Aggregate
+         Filter: (max(t1_5.id) = $3)
+         ->  Merge Join
+               Merge Cond: (t1_5.id = t3_5.id)
+               ->  Nested Loop
+                     ->  Index Only Scan using t2_pkey on t2 t2_5
+                     ->  Index Only Scan using t1_pkey on t1 t1_5
+                           Index Cond: (id = t2_5.id)
+               ->  Sort
+                     Sort Key: t3_5.id
+                     ->  Seq Scan on t3 t3_5
+(51 rows)
 
 /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/
 EXPLAIN (COSTS false)
@@ -5115,21 +5221,10 @@ NestLoop(t1_5 t2_5)
 duplication hint:
 error hint:
 
-                                  QUERY PLAN                                  
-------------------------------------------------------------------------------
+                                     QUERY PLAN                                     
+------------------------------------------------------------------------------------
  Nested Loop
-   CTE c1_1
-     ->  Aggregate
-           ->  Merge Join
-                 Merge Cond: (t2_5.id = t1_5.id)
-                 ->  Merge Join
-                       Merge Cond: (t2_5.id = t3_5.id)
-                       ->  Index Only Scan using t2_pkey on t2 t2_5
-                       ->  Sort
-                             Sort Key: t3_5.id
-                             ->  Seq Scan on t3 t3_5
-                 ->  Index Only Scan using t1_pkey on t1 t1_5
-   InitPlan 2 (returns $1)
+   InitPlan 1 (returns $0)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t2_2.id = t1_2.id)
@@ -5140,7 +5235,7 @@ error hint:
                              Sort Key: t3_2.id
                              ->  Seq Scan on t3 t3_2
                  ->  Index Only Scan using t1_pkey on t1 t1_2
-   InitPlan 3 (returns $2)
+   InitPlan 2 (returns $1)
      ->  Aggregate
            ->  Merge Join
                  Merge Cond: (t2_4.id = t1_4.id)
@@ -5157,37 +5252,46 @@ error hint:
                      ->  Nested Loop
                            ->  Nested Loop
                                  ->  Index Only Scan using t1_pkey on t1 t1_3
-                                       Index Cond: (id = $2)
+                                       Index Cond: (id = $1)
                                  ->  Index Only Scan using t2_pkey on t2 t2_3
-                                       Index Cond: (id = $2)
+                                       Index Cond: (id = $1)
                            ->  Seq Scan on t3 t3_3
-                                 Filter: (id = $2)
-                     ->  CTE Scan on c1_1
-                           Filter: (id = $2)
+                                 Filter: (id = $1)
+                     ->  Aggregate
+                           Filter: (max(t1_5.id) = $1)
+                           ->  Merge Join
+                                 Merge Cond: (t2_5.id = t1_5.id)
+                                 ->  Merge Join
+                                       Merge Cond: (t2_5.id = t3_5.id)
+                                       ->  Index Only Scan using t2_pkey on t2 t2_5
+                                       ->  Sort
+                                             Sort Key: t3_5.id
+                                             ->  Seq Scan on t3 t3_5
+                                 ->  Index Only Scan using t1_pkey on t1 t1_5
                ->  Seq Scan on t3 t3_1
-                     Filter: (id = $2)
+                     Filter: (id = $1)
          ->  Index Only Scan using t2_pkey on t2 t2_1
-               Index Cond: (id = $2)
+               Index Cond: (id = $1)
    ->  Index Only Scan using t1_pkey on t1 t1_1
-         Index Cond: (id = $2)
-(53 rows)
+         Index Cond: (id = $1)
+(51 rows)
 
 -- ambigous error
 EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id;
-                  QUERY PLAN                   
------------------------------------------------
+                   QUERY PLAN                    
+-------------------------------------------------
  Merge Join
-   Merge Cond: (public.t1.id = t2.id)
+   Merge Cond: (t1.id = t2.id)
    ->  Merge Join
-         Merge Cond: (public.t1.id = s0.t1.id)
-         ->  Index Scan using t1_pkey on t1
+         Merge Cond: (t1.id = t1_1.id)
          ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t1_pkey on t1 t1_1
    ->  Index Scan using t2_pkey on t2
 (7 rows)
 
 /*+NestLoop(t1 t2)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id;
-INFO:  hint syntax error at or near "NestLoop(t1 t2)"
+INFO:  pg_hint_plan: hint syntax error at or near "NestLoop(t1 t2)"
 DETAIL:  Relation name "t1" is ambiguous.
 LOG:  pg_hint_plan:
 used hint:
@@ -5196,20 +5300,20 @@ duplication hint:
 error hint:
 NestLoop(t1 t2)
 
-                  QUERY PLAN                   
------------------------------------------------
+                   QUERY PLAN                    
+-------------------------------------------------
  Merge Join
-   Merge Cond: (public.t1.id = t2.id)
+   Merge Cond: (t1.id = t2.id)
    ->  Merge Join
-         Merge Cond: (public.t1.id = s0.t1.id)
-         ->  Index Scan using t1_pkey on t1
+         Merge Cond: (t1.id = t1_1.id)
          ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t1_pkey on t1 t1_1
    ->  Index Scan using t2_pkey on t2
 (7 rows)
 
 /*+Leading(t1 t2 t1)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id;
-INFO:  hint syntax error at or near "Leading(t1 t2 t1)"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(t1 t2 t1)"
 DETAIL:  Relation name "t1" is ambiguous.
 LOG:  pg_hint_plan:
 used hint:
@@ -5218,14 +5322,14 @@ duplication hint:
 error hint:
 Leading(t1 t2 t1)
 
-                  QUERY PLAN                   
------------------------------------------------
+                   QUERY PLAN                    
+-------------------------------------------------
  Merge Join
-   Merge Cond: (public.t1.id = t2.id)
+   Merge Cond: (t1.id = t2.id)
    ->  Merge Join
-         Merge Cond: (public.t1.id = s0.t1.id)
-         ->  Index Scan using t1_pkey on t1
+         Merge Cond: (t1.id = t1_1.id)
          ->  Index Scan using t1_pkey on t1
+         ->  Index Scan using t1_pkey on t1 t1_1
    ->  Index Scan using t2_pkey on t2
 (7 rows)
 
@@ -5329,7 +5433,7 @@ ERROR:  1.23457e+63 is outside the valid range for parameter "cursor_tuple_fract
 /*+ Set(enable_seqscan 100)Set(seq_page_cost on)*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;
 INFO:  parameter "enable_seqscan" requires a Boolean value
-INFO:  parameter "seq_page_cost" requires a numeric value
+INFO:  invalid value for parameter "seq_page_cost": "on"
 LOG:  pg_hint_plan:
 used hint:
 not used hint:
@@ -5452,7 +5556,7 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val =
 
 /*+Leading((t1))*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
-INFO:  hint syntax error at or near "Leading((t1))"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading((t1))"
 DETAIL:  Leading hint requires two sets of relations when parentheses nests.
 LOG:  pg_hint_plan:
 used hint:
@@ -5499,7 +5603,7 @@ error hint:
 
 /*+Leading((t1 t2 t3))*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10;
-INFO:  hint syntax error at or near "Leading((t1 t2 t3))"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading((t1 t2 t3))"
 DETAIL:  Leading hint requires two sets of relations when parentheses nests.
 LOG:  pg_hint_plan:
 used hint:
@@ -5764,7 +5868,7 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val =
 
 /*+Leading(((t1 t2) t3)) Leading(((t3 t1) t2))*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t1.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1);
-INFO:  hint syntax error at or near "Leading(((t1 t2) t3)) Leading(((t3 t1) t2))"
+INFO:  pg_hint_plan: hint syntax error at or near "Leading(((t1 t2) t3)) Leading(((t3 t1) t2))"
 DETAIL:  Conflict leading hint.
 LOG:  pg_hint_plan:
 used hint:
@@ -5987,6 +6091,7 @@ error hint:
                     QUERY PLAN                    
 --------------------------------------------------
  Nested Loop
+   Join Filter: (t3.id = t4.id)
    ->  Nested Loop
          Join Filter: (t1.val = t3.val)
          ->  Hash Join
@@ -5996,8 +6101,7 @@ error hint:
                ->  Hash
                      ->  Seq Scan on t2
          ->  Seq Scan on t3
-   ->  Index Scan using t4_pkey on t4
-         Index Cond: (id = t3.id)
+   ->  Seq Scan on t4
 (12 rows)
 
 /*+Leading(((t1 t2) t3)) MergeJoin(t1 t2 t3 t4)*/
@@ -6248,13 +6352,15 @@ error hint:
                      Merge Cond: (t1.id = t2.id)
                      ->  Index Scan using t1_pkey on t1
                      ->  Index Scan using t2_pkey on t2
-               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t3.id
+                     ->  Seq Scan on t3
          ->  Sort
                Sort Key: t4.id
                ->  Seq Scan on t4
    ->  Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
          Index Cond: (id = t1.id)
-(15 rows)
+(17 rows)
 
 /*+Leading(((((t5 t4)t3)t2)t1))*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id;
@@ -6336,13 +6442,15 @@ error hint:
    ->  Materialize
          ->  Merge Join
                Merge Cond: (t3.id = t1.id)
-               ->  Index Scan using t3_pkey on t3
+               ->  Sort
+                     Sort Key: t3.id
+                     ->  Seq Scan on t3
                ->  Materialize
                      ->  Merge Join
                            Merge Cond: (t2.id = t1.id)
                            ->  Index Scan using t2_pkey on t2
                            ->  Index Scan using t1_pkey on t1
-(17 rows)
+(19 rows)
 
 /*+Leading((((t1 t2)t3)(t4 t5)))*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id;
@@ -6363,13 +6471,15 @@ error hint:
                Merge Cond: (t1.id = t2.id)
                ->  Index Scan using t1_pkey on t1
                ->  Index Scan using t2_pkey on t2
-         ->  Index Scan using t3_pkey on t3
+         ->  Sort
+               Sort Key: t3.id
+               ->  Seq Scan on t3
    ->  Materialize
          ->  Merge Join
                Merge Cond: (t4.id = t5.id)
                ->  Index Scan using t4_pkey on t4
                ->  Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5
-(14 rows)
+(16 rows)
 
 /*+Leading((((t5 t4)t3)(t2 t1)))*/
 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id;
@@ -6405,29 +6515,22 @@ EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid =
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Seq Scan on p2
+   ->  Seq Scan on p2 p2_1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c1 p2
+   ->  Seq Scan on p2_c1 p2_2
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-(11 rows)
+   ->  Seq Scan on p2_c1_c1 p2_3
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_4
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(9 rows)
 
 /*+IndexScan(p2 p2_pkey)*/
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_pkey
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_pkey
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3): p2_c3_pkey
-LOG:  available indexes for IndexScan(p2_c4): p2_c4_pkey
 LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey
 LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_pkey
-LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_pkey
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_pkey)
@@ -6435,19 +6538,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p2_pkey on p2
+   ->  Index Scan using p2_pkey on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_pkey on p2_c1 p2
+   ->  Index Scan using p2_c1_pkey on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -6456,13 +6559,8 @@ error hint:
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_id_val_idx
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_id_val_idx
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_id_val_idx
-LOG:  available indexes for IndexScan(p2_c3): p2_c3_id_val_idx
-LOG:  available indexes for IndexScan(p2_c4): p2_c4_id_val_idx
 LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_id_val_idx
 LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_id_val_idx
-LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_id_val_idx
-LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_id_val_idx
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_id_val_idx)
@@ -6470,19 +6568,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                       QUERY PLAN                       
---------------------------------------------------------
+                         QUERY PLAN                          
+-------------------------------------------------------------
  Append
-   ->  Index Scan using p2_id_val_idx on p2
+   ->  Index Scan using p2_id_val_idx on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2
+   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -6491,13 +6589,8 @@ error hint:
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_val_id_idx
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_val_id_idx
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_val_id_idx
-LOG:  available indexes for IndexScan(p2_c3): p2_c3_val_id_idx
-LOG:  available indexes for IndexScan(p2_c4):
 LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_val_id_idx
 LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_val_id_idx
-LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_val_id_idx
-LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_val_id_idx
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_val_id_idx)
@@ -6505,19 +6598,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                       QUERY PLAN                       
---------------------------------------------------------
+                         QUERY PLAN                          
+-------------------------------------------------------------
  Append
-   ->  Index Scan using p2_val_id_idx on p2
+   ->  Index Scan using p2_val_id_idx on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_val_id_idx on p2_c1 p2
+   ->  Index Scan using p2_c1_val_id_idx on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_val_id_idx on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_val_id_idx on p2_c1_c1 p2_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_val_id_idx on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_val_id_idx on p2_c1_c2 p2_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -6526,32 +6619,29 @@ EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p
                                        QUERY PLAN                                        
 -----------------------------------------------------------------------------------------
  Append
-   ->  Seq Scan on p2
+   ->  Seq Scan on p2 p2_1
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c1 p2
+   ->  Seq Scan on p2_c1 p2_2
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c2 p2
+   ->  Seq Scan on p2_c2 p2_3
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c3 p2
+   ->  Seq Scan on p2_c3 p2_4
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Tid Scan on p2_c4 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c3_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c3_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-(24 rows)
+   ->  Seq Scan on p2_c4 p2_5
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c1 p2_6
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_7
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c3_c1 p2_8
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c3_c2 p2_9
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+(19 rows)
 
-/*+IndexScan(p2 p2_val)*/
+-- Inhibit parallel exection to avoid interfaring the hint
+set max_parallel_workers_per_gather to 0;
+/*+ IndexScan(p2 p2_val)*/
 EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2):
 LOG:  available indexes for IndexScan(p2_c1):
@@ -6572,42 +6662,32 @@ error hint:
                                        QUERY PLAN                                        
 -----------------------------------------------------------------------------------------
  Append
-   ->  Seq Scan on p2
+   ->  Seq Scan on p2 p2_1
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c1 p2
+   ->  Seq Scan on p2_c1 p2_2
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c2 p2
+   ->  Seq Scan on p2_c2 p2_3
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c3 p2
+   ->  Seq Scan on p2_c3 p2_4
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Tid Scan on p2_c4 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c3_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c3_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-(24 rows)
+   ->  Seq Scan on p2_c4 p2_5
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c1 p2_6
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_7
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c3_c1 p2_8
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c3_c2 p2_9
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+(19 rows)
 
 /*+IndexScan(p2 p2_pkey)*/
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_pkey
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_pkey
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3): p2_c3_pkey
-LOG:  available indexes for IndexScan(p2_c4): p2_c4_pkey
 LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey
 LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_pkey
-LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_pkey
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_pkey)
@@ -6615,19 +6695,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p2_pkey on p2
+   ->  Index Scan using p2_pkey on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_pkey on p2_c1 p2
+   ->  Index Scan using p2_c1_pkey on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -6636,13 +6716,8 @@ error hint:
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_id2_val
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_id2_val
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_id2_val
-LOG:  available indexes for IndexScan(p2_c3):
-LOG:  available indexes for IndexScan(p2_c4):
 LOG:  available indexes for IndexScan(p2_c1_c1):
 LOG:  available indexes for IndexScan(p2_c1_c2):
-LOG:  available indexes for IndexScan(p2_c3_c1):
-LOG:  available indexes for IndexScan(p2_c3_c2):
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_id2_val)
@@ -6650,34 +6725,27 @@ not used hint:
 duplication hint:
 error hint:
 
-                   QUERY PLAN                    
--------------------------------------------------
+                              QUERY PLAN                               
+-----------------------------------------------------------------------
  Append
-   ->  Index Scan using p2_id2_val on p2
+   ->  Index Scan using p2_id2_val on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_id2_val on p2_c1 p2
+   ->  Index Scan using p2_c1_id2_val on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-(13 rows)
+   ->  Seq Scan on p2_c1_c1 p2_3
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_4
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(11 rows)
 
 /*+IndexScan(p2 p2_val2_id)*/
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_val2_id
 LOG:  available indexes for IndexScan(p2_c1):
-LOG:  available indexes for IndexScan(p2_c2):
-LOG:  available indexes for IndexScan(p2_c3):
-LOG:  available indexes for IndexScan(p2_c4):
 LOG:  available indexes for IndexScan(p2_c1_c1):
 LOG:  available indexes for IndexScan(p2_c1_c2):
-LOG:  available indexes for IndexScan(p2_c3_c1):
-LOG:  available indexes for IndexScan(p2_c3_c2):
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_val2_id)
@@ -6688,30 +6756,23 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Index Scan using p2_val2_id on p2
+   ->  Index Scan using p2_val2_id on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Seq Scan on p2_c1 p2
+   ->  Seq Scan on p2_c1 p2_2
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-(12 rows)
+   ->  Seq Scan on p2_c1_c1 p2_3
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_4
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(10 rows)
 
 /*+IndexScan(p2 p2_pkey)*/
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_pkey
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_pkey
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3): p2_c3_pkey
-LOG:  available indexes for IndexScan(p2_c4): p2_c4_pkey
 LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey
 LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_pkey
-LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_pkey
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_pkey)
@@ -6719,19 +6780,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p2_pkey on p2
+   ->  Index Scan using p2_pkey on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_pkey on p2_c1 p2
+   ->  Index Scan using p2_c1_pkey on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -6740,13 +6801,8 @@ error hint:
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2):
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_id_val_idx
-LOG:  available indexes for IndexScan(p2_c2):
-LOG:  available indexes for IndexScan(p2_c3):
-LOG:  available indexes for IndexScan(p2_c4):
 LOG:  available indexes for IndexScan(p2_c1_c1):
 LOG:  available indexes for IndexScan(p2_c1_c2):
-LOG:  available indexes for IndexScan(p2_c3_c1):
-LOG:  available indexes for IndexScan(p2_c3_c2):
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_c1_id_val_idx)
@@ -6757,30 +6813,23 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Seq Scan on p2
+   ->  Seq Scan on p2 p2_1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2
+   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-(12 rows)
+   ->  Seq Scan on p2_c1_c1 p2_3
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_4
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(10 rows)
 
 /*+IndexScan(p2 no_exist)*/
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2):
 LOG:  available indexes for IndexScan(p2_c1):
-LOG:  available indexes for IndexScan(p2_c2):
-LOG:  available indexes for IndexScan(p2_c3):
-LOG:  available indexes for IndexScan(p2_c4):
 LOG:  available indexes for IndexScan(p2_c1_c1):
 LOG:  available indexes for IndexScan(p2_c1_c2):
-LOG:  available indexes for IndexScan(p2_c3_c1):
-LOG:  available indexes for IndexScan(p2_c3_c2):
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 no_exist)
@@ -6791,29 +6840,22 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Seq Scan on p2
+   ->  Seq Scan on p2 p2_1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c1 p2
+   ->  Seq Scan on p2_c1 p2_2
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-(11 rows)
+   ->  Seq Scan on p2_c1_c1 p2_3
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_4
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(9 rows)
 
 /*+IndexScan(p2 p2_pkey p2_c1_id_val_idx)*/
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_pkey
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_id_val_idx p2_c1_pkey
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3): p2_c3_pkey
-LOG:  available indexes for IndexScan(p2_c4): p2_c4_pkey
 LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey
 LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_pkey
-LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_pkey
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_pkey p2_c1_id_val_idx)
@@ -6821,19 +6863,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p2_pkey on p2
+   ->  Index Scan using p2_pkey on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2
+   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -6842,13 +6884,8 @@ error hint:
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_pkey
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_pkey
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3): p2_c3_pkey
-LOG:  available indexes for IndexScan(p2_c4): p2_c4_pkey
 LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey
 LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_pkey
-LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_pkey
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_pkey no_exist)
@@ -6856,19 +6893,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p2_pkey on p2
+   ->  Index Scan using p2_pkey on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_pkey on p2_c1 p2
+   ->  Index Scan using p2_c1_pkey on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -6877,13 +6914,8 @@ error hint:
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2):
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_id_val_idx
-LOG:  available indexes for IndexScan(p2_c2):
-LOG:  available indexes for IndexScan(p2_c3):
-LOG:  available indexes for IndexScan(p2_c4):
 LOG:  available indexes for IndexScan(p2_c1_c1):
 LOG:  available indexes for IndexScan(p2_c1_c2):
-LOG:  available indexes for IndexScan(p2_c3_c1):
-LOG:  available indexes for IndexScan(p2_c3_c2):
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_c1_id_val_idx no_exist)
@@ -6894,30 +6926,23 @@ error hint:
                               QUERY PLAN                               
 -----------------------------------------------------------------------
  Append
-   ->  Seq Scan on p2
+   ->  Seq Scan on p2 p2_1
          Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2
+   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((id >= 50) AND (id <= 51))
-(12 rows)
+   ->  Seq Scan on p2_c1_c1 p2_3
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_4
+         Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
+(10 rows)
 
 /*+IndexScan(p2 p2_pkey p2_c1_id_val_idx no_exist)*/
 EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)';
 LOG:  available indexes for IndexScan(p2): p2_pkey
 LOG:  available indexes for IndexScan(p2_c1): p2_c1_id_val_idx p2_c1_pkey
-LOG:  available indexes for IndexScan(p2_c2): p2_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3): p2_c3_pkey
-LOG:  available indexes for IndexScan(p2_c4): p2_c4_pkey
 LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey
 LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey
-LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_pkey
-LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_pkey
 LOG:  pg_hint_plan:
 used hint:
 IndexScan(p2 p2_pkey p2_c1_id_val_idx no_exist)
@@ -6925,19 +6950,19 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p2_pkey on p2
+   ->  Index Scan using p2_pkey on p2 p2_1
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2
+   ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2_2
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4
          Index Cond: ((id >= 50) AND (id <= 51))
          Filter: (ctid = '(1,1)'::tid)
 (13 rows)
@@ -6963,31 +6988,31 @@ error hint:
                             QUERY PLAN                             
 -------------------------------------------------------------------
  Append
-   ->  Index Scan using p2_val_idx on p2
+   ->  Index Scan using p2_val_idx on p2 p2_1
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_val_idx on p2_c1 p2
+   ->  Index Scan using p2_c1_val_idx on p2_c1 p2_2
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c2_val_idx on p2_c2 p2
+   ->  Index Scan using p2_c2_val_idx on p2_c2 p2_3
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c3_val_idx on p2_c3 p2
+   ->  Index Scan using p2_c3_val_idx on p2_c3 p2_4
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c4_val_idx on p2_c4 p2
+   ->  Index Scan using p2_c4_val_idx on p2_c4 p2_5
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_val_idx on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_val_idx on p2_c1_c1 p2_6
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_val_idx on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_val_idx on p2_c1_c2 p2_7
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c3_c1_val_idx on p2_c3_c1 p2
+   ->  Index Scan using p2_c3_c1_val_idx on p2_c3_c1 p2_8
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c3_c2_val_idx on p2_c3_c2 p2
+   ->  Index Scan using p2_c3_c2_val_idx on p2_c3_c2 p2_9
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
 (28 rows)
@@ -7013,30 +7038,25 @@ error hint:
                                        QUERY PLAN                                        
 -----------------------------------------------------------------------------------------
  Append
-   ->  Seq Scan on p2
+   ->  Seq Scan on p2 p2_1
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c1 p2
+   ->  Seq Scan on p2_c1 p2_2
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c2 p2
+   ->  Seq Scan on p2_c2 p2_3
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c3 p2
+   ->  Seq Scan on p2_c3 p2_4
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Tid Scan on p2_c4 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c3_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c3_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-(24 rows)
+   ->  Seq Scan on p2_c4 p2_5
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c1 p2_6
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_7
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c3_c1 p2_8
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c3_c2 p2_9
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+(19 rows)
 
 /*+IndexScan(p2 p2_val_idx6)*/
 EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)';
@@ -7059,30 +7079,25 @@ error hint:
                                        QUERY PLAN                                        
 -----------------------------------------------------------------------------------------
  Append
-   ->  Seq Scan on p2
+   ->  Seq Scan on p2 p2_1
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c1 p2
+   ->  Seq Scan on p2_c1 p2_2
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c2 p2
+   ->  Seq Scan on p2_c2 p2_3
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Seq Scan on p2_c3 p2
+   ->  Seq Scan on p2_c3 p2_4
          Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
-   ->  Tid Scan on p2_c4 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c1_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c1_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c3_c1 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-   ->  Tid Scan on p2_c3_c2 p2
-         TID Cond: (ctid = '(1,1)'::tid)
-         Filter: ((val >= '50'::text) AND (val <= '51'::text))
-(24 rows)
+   ->  Seq Scan on p2_c4 p2_5
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c1 p2_6
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c1_c2 p2_7
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c3_c1 p2_8
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+   ->  Seq Scan on p2_c3_c2 p2_9
+         Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
+(19 rows)
 
 /*+IndexScan(p2 p2_val_idx p2_val_idx6)*/
 EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)';
@@ -7105,31 +7120,31 @@ error hint:
                             QUERY PLAN                             
 -------------------------------------------------------------------
  Append
-   ->  Index Scan using p2_val_idx on p2
+   ->  Index Scan using p2_val_idx on p2 p2_1
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_val_idx on p2_c1 p2
+   ->  Index Scan using p2_c1_val_idx on p2_c1 p2_2
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c2_val_idx on p2_c2 p2
+   ->  Index Scan using p2_c2_val_idx on p2_c2 p2_3
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c3_val_idx on p2_c3 p2
+   ->  Index Scan using p2_c3_val_idx on p2_c3 p2_4
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c4_val_idx on p2_c4 p2
+   ->  Index Scan using p2_c4_val_idx on p2_c4 p2_5
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c1_val_idx on p2_c1_c1 p2
+   ->  Index Scan using p2_c1_c1_val_idx on p2_c1_c1 p2_6
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c1_c2_val_idx on p2_c1_c2 p2
+   ->  Index Scan using p2_c1_c2_val_idx on p2_c1_c2 p2_7
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c3_c1_val_idx on p2_c3_c1 p2
+   ->  Index Scan using p2_c3_c1_val_idx on p2_c3_c1 p2_8
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
-   ->  Index Scan using p2_c3_c2_val_idx on p2_c3_c2 p2
+   ->  Index Scan using p2_c3_c2_val_idx on p2_c3_c2 p2_9
          Index Cond: ((val >= '50'::text) AND (val <= '51'::text))
          Filter: (ctid = '(1,1)'::tid)
 (28 rows)
@@ -7389,26 +7404,26 @@ error hint:
 
 -- Inheritance
 EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1;
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7430,26 +7445,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7471,26 +7486,26 @@ not used hint:
 duplication hint:
 error hint:
 
-                    QUERY PLAN                    
---------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Append
-   ->  Index Scan using p1_val2 on p1
+   ->  Index Scan using p1_val2 on p1 p1_1
          Index Cond: (val = 1)
-   ->  Index Scan using p1_c1_val2 on p1_c1 p1
+   ->  Index Scan using p1_c1_val2 on p1_c1 p1_2
          Index Cond: (val = 1)
-   ->  Index Scan using p1_c2_val2 on p1_c2 p1
+   ->  Index Scan using p1_c2_val2 on p1_c2 p1_3
          Index Cond: (val = 1)
-   ->  Index Scan using p1_c3_val2 on p1_c3 p1
+   ->  Index Scan using p1_c3_val2 on p1_c3 p1_4
          Index Cond: (val = 1)
-   ->  Index Scan using p1_c4_val2 on p1_c4 p1
+   ->  Index Scan using p1_c4_val2 on p1_c4 p1_5
          Index Cond: (val = 1)
-   ->  Index Scan using p1_c1_c1_val2 on p1_c1_c1 p1
+   ->  Index Scan using p1_c1_c1_val2 on p1_c1_c1 p1_6
          Index Cond: (val = 1)
-   ->  Index Scan using p1_c1_c2_val2 on p1_c1_c2 p1
+   ->  Index Scan using p1_c1_c2_val2 on p1_c1_c2 p1_7
          Index Cond: (val = 1)
-   ->  Index Scan using p1_c3_c1_val2 on p1_c3_c1 p1
+   ->  Index Scan using p1_c3_c1_val2 on p1_c3_c1 p1_8
          Index Cond: (val = 1)
-   ->  Index Scan using p1_c3_c2_val2 on p1_c3_c2 p1
+   ->  Index Scan using p1_c3_c2_val2 on p1_c3_c2 p1_9
          Index Cond: (val = 1)
 (19 rows)
 
@@ -7512,26 +7527,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7553,26 +7568,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7594,26 +7609,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7635,26 +7650,26 @@ not used hint:
 duplication hint:
 error hint:
 
-                      QUERY PLAN                       
--------------------------------------------------------
+                         QUERY PLAN                         
+------------------------------------------------------------
  Append
-   ->  Index Only Scan using p1_val2 on p1
+   ->  Index Only Scan using p1_val2 on p1 p1_1
          Index Cond: (val = 1)
-   ->  Index Only Scan using p1_c1_val2 on p1_c1 p1
+   ->  Index Only Scan using p1_c1_val2 on p1_c1 p1_2
          Index Cond: (val = 1)
-   ->  Index Only Scan using p1_c2_val2 on p1_c2 p1
+   ->  Index Only Scan using p1_c2_val2 on p1_c2 p1_3
          Index Cond: (val = 1)
-   ->  Index Only Scan using p1_c3_val2 on p1_c3 p1
+   ->  Index Only Scan using p1_c3_val2 on p1_c3 p1_4
          Index Cond: (val = 1)
-   ->  Index Only Scan using p1_c4_val2 on p1_c4 p1
+   ->  Index Only Scan using p1_c4_val2 on p1_c4 p1_5
          Index Cond: (val = 1)
-   ->  Index Only Scan using p1_c1_c1_val2 on p1_c1_c1 p1
+   ->  Index Only Scan using p1_c1_c1_val2 on p1_c1_c1 p1_6
          Index Cond: (val = 1)
-   ->  Index Only Scan using p1_c1_c2_val2 on p1_c1_c2 p1
+   ->  Index Only Scan using p1_c1_c2_val2 on p1_c1_c2 p1_7
          Index Cond: (val = 1)
-   ->  Index Only Scan using p1_c3_c1_val2 on p1_c3_c1 p1
+   ->  Index Only Scan using p1_c3_c1_val2 on p1_c3_c1 p1_8
          Index Cond: (val = 1)
-   ->  Index Only Scan using p1_c3_c2_val2 on p1_c3_c2 p1
+   ->  Index Only Scan using p1_c3_c2_val2 on p1_c3_c2 p1_9
          Index Cond: (val = 1)
 (19 rows)
 
@@ -7676,26 +7691,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7717,26 +7732,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7758,26 +7773,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7802,39 +7817,39 @@ error hint:
                    QUERY PLAN                   
 ------------------------------------------------
  Append
-   ->  Bitmap Heap Scan on p1
+   ->  Bitmap Heap Scan on p1 p1_1
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_val2
                Index Cond: (val = 1)
-   ->  Bitmap Heap Scan on p1_c1 p1
+   ->  Bitmap Heap Scan on p1_c1 p1_2
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_c1_val2
                Index Cond: (val = 1)
-   ->  Bitmap Heap Scan on p1_c2 p1
+   ->  Bitmap Heap Scan on p1_c2 p1_3
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_c2_val2
                Index Cond: (val = 1)
-   ->  Bitmap Heap Scan on p1_c3 p1
+   ->  Bitmap Heap Scan on p1_c3 p1_4
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_c3_val2
                Index Cond: (val = 1)
-   ->  Bitmap Heap Scan on p1_c4 p1
+   ->  Bitmap Heap Scan on p1_c4 p1_5
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_c4_val2
                Index Cond: (val = 1)
-   ->  Bitmap Heap Scan on p1_c1_c1 p1
+   ->  Bitmap Heap Scan on p1_c1_c1 p1_6
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_c1_c1_val2
                Index Cond: (val = 1)
-   ->  Bitmap Heap Scan on p1_c1_c2 p1
+   ->  Bitmap Heap Scan on p1_c1_c2 p1_7
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_c1_c2_val2
                Index Cond: (val = 1)
-   ->  Bitmap Heap Scan on p1_c3_c1 p1
+   ->  Bitmap Heap Scan on p1_c3_c1 p1_8
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_c3_c1_val2
                Index Cond: (val = 1)
-   ->  Bitmap Heap Scan on p1_c3_c2 p1
+   ->  Bitmap Heap Scan on p1_c3_c2 p1_9
          Recheck Cond: (val = 1)
          ->  Bitmap Index Scan on p1_c3_c2_val2
                Index Cond: (val = 1)
@@ -7858,26 +7873,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7899,26 +7914,26 @@ not used hint:
 duplication hint:
 error hint:
 
-         QUERY PLAN         
-----------------------------
+           QUERY PLAN            
+---------------------------------
  Append
-   ->  Seq Scan on p1
+   ->  Seq Scan on p1 p1_1
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1 p1
+   ->  Seq Scan on p1_c1 p1_2
          Filter: (val = 1)
-   ->  Seq Scan on p1_c2 p1
+   ->  Seq Scan on p1_c2 p1_3
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3 p1
+   ->  Seq Scan on p1_c3 p1_4
          Filter: (val = 1)
-   ->  Seq Scan on p1_c4 p1
+   ->  Seq Scan on p1_c4 p1_5
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c1 p1
+   ->  Seq Scan on p1_c1_c1 p1_6
          Filter: (val = 1)
-   ->  Seq Scan on p1_c1_c2 p1
+   ->  Seq Scan on p1_c1_c2 p1_7
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c1 p1
+   ->  Seq Scan on p1_c3_c1 p1_8
          Filter: (val = 1)
-   ->  Seq Scan on p1_c3_c2 p1
+   ->  Seq Scan on p1_c3_c2 p1_9
          Filter: (val = 1)
 (19 rows)
 
@@ -7967,14 +7982,16 @@ EXPLAIN (COSTS false) SELECT id FROM t1 WHERE t1.id = 1;
    Index Cond: (id = 1)
 (2 rows)
 
-DO LANGUAGE plpgsql $$
+-- static function
+CREATE FUNCTION testfunc() RETURNS RECORD AS $$
 DECLARE
-    id integer;
+  ret record;
 BEGIN
-       SELECT /*+SeqScan(t1)*/ t1.id INTO id FROM t1 WHERE t1.id = 1;
-       RETURN;
+  SELECT /*+ SeqScan(t1) */ * INTO ret FROM t1 LIMIT 1;
+  RETURN ret;
 END;
-$$;
+$$ LANGUAGE plpgsql;
+SELECT testfunc();
 LOG:  pg_hint_plan:
 used hint:
 SeqScan(t1)
@@ -7982,6 +7999,1120 @@ not used hint:
 duplication hint:
 error hint:
 
-CONTEXT:  SQL statement "SELECT /*+SeqScan(t1)*/ t1.id         FROM t1 WHERE t1.id = 1"
-PL/pgSQL function inline_code_block line 5 at SQL statement
+CONTEXT:  SQL statement "SELECT /*+ SeqScan(t1) */ *          FROM t1 LIMIT 1"
+PL/pgSQL function testfunc() line 5 at SQL statement
+ testfunc 
+----------
+ (1,1)
+(1 row)
+
+-- dynamic function
+DROP FUNCTION testfunc();
+CREATE FUNCTION testfunc() RETURNS void AS $$
+BEGIN
+  EXECUTE format('/*+ SeqScan(t1) */ SELECT * FROM t1');
+END;
+$$ LANGUAGE plpgsql;
+SELECT testfunc();
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "/*+ SeqScan(t1) */ SELECT * FROM t1"
+PL/pgSQL function testfunc() line 3 at EXECUTE
+ testfunc 
+----------
+(1 row)
+
+-- This should not use SeqScan(t1)
+/*+ IndexScan(t1) */ SELECT * from t1 LIMIT 1;
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+ id | val 
+----+-----
+  1 |   1
+(1 row)
+
+-- Perform
+DROP FUNCTION testfunc();
+CREATE FUNCTION testfunc() RETURNS void AS $$
+BEGIN
+  PERFORM  1, /*+ SeqScan(t1) */ * from t1;
+END;
+$$ LANGUAGE plpgsql;
+SELECT testfunc();
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "SELECT 1, /*+ SeqScan(t1) */ * from t1"
+PL/pgSQL function testfunc() line 3 at PERFORM
+ testfunc 
+----------
+(1 row)
+
+-- FOR loop
+DROP FUNCTION testfunc();
+CREATE FUNCTION testfunc() RETURNS int AS $$
+DECLARE
+  sum int;
+  v int;
+BEGIN
+  sum := 0;
+  FOR v IN SELECT /*+ SeqScan(t1) */ v FROM t1 ORDER BY id LOOP
+    sum := sum + v;
+  END LOOP;
+  RETURN v;
+END;
+$$ LANGUAGE plpgsql;
+SELECT testfunc();
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "SELECT /*+ SeqScan(t1) */ v FROM t1 ORDER BY id"
+PL/pgSQL function testfunc() line 7 at FOR over SELECT rows
+ testfunc 
+----------
+         
+(1 row)
+
+-- Dynamic FOR loop
+DROP FUNCTION testfunc();
+CREATE FUNCTION testfunc() RETURNS int AS $$
+DECLARE
+  sum int;
+  v int;
+  i   int;
+BEGIN
+  sum := 0;
+  FOR v IN EXECUTE 'SELECT /*+ SeqScan(t1) */ val FROM t1 ORDER BY id' LOOP
+    sum := sum + v;
+  END LOOP;
+  RETURN v;
+END;
+$$ LANGUAGE plpgsql;
+SELECT testfunc();
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "SELECT /*+ SeqScan(t1) */ val FROM t1 ORDER BY id"
+PL/pgSQL function testfunc() line 8 at FOR over EXECUTE statement
+ testfunc 
+----------
+        0
+(1 row)
+
+-- Cursor FOR loop
+DROP FUNCTION testfunc();
+CREATE FUNCTION testfunc() RETURNS int AS $$
+DECLARE
+  ref CURSOR FOR SELECT /*+ SeqScan(t1) */ * FROM t1 ORDER BY id;
+  rec record;
+  sum int := 0;
+BEGIN
+  FOR rec IN ref LOOP
+    sum := sum + rec.val;
+  END LOOP;
+  RETURN sum;
+END;
+$$ LANGUAGE plpgsql;
+SELECT testfunc();
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "SELECT /*+ SeqScan(t1) */ * FROM t1 ORDER BY id"
+PL/pgSQL function testfunc() line 7 at FOR over cursor
+ testfunc 
+----------
+   495000
+(1 row)
+
+-- RETURN QUERY
+DROP FUNCTION testfunc();
+CREATE FUNCTION testfunc() RETURNS SETOF t1 AS $$
+BEGIN
+  RETURN QUERY SELECT /*+ SeqScan(t1) */ * FROM t1 ORDER BY id;
+END;
+$$ LANGUAGE plpgsql;
+SELECT * FROM testfunc() LIMIT 1;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "SELECT /*+ SeqScan(t1) */ * FROM t1 ORDER BY id"
+PL/pgSQL function testfunc() line 3 at RETURN QUERY
+ id | val 
+----+-----
+  1 |   1
+(1 row)
+
+-- Test for error exit from inner SQL statement.
+DROP FUNCTION testfunc();
+CREATE FUNCTION testfunc() RETURNS SETOF t1 AS $$
+BEGIN
+  RETURN QUERY SELECT /*+ SeqScan(t1) */ * FROM ttx ORDER BY id;
+END;
+$$ LANGUAGE plpgsql;
+SELECT * FROM testfunc() LIMIT 1;
+ERROR:  relation "ttx" does not exist
+LINE 1: SELECT /*+ SeqScan(t1) */ * FROM ttx ORDER BY id
+                                         ^
+QUERY:  SELECT /*+ SeqScan(t1) */ * FROM ttx ORDER BY id
+CONTEXT:  PL/pgSQL function testfunc() line 3 at RETURN QUERY
+-- this should not use SeqScan(t1) hint.
+/*+ IndexScan(t1) */ SELECT * from t1 LIMIT 1;
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+ id | val 
+----+-----
+  1 |   1
+(1 row)
+
+DROP FUNCTION testfunc();
 DROP EXTENSION pg_hint_plan;
+CREATE FUNCTION reset_stats_and_wait() RETURNS void AS $$
+DECLARE
+  rows int;
+BEGIN
+  rows = 1;
+  while rows > 0 LOOP
+   PERFORM pg_stat_reset();
+   PERFORM pg_sleep(0.5);
+   SELECT sum(seq_scan + idx_scan) from pg_stat_user_tables into rows;
+  END LOOP;
+END;
+$$ LANGUAGE plpgsql;
+-- Dynamic query in pl/pgsql
+CREATE OR REPLACE FUNCTION dynsql1(x int) RETURNS int AS $$
+DECLARE c int;
+BEGIN
+  EXECUTE '/*+ IndexScan(t1) */ SELECT count(*) FROM t1 WHERE id < $1'
+       INTO c USING x;
+  RETURN c;
+END;
+$$ VOLATILE LANGUAGE plpgsql;
+vacuum analyze t1;
+SET pg_hint_plan.enable_hint = false;
+SELECT pg_sleep(1);
+ pg_sleep 
+----------
+(1 row)
+
+SELECT reset_stats_and_wait();
+ reset_stats_and_wait 
+----------------------
+(1 row)
+
+SELECT dynsql1(9000);
+ dynsql1 
+---------
+    8999
+(1 row)
+
+SELECT pg_sleep(1);
+ pg_sleep 
+----------
+(1 row)
+
+SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1';
+ relname | seq_scan | idx_scan 
+---------+----------+----------
+ t1      | t        | f
+(1 row)
+
+SET pg_hint_plan.enable_hint = true;
+SELECT reset_stats_and_wait();
+ reset_stats_and_wait 
+----------------------
+(1 row)
+
+SELECT dynsql1(9000);
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "/*+ IndexScan(t1) */ SELECT count(*) FROM t1 WHERE id < $1"
+PL/pgSQL function dynsql1(integer) line 4 at EXECUTE
+ dynsql1 
+---------
+    8999
+(1 row)
+
+SELECT pg_sleep(1);
+ pg_sleep 
+----------
+(1 row)
+
+SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1';
+ relname | seq_scan | idx_scan 
+---------+----------+----------
+ t1      | f        | t
+(1 row)
+
+-- Looped dynamic query in pl/pgsql
+CREATE OR REPLACE FUNCTION dynsql2(x int, OUT r int) AS $$
+DECLARE
+  c text;
+  s int;
+BEGIN
+  r := 0;
+  FOR c IN SELECT f.f FROM (VALUES ('p1_c1'), ('p1_c2')) f(f) LOOP
+    FOR s IN EXECUTE '/*+ IndexScan(' || c || ' ' || c || '_pkey) */ SELECT sum(val) FROM ' || c || ' WHERE id < ' || x LOOP
+      r := r + s;
+    END LOOP;
+  END LOOP;
+END;
+$$ VOLATILE LANGUAGE plpgsql;
+SET pg_hint_plan.enable_hint = false;
+SELECT reset_stats_and_wait();
+ reset_stats_and_wait 
+----------------------
+(1 row)
+
+SELECT dynsql2(9000);
+ dynsql2 
+---------
+    9900
+(1 row)
+
+SELECT pg_sleep(1);
+ pg_sleep 
+----------
+(1 row)
+
+-- one of the index scans happened while planning.
+SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2');
+ relname | seq_scan | idx_scan 
+---------+----------+----------
+ p1_c1   |        1 |        0
+ p1_c2   |        1 |        1
+(2 rows)
+
+SET pg_hint_plan.enable_hint = true;
+SELECT reset_stats_and_wait();
+ reset_stats_and_wait 
+----------------------
+(1 row)
+
+SELECT dynsql2(9000);
+LOG:  available indexes for IndexScan(p1_c1): p1_c1_pkey
+CONTEXT:  SQL statement "/*+ IndexScan(p1_c1 p1_c1_pkey) */ SELECT sum(val) FROM p1_c1 WHERE id < 9000"
+PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement
+LOG:  available indexes for IndexScan(p1_c1_c1): p1_c1_c1_pkey
+CONTEXT:  SQL statement "/*+ IndexScan(p1_c1 p1_c1_pkey) */ SELECT sum(val) FROM p1_c1 WHERE id < 9000"
+PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement
+LOG:  available indexes for IndexScan(p1_c1_c2): p1_c1_c2_pkey
+CONTEXT:  SQL statement "/*+ IndexScan(p1_c1 p1_c1_pkey) */ SELECT sum(val) FROM p1_c1 WHERE id < 9000"
+PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1_c1 p1_c1_pkey)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "/*+ IndexScan(p1_c1 p1_c1_pkey) */ SELECT sum(val) FROM p1_c1 WHERE id < 9000"
+PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement
+LOG:  available indexes for IndexScan(p1_c2): p1_c2_pkey
+CONTEXT:  SQL statement "/*+ IndexScan(p1_c2 p1_c2_pkey) */ SELECT sum(val) FROM p1_c2 WHERE id < 9000"
+PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1_c2 p1_c2_pkey)
+not used hint:
+duplication hint:
+error hint:
+
+CONTEXT:  SQL statement "/*+ IndexScan(p1_c2 p1_c2_pkey) */ SELECT sum(val) FROM p1_c2 WHERE id < 9000"
+PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement
+ dynsql2 
+---------
+    9900
+(1 row)
+
+SELECT pg_sleep(1);
+ pg_sleep 
+----------
+(1 row)
+
+-- the index scan happened while planning.
+SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2');
+ relname | seq_scan | idx_scan 
+---------+----------+----------
+ p1_c1   |        0 |        1
+ p1_c2   |        0 |        2
+(2 rows)
+
+-- Subqueries on inheritance tables under UNION
+EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000
+UNION ALL
+SELECT val::int FROM p2 WHERE id < 1000;
+                 QUERY PLAN                  
+---------------------------------------------
+ Append
+   ->  Append
+         ->  Seq Scan on p1 p1_1
+               Filter: (val < 1000)
+         ->  Seq Scan on p1_c1 p1_2
+               Filter: (val < 1000)
+         ->  Seq Scan on p1_c2 p1_3
+               Filter: (val < 1000)
+         ->  Seq Scan on p1_c3 p1_4
+               Filter: (val < 1000)
+         ->  Seq Scan on p1_c4 p1_5
+               Filter: (val < 1000)
+         ->  Seq Scan on p1_c1_c1 p1_6
+               Filter: (val < 1000)
+         ->  Seq Scan on p1_c1_c2 p1_7
+               Filter: (val < 1000)
+         ->  Seq Scan on p1_c3_c1 p1_8
+               Filter: (val < 1000)
+         ->  Seq Scan on p1_c3_c2 p1_9
+               Filter: (val < 1000)
+   ->  Result
+         ->  Append
+               ->  Seq Scan on p2 p2_1
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c1 p2_2
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c2 p2_3
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c3 p2_4
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c4 p2_5
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c1_c1 p2_6
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c1_c2 p2_7
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c3_c1 p2_8
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c3_c2 p2_9
+                     Filter: (id < 1000)
+(40 rows)
+
+/*+ IndexScan(p1 p1_val2) */
+EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000
+UNION ALL
+SELECT val::int FROM p2 WHERE id < 1000;
+LOG:  available indexes for IndexScan(p1): p1_val3 p1_val2 p1_val1
+LOG:  available indexes for IndexScan(p1_c1): p1_c1_val3 p1_c1_val2 p1_c1_val1
+LOG:  available indexes for IndexScan(p1_c2): p1_c2_val3 p1_c2_val2 p1_c2_val1
+LOG:  available indexes for IndexScan(p1_c3): p1_c3_val3 p1_c3_val2 p1_c3_val1
+LOG:  available indexes for IndexScan(p1_c4): p1_c4_val3 p1_c4_val2 p1_c4_val1
+LOG:  available indexes for IndexScan(p1_c1_c1): p1_c1_c1_val3 p1_c1_c1_val2 p1_c1_c1_val1
+LOG:  available indexes for IndexScan(p1_c1_c2): p1_c1_c2_val3 p1_c1_c2_val2 p1_c1_c2_val1
+LOG:  available indexes for IndexScan(p1_c3_c1): p1_c3_c1_val3 p1_c3_c1_val2 p1_c3_c1_val1
+LOG:  available indexes for IndexScan(p1_c3_c2): p1_c3_c2_val3 p1_c3_c2_val2 p1_c3_c2_val1
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1 p1_val2)
+not used hint:
+duplication hint:
+error hint:
+
+                         QUERY PLAN                          
+-------------------------------------------------------------
+ Append
+   ->  Append
+         ->  Index Scan using p1_val3 on p1 p1_1
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c1_val3 on p1_c1 p1_2
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c2_val3 on p1_c2 p1_3
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c3_val3 on p1_c3 p1_4
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c4_val3 on p1_c4 p1_5
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c1_c1_val3 on p1_c1_c1 p1_6
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c1_c2_val3 on p1_c1_c2 p1_7
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c3_c1_val3 on p1_c3_c1 p1_8
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c3_c2_val3 on p1_c3_c2 p1_9
+               Index Cond: (val < 1000)
+   ->  Result
+         ->  Append
+               ->  Seq Scan on p2 p2_1
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c1 p2_2
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c2 p2_3
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c3 p2_4
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c4 p2_5
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c1_c1 p2_6
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c1_c2 p2_7
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c3_c1 p2_8
+                     Filter: (id < 1000)
+               ->  Seq Scan on p2_c3_c2 p2_9
+                     Filter: (id < 1000)
+(40 rows)
+
+/*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */
+EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000
+UNION ALL
+SELECT val::int FROM p2 WHERE id < 1000;
+LOG:  available indexes for IndexScan(p1): p1_val3 p1_val2 p1_val1
+LOG:  available indexes for IndexScan(p1_c1): p1_c1_val3 p1_c1_val2 p1_c1_val1
+LOG:  available indexes for IndexScan(p1_c2): p1_c2_val3 p1_c2_val2 p1_c2_val1
+LOG:  available indexes for IndexScan(p1_c3): p1_c3_val3 p1_c3_val2 p1_c3_val1
+LOG:  available indexes for IndexScan(p1_c4): p1_c4_val3 p1_c4_val2 p1_c4_val1
+LOG:  available indexes for IndexScan(p1_c1_c1): p1_c1_c1_val3 p1_c1_c1_val2 p1_c1_c1_val1
+LOG:  available indexes for IndexScan(p1_c1_c2): p1_c1_c2_val3 p1_c1_c2_val2 p1_c1_c2_val1
+LOG:  available indexes for IndexScan(p1_c3_c1): p1_c3_c1_val3 p1_c3_c1_val2 p1_c3_c1_val1
+LOG:  available indexes for IndexScan(p1_c3_c2): p1_c3_c2_val3 p1_c3_c2_val2 p1_c3_c2_val1
+LOG:  available indexes for IndexScan(p2): p2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1): p2_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c2): p2_c2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3): p2_c3_id_val_idx
+LOG:  available indexes for IndexScan(p2_c4): p2_c4_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_id_val_idx
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1 p1_val2)
+IndexScan(p2 p2_id_val_idx)
+not used hint:
+duplication hint:
+error hint:
+
+                               QUERY PLAN                                
+-------------------------------------------------------------------------
+ Append
+   ->  Append
+         ->  Index Scan using p1_val3 on p1 p1_1
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c1_val3 on p1_c1 p1_2
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c2_val3 on p1_c2 p1_3
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c3_val3 on p1_c3 p1_4
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c4_val3 on p1_c4 p1_5
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c1_c1_val3 on p1_c1_c1 p1_6
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c1_c2_val3 on p1_c1_c2 p1_7
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c3_c1_val3 on p1_c3_c1 p1_8
+               Index Cond: (val < 1000)
+         ->  Index Scan using p1_c3_c2_val3 on p1_c3_c2 p1_9
+               Index Cond: (val < 1000)
+   ->  Result
+         ->  Append
+               ->  Index Scan using p2_id_val_idx on p2 p2_1
+                     Index Cond: (id < 1000)
+               ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2_2
+                     Index Cond: (id < 1000)
+               ->  Index Scan using p2_c2_id_val_idx on p2_c2 p2_3
+                     Index Cond: (id < 1000)
+               ->  Index Scan using p2_c3_id_val_idx on p2_c3 p2_4
+                     Index Cond: (id < 1000)
+               ->  Index Scan using p2_c4_id_val_idx on p2_c4 p2_5
+                     Index Cond: (id < 1000)
+               ->  Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2_6
+                     Index Cond: (id < 1000)
+               ->  Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2_7
+                     Index Cond: (id < 1000)
+               ->  Index Scan using p2_c3_c1_id_val_idx on p2_c3_c1 p2_8
+                     Index Cond: (id < 1000)
+               ->  Index Scan using p2_c3_c2_id_val_idx on p2_c3_c2 p2_9
+                     Index Cond: (id < 1000)
+(40 rows)
+
+-- union all case
+EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000
+UNION
+SELECT val::int FROM p2 WHERE id < 1000;
+                    QUERY PLAN                     
+---------------------------------------------------
+ HashAggregate
+   Group Key: p1.val
+   ->  Append
+         ->  Append
+               ->  Seq Scan on p1 p1_1
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c1 p1_2
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c2 p1_3
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c3 p1_4
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c4 p1_5
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c1_c1 p1_6
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c1_c2 p1_7
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c3_c1 p1_8
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c3_c2 p1_9
+                     Filter: (val < 1000)
+         ->  Result
+               ->  Append
+                     ->  Seq Scan on p2 p2_1
+                           Filter: (id < 1000)
+                     ->  Seq Scan on p2_c1 p2_2
+                           Filter: (id < 1000)
+                     ->  Seq Scan on p2_c2 p2_3
+                           Filter: (id < 1000)
+                     ->  Seq Scan on p2_c3 p2_4
+                           Filter: (id < 1000)
+                     ->  Seq Scan on p2_c4 p2_5
+                           Filter: (id < 1000)
+                     ->  Seq Scan on p2_c1_c1 p2_6
+                           Filter: (id < 1000)
+                     ->  Seq Scan on p2_c1_c2 p2_7
+                           Filter: (id < 1000)
+                     ->  Seq Scan on p2_c3_c1 p2_8
+                           Filter: (id < 1000)
+                     ->  Seq Scan on p2_c3_c2 p2_9
+                           Filter: (id < 1000)
+(42 rows)
+
+/*+ IndexScan(p2 p2_id_val_idx) */
+EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000
+UNION
+SELECT val::int FROM p2 WHERE id < 1000;
+LOG:  available indexes for IndexScan(p2): p2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1): p2_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c2): p2_c2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3): p2_c3_id_val_idx
+LOG:  available indexes for IndexScan(p2_c4): p2_c4_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_id_val_idx
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p2 p2_id_val_idx)
+not used hint:
+duplication hint:
+error hint:
+
+                                  QUERY PLAN                                   
+-------------------------------------------------------------------------------
+ HashAggregate
+   Group Key: p1.val
+   ->  Append
+         ->  Append
+               ->  Seq Scan on p1 p1_1
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c1 p1_2
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c2 p1_3
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c3 p1_4
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c4 p1_5
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c1_c1 p1_6
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c1_c2 p1_7
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c3_c1 p1_8
+                     Filter: (val < 1000)
+               ->  Seq Scan on p1_c3_c2 p1_9
+                     Filter: (val < 1000)
+         ->  Result
+               ->  Append
+                     ->  Index Scan using p2_id_val_idx on p2 p2_1
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2_2
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c2_id_val_idx on p2_c2 p2_3
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c3_id_val_idx on p2_c3 p2_4
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c4_id_val_idx on p2_c4 p2_5
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2_6
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2_7
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c3_c1_id_val_idx on p2_c3_c1 p2_8
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c3_c2_id_val_idx on p2_c3_c2 p2_9
+                           Index Cond: (id < 1000)
+(42 rows)
+
+/*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */
+EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000
+UNION
+SELECT val::int FROM p2 WHERE id < 1000;
+LOG:  available indexes for IndexScan(p1): p1_val3 p1_val2 p1_val1
+LOG:  available indexes for IndexScan(p1_c1): p1_c1_val3 p1_c1_val2 p1_c1_val1
+LOG:  available indexes for IndexScan(p1_c2): p1_c2_val3 p1_c2_val2 p1_c2_val1
+LOG:  available indexes for IndexScan(p1_c3): p1_c3_val3 p1_c3_val2 p1_c3_val1
+LOG:  available indexes for IndexScan(p1_c4): p1_c4_val3 p1_c4_val2 p1_c4_val1
+LOG:  available indexes for IndexScan(p1_c1_c1): p1_c1_c1_val3 p1_c1_c1_val2 p1_c1_c1_val1
+LOG:  available indexes for IndexScan(p1_c1_c2): p1_c1_c2_val3 p1_c1_c2_val2 p1_c1_c2_val1
+LOG:  available indexes for IndexScan(p1_c3_c1): p1_c3_c1_val3 p1_c3_c1_val2 p1_c3_c1_val1
+LOG:  available indexes for IndexScan(p1_c3_c2): p1_c3_c2_val3 p1_c3_c2_val2 p1_c3_c2_val1
+LOG:  available indexes for IndexScan(p2): p2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1): p2_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c2): p2_c2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3): p2_c3_id_val_idx
+LOG:  available indexes for IndexScan(p2_c4): p2_c4_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1_c1): p2_c1_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c1_c2): p2_c1_c2_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3_c1): p2_c3_c1_id_val_idx
+LOG:  available indexes for IndexScan(p2_c3_c2): p2_c3_c2_id_val_idx
+LOG:  pg_hint_plan:
+used hint:
+IndexScan(p1 p1_val2)
+IndexScan(p2 p2_id_val_idx)
+not used hint:
+duplication hint:
+error hint:
+
+                                  QUERY PLAN                                   
+-------------------------------------------------------------------------------
+ HashAggregate
+   Group Key: p1.val
+   ->  Append
+         ->  Append
+               ->  Index Scan using p1_val3 on p1 p1_1
+                     Index Cond: (val < 1000)
+               ->  Index Scan using p1_c1_val3 on p1_c1 p1_2
+                     Index Cond: (val < 1000)
+               ->  Index Scan using p1_c2_val3 on p1_c2 p1_3
+                     Index Cond: (val < 1000)
+               ->  Index Scan using p1_c3_val3 on p1_c3 p1_4
+                     Index Cond: (val < 1000)
+               ->  Index Scan using p1_c4_val3 on p1_c4 p1_5
+                     Index Cond: (val < 1000)
+               ->  Index Scan using p1_c1_c1_val3 on p1_c1_c1 p1_6
+                     Index Cond: (val < 1000)
+               ->  Index Scan using p1_c1_c2_val3 on p1_c1_c2 p1_7
+                     Index Cond: (val < 1000)
+               ->  Index Scan using p1_c3_c1_val3 on p1_c3_c1 p1_8
+                     Index Cond: (val < 1000)
+               ->  Index Scan using p1_c3_c2_val3 on p1_c3_c2 p1_9
+                     Index Cond: (val < 1000)
+         ->  Result
+               ->  Append
+                     ->  Index Scan using p2_id_val_idx on p2 p2_1
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c1_id_val_idx on p2_c1 p2_2
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c2_id_val_idx on p2_c2 p2_3
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c3_id_val_idx on p2_c3 p2_4
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c4_id_val_idx on p2_c4 p2_5
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2_6
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2_7
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c3_c1_id_val_idx on p2_c3_c1 p2_8
+                           Index Cond: (id < 1000)
+                     ->  Index Scan using p2_c3_c2_id_val_idx on p2_c3_c2 p2_9
+                           Index Cond: (id < 1000)
+(42 rows)
+
+--
+-- Rows hint tests
+--
+-- Explain result includes "Planning time" if COSTS is enabled, but
+-- this test needs it enabled for get rows count. So do tests via psql
+-- and grep -v the mutable line.
+-- Parse error check
+/*+ Rows() */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near " "
+DETAIL:  Rows hint needs at least one relation followed by one correction term.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Rows()
+
+ ?column? 
+----------
+        1
+(1 row)
+
+/*+ Rows(x) */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near " "
+DETAIL:  Rows hint needs at least one relation followed by one correction term.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Rows()
+
+ ?column? 
+----------
+        1
+(1 row)
+
+-- value types
+\o results/pg_hint_plan.tmpout
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 #99) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+Rows(t1 t2 #99)
+not used hint:
+duplication hint:
+error hint:
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=99 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 +99) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+Rows(t1 t2 +99)
+not used hint:
+duplication hint:
+error hint:
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=1099 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 -99) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+Rows(t1 t2 -99)
+not used hint:
+duplication hint:
+error hint:
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=901 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 *99) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+Rows(t1 t2 *99)
+not used hint:
+duplication hint:
+error hint:
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=99000 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 *0.01) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+Rows(t1 t2 *0.01)
+not used hint:
+duplication hint:
+error hint:
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=10 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 #aa) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR
+INFO:  pg_hint_plan: hint syntax error at or near "aa"
+DETAIL:  Rows hint requires valid number as rows estimation.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Rows(t1 t2 #aa)
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 /99) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR
+INFO:  pg_hint_plan: hint syntax error at or near "/99"
+DETAIL:  Unrecognized rows value type notation.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Rows(t1 t2 /99)
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+-- round up to 1
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 -99999) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id);
+WARNING:  Force estimate to be at least one row, to avoid possible divide-by-zero when interpolating costs : Rows(t1 t2 -99999) 
+LOG:  pg_hint_plan:
+used hint:
+Rows(t1 t2 -99999)
+not used hint:
+duplication hint:
+error hint:
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                  QUERY PLAN                                  
+------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+   Merge Cond: (t1.id = t2.id)
+   ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+   ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+
+-- complex join tree
+\o results/pg_hint_plan.tmpout
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                     QUERY PLAN                                     
+------------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=10 width=xxx)
+   Merge Cond: (t1.id = t3.id)
+   ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+         ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+         Sort Key: t3.id
+         ->  Seq Scan on t3  (cost=xxx..xxx rows=100 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t2 #22) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+Rows(t1 t2 #22)
+not used hint:
+duplication hint:
+error hint:
+
+\o
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                     QUERY PLAN                                     
+------------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=1 width=xxx)
+   Merge Cond: (t1.id = t3.id)
+   ->  Merge Join  (cost=xxx..xxx rows=22 width=xxx)
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+         ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+         Sort Key: t3.id
+         ->  Seq Scan on t3  (cost=xxx..xxx rows=100 width=xxx)
+
+\o results/pg_hint_plan.tmpout
+/*+ Rows(t1 t3 *10) */
+EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
+LOG:  pg_hint_plan:
+used hint:
+Rows(t1 t3 *10)
+not used hint:
+duplication hint:
+error hint:
+
+\o
+set max_parallel_workers_per_gather to DEFAULT;
+\! sql/maskout.sh results/pg_hint_plan.tmpout
+                                     QUERY PLAN                                     
+------------------------------------------------------------------------------------
+ Merge Join  (cost=xxx..xxx rows=100 width=xxx)
+   Merge Cond: (t1.id = t3.id)
+   ->  Merge Join  (cost=xxx..xxx rows=1000 width=xxx)
+         Merge Cond: (t1.id = t2.id)
+         ->  Index Scan using t1_pkey on t1  (cost=xxx..xxx rows=10000 width=xxx)
+         ->  Index Scan using t2_pkey on t2  (cost=xxx..xxx rows=1000 width=xxx)
+   ->  Sort  (cost=xxx..xxx rows=100 width=xxx)
+         Sort Key: t3.id
+         ->  Seq Scan on t3  (cost=xxx..xxx rows=100 width=xxx)
+
+\! rm results/pg_hint_plan.tmpout
+-- hint error level
+set client_min_messages to 'DEBUG1';
+set pg_hint_plan.debug_level to 'verbose';
+/*+ SeqScan( */ SELECT 1;
+INFO:  pg_hint_plan: hint syntax error at or near ""
+DETAIL:  Closing parenthesis is necessary.
+ ?column? 
+----------
+        1
+(1 row)
+
+/*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
+LOG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+ id | val 
+----+-----
+(0 rows)
+
+set pg_hint_plan.message_level to 'DEBUG1';
+set pg_hint_plan.parse_messages to 'NOTICE';
+/*+ SeqScan( */ SELECT 1;
+NOTICE:  pg_hint_plan: hint syntax error at or near ""
+DETAIL:  Closing parenthesis is necessary.
+ ?column? 
+----------
+        1
+(1 row)
+
+/*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
+DEBUG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+ id | val 
+----+-----
+(0 rows)
+
+-- all hint types together
+/*+ SeqScan(t1) MergeJoin(t1 t2) Leading(t1 t2) Rows(t1 t2 +10) Parallel(t1 8 hard) Set(random_page_cost 2.0)*/
+EXPLAIN (costs off) SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id);
+DEBUG:  adjusted rows 1000 to 1010
+DEBUG:  pg_hint_plan:
+used hint:
+SeqScan(t1)
+MergeJoin(t1 t2)
+Leading(t1 t2)
+Set(random_page_cost 2.0)
+Rows(t1 t2 +10)
+Parallel(t1 8 hard)
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                    
+-------------------------------------------------
+ Nested Loop
+   ->  Merge Join
+         Merge Cond: (t2.id = t1.id)
+         ->  Index Scan using t2_pkey on t2
+         ->  Sort
+               Sort Key: t1.id
+               ->  Gather
+                     Workers Planned: 8
+                     ->  Parallel Seq Scan on t1
+   ->  Index Scan using t3_pkey on t3
+         Index Cond: (id = t1.id)
+(11 rows)
+