OSDN Git Service

Leadingヒント句の仕様変更にそって[結合順序]試験のPG9.1用予測結果を変更した。
[pghintplan/pg_hint_plan.git] / expected / ut-L-9.1.out
index f314329..ef054da 100644 (file)
@@ -198,27 +198,26 @@ error hint:
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
 LOG:  pg_hint_plan:
 used hint:
-Leading(t5 t2 t3 t1)
 not used hint:
+Leading(t5 t2 t3 t1)
 duplication hint:
 error hint:
 
                    QUERY PLAN                   
 ------------------------------------------------
- Nested Loop
+ Merge Join
+   Merge Cond: (t1.c1 = t2.c1)
    ->  Merge Join
-         Merge Cond: (t1.c1 = t2.c1)
-         ->  Index Scan using t1_i1 on t1
-         ->  Sort
-               Sort Key: t2.c1
-               ->  Hash Join
-                     Hash Cond: (t3.c1 = t2.c1)
-                     ->  Seq Scan on t3
-                     ->  Hash
-                           ->  Seq Scan on t2
-   ->  Index Scan using t4_i1 on t4
-         Index Cond: (c1 = t1.c1)
-(13 rows)
+         Merge Cond: (t1.c1 = t4.c1)
+         ->  Merge Join
+               Merge Cond: (t1.c1 = t3.c1)
+               ->  Index Scan using t1_i1 on t1
+               ->  Index Scan using t3_i1 on t3
+         ->  Index Scan using t4_i1 on t4
+   ->  Sort
+         Sort Key: t2.c1
+         ->  Seq Scan on t2
+(12 rows)
 
 ----
 ---- No. L-1-4 conflict table name
@@ -276,9 +275,9 @@ DETAIL:  Relation name "t1" is ambiguous.
 LOG:  pg_hint_plan:
 used hint:
 not used hint:
-Leading(t1 t2 t3 t1)
 duplication hint:
 error hint:
+Leading(t1 t2 t3 t1)
 
                    QUERY PLAN                   
 ------------------------------------------------
@@ -300,25 +299,25 @@ error hint:
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s2.t1 WHERE s1.t1.c1 = t2.c1 AND s1.t1.c1 = t3.c1 AND s1.t1.c1 = s2.t1.c1;
 LOG:  pg_hint_plan:
 used hint:
-Leading(s1.t1 t2 t3 s2.t1)
 not used hint:
+Leading(s1.t1 t2 t3 s2.t1)
 duplication hint:
 error hint:
 
                    QUERY PLAN                   
 ------------------------------------------------
- Nested Loop
-   ->  Nested Loop
+ Merge Join
+   Merge Cond: (s1.t1.c1 = s2.t1.c1)
+   ->  Merge Join
+         Merge Cond: (s1.t1.c1 = t2.c1)
          ->  Merge Join
-               Merge Cond: (t3.c1 = t2.c1)
+               Merge Cond: (s1.t1.c1 = t3.c1)
+               ->  Index Scan using t1_i1 on t1
                ->  Index Scan using t3_i1 on t3
-               ->  Sort
-                     Sort Key: t2.c1
-                     ->  Seq Scan on t2
-         ->  Index Scan using t1_pkey on t1
-               Index Cond: (c1 = t2.c1)
-   ->  Index Scan using t1_i1 on t1
-         Index Cond: (c1 = t2.c1)
+         ->  Index Scan using t2_i1 on t2
+   ->  Sort
+         Sort Key: s2.t1.c1
+         ->  Seq Scan on t1
 (12 rows)
 
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s2.t1 s2t1 WHERE s1.t1.c1 = t2.c1 AND s1.t1.c1 = t3.c1 AND s1.t1.c1 = s2t1.c1;
@@ -438,11 +437,12 @@ error hint:
                                  ->  Seq Scan on t2
 (30 rows)
 
-/*+Leading(st1 st2 st3 st4 t4 t2 t3 t1)*/
+/*+Leading(st1 st2 st3 st4)Leading(t4 t2 t3 t1)*/
 EXPLAIN (COSTS false) SELECT *, (SELECT max(st1.c1) FROM s1.t1 st1, s1.t2 st2, s1.t3 st3, s1.t4 st4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1) FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
 LOG:  pg_hint_plan:
 used hint:
-Leading(st1 st2 st3 st4 t4 t2 t3 t1)
+Leading(st1 st2 st3 st4)
+Leading(t4 t2 t3 t1)
 not used hint:
 duplication hint:
 error hint:
@@ -513,30 +513,30 @@ error hint:
 -- No. L-1-5-2
 /*+Leading(t4 t2 t3 t1 t4)*/
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+INFO:  hint syntax error at or near "Leading(t4 t2 t3 t1 t4)"
+DETAIL:  Relation name "t4" is duplicated.
 LOG:  pg_hint_plan:
 used hint:
-Leading(t4 t2 t3 t1 t4)
 not used hint:
 duplication hint:
 error hint:
+Leading(t4 t2 t3 t1 t4)
 
-                      QUERY PLAN                      
-------------------------------------------------------
+                   QUERY PLAN                   
+------------------------------------------------
  Merge Join
    Merge Cond: (t1.c1 = t2.c1)
-   ->  Index Scan using t1_i1 on t1
+   ->  Merge Join
+         Merge Cond: (t1.c1 = t4.c1)
+         ->  Merge Join
+               Merge Cond: (t1.c1 = t3.c1)
+               ->  Index Scan using t1_i1 on t1
+               ->  Index Scan using t3_i1 on t3
+         ->  Index Scan using t4_i1 on t4
    ->  Sort
          Sort Key: t2.c1
-         ->  Hash Join
-               Hash Cond: (t3.c1 = t2.c1)
-               ->  Seq Scan on t3
-               ->  Hash
-                     ->  Hash Join
-                           Hash Cond: (t4.c1 = t2.c1)
-                           ->  Seq Scan on t4
-                           ->  Hash
-                                 ->  Seq Scan on t2
-(14 rows)
+         ->  Seq Scan on t2
+(12 rows)
 
 /*+Leading(t4 t2 t3 t4)*/
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
@@ -568,30 +568,30 @@ Leading(t4 t2 t3 t4)
 -- No. L-1-5-3
 /*+Leading(t4 t2 t3 t1 t4 t2 t3 t1)*/
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+INFO:  hint syntax error at or near "Leading(t4 t2 t3 t1 t4 t2 t3 t1)"
+DETAIL:  Relation name "t4" is duplicated.
 LOG:  pg_hint_plan:
 used hint:
-Leading(t4 t2 t3 t1 t4 t2 t3 t1)
 not used hint:
 duplication hint:
 error hint:
+Leading(t4 t2 t3 t1 t4 t2 t3 t1)
 
-                      QUERY PLAN                      
-------------------------------------------------------
+                   QUERY PLAN                   
+------------------------------------------------
  Merge Join
    Merge Cond: (t1.c1 = t2.c1)
-   ->  Index Scan using t1_i1 on t1
+   ->  Merge Join
+         Merge Cond: (t1.c1 = t4.c1)
+         ->  Merge Join
+               Merge Cond: (t1.c1 = t3.c1)
+               ->  Index Scan using t1_i1 on t1
+               ->  Index Scan using t3_i1 on t3
+         ->  Index Scan using t4_i1 on t4
    ->  Sort
          Sort Key: t2.c1
-         ->  Hash Join
-               Hash Cond: (t3.c1 = t2.c1)
-               ->  Seq Scan on t3
-               ->  Hash
-                     ->  Hash Join
-                           Hash Cond: (t4.c1 = t2.c1)
-                           ->  Seq Scan on t4
-                           ->  Hash
-                                 ->  Seq Scan on t2
-(14 rows)
+         ->  Seq Scan on t2
+(12 rows)
 
 /*+Leading(t4 t2 t2 t4)*/
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
@@ -907,25 +907,24 @@ error hint:
 (10 rows)
 
 -- No. L-1-6-8
-EXPLAIN (COSTS false) SELECT * FROM (VALUES(1,1,1,'1')) AS t1 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t2 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2'), (3,3,3,'3')) AS t3 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2'), (3,3,3,'3'), (4,4,4,'4')) AS t4  (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
-                                QUERY PLAN                                
---------------------------------------------------------------------------
+EXPLAIN (COSTS false) SELECT * FROM (VALUES(1,1,1,'1')) AS t1 (c1, c2, c3, c4), s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+                      QUERY PLAN                       
+-------------------------------------------------------
  Nested Loop
-   Join Filter: ("*VALUES*".column1 = "*VALUES*".column1)
-   ->  Hash Join
-         Hash Cond: ("*VALUES*".column1 = "*VALUES*".column1)
-         ->  Values Scan on "*VALUES*"
-         ->  Hash
-               ->  Hash Join
-                     Hash Cond: ("*VALUES*".column1 = "*VALUES*".column1)
+   ->  Nested Loop
+         ->  Hash Join
+               Hash Cond: (t2.c1 = "*VALUES*".column1)
+               ->  Seq Scan on t2
+               ->  Hash
                      ->  Values Scan on "*VALUES*"
-                     ->  Hash
-                           ->  Values Scan on "*VALUES*"
-   ->  Values Scan on "*VALUES*"
-(12 rows)
+         ->  Index Scan using t3_i1 on t3
+               Index Cond: (c1 = "*VALUES*".column1)
+   ->  Index Scan using t4_i1 on t4
+         Index Cond: (c1 = "*VALUES*".column1)
+(11 rows)
 
 /*+Leading(t4 t3 t2 t1)*/
-EXPLAIN (COSTS false) SELECT * FROM (VALUES(1,1,1,'1')) AS t1 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t2 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2'), (3,3,3,'3')) AS t3 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2'), (3,3,3,'3'), (4,4,4,'4')) AS t4  (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+EXPLAIN (COSTS false) SELECT * FROM (VALUES(1,1,1,'1')) AS t1 (c1, c2, c3, c4), s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
 LOG:  pg_hint_plan:
 used hint:
 not used hint:
@@ -933,21 +932,20 @@ Leading(t4 t3 t2 t1)
 duplication hint:
 error hint:
 
-                                QUERY PLAN                                
---------------------------------------------------------------------------
+                      QUERY PLAN                       
+-------------------------------------------------------
  Nested Loop
-   Join Filter: ("*VALUES*".column1 = "*VALUES*".column1)
-   ->  Hash Join
-         Hash Cond: ("*VALUES*".column1 = "*VALUES*".column1)
-         ->  Values Scan on "*VALUES*"
-         ->  Hash
-               ->  Hash Join
-                     Hash Cond: ("*VALUES*".column1 = "*VALUES*".column1)
+   ->  Nested Loop
+         ->  Hash Join
+               Hash Cond: (t2.c1 = "*VALUES*".column1)
+               ->  Seq Scan on t2
+               ->  Hash
                      ->  Values Scan on "*VALUES*"
-                     ->  Hash
-                           ->  Values Scan on "*VALUES*"
-   ->  Values Scan on "*VALUES*"
-(12 rows)
+         ->  Index Scan using t3_i1 on t3
+               Index Cond: (c1 = "*VALUES*".column1)
+   ->  Index Scan using t4_i1 on t4
+         Index Cond: (c1 = "*VALUES*".column1)
+(11 rows)
 
 -- No. L-1-6-9
 EXPLAIN (COSTS false) WITH c1(c1) AS (SELECT st1.c1 FROM s1.t1 st1, s1.t1 st2, s1.t1 st3, s1.t1 st4 WHERE st1.c1 = st2.c1 AND st1.c1 = st3.c1 AND st1.c1 = st4.c1) SELECT * FROM c1 ct1, c1 ct2, c1 ct3, c1 ct4 WHERE ct1.c1 = ct2.c1 AND ct1.c1 = ct3.c1 AND ct1.c1 = ct4.c1;
@@ -988,11 +986,12 @@ EXPLAIN (COSTS false) WITH c1(c1) AS (SELECT st1.c1 FROM s1.t1 st1, s1.t1 st2, s
                      ->  CTE Scan on c1 ct4
 (33 rows)
 
-/*+Leading(ct4 ct3 ct2 ct1 st4 st3 st2 st1)*/
+/*+Leading(ct4 ct3 ct2 ct1)Leading(st4 st3 st2 st1)*/
 EXPLAIN (COSTS false) WITH c1(c1) AS (SELECT st1.c1 FROM s1.t1 st1, s1.t1 st2, s1.t1 st3, s1.t1 st4 WHERE st1.c1 = st2.c1 AND st1.c1 = st3.c1 AND st1.c1 = st4.c1) SELECT * FROM c1 ct1, c1 ct2, c1 ct3, c1 ct4 WHERE ct1.c1 = ct2.c1 AND ct1.c1 = ct3.c1 AND ct1.c1 = ct4.c1;
 LOG:  pg_hint_plan:
 used hint:
-Leading(ct4 ct3 ct2 ct1 st4 st3 st2 st1)
+Leading(ct4 ct3 ct2 ct1)
+Leading(st4 st3 st2 st1)
 not used hint:
 duplication hint:
 error hint:
@@ -1146,27 +1145,26 @@ EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, (SELECT t4.c1 FROM s1.t
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, (SELECT t4.c1 FROM s1.t4) st4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = st4.c1;
 LOG:  pg_hint_plan:
 used hint:
-Leading(st4 t2 t3 t1)
 not used hint:
+Leading(st4 t2 t3 t1)
 duplication hint:
 error hint:
 
                    QUERY PLAN                   
 ------------------------------------------------
- Nested Loop
+ Merge Join
+   Merge Cond: (t1.c1 = t2.c1)
    ->  Merge Join
-         Merge Cond: (t1.c1 = t2.c1)
-         ->  Index Scan using t1_i1 on t1
-         ->  Sort
-               Sort Key: t2.c1
-               ->  Hash Join
-                     Hash Cond: (t3.c1 = t2.c1)
-                     ->  Seq Scan on t3
-                     ->  Hash
-                           ->  Seq Scan on t2
-   ->  Index Scan using t4_i1 on t4
-         Index Cond: (c1 = t1.c1)
-(13 rows)
+         Merge Cond: (t1.c1 = t4.c1)
+         ->  Merge Join
+               Merge Cond: (t1.c1 = t3.c1)
+               ->  Index Scan using t1_i1 on t1
+               ->  Index Scan using t3_i1 on t3
+         ->  Index Scan using t4_i1 on t4
+   ->  Sort
+         Sort Key: t2.c1
+         ->  Seq Scan on t2
+(12 rows)
 
 /*+Leading(t4 t2 t3 t1)*/
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, (SELECT t4.c1 FROM s1.t4) st4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = st4.c1;
@@ -1196,7 +1194,7 @@ error hint:
 (14 rows)
 
 ----
----- No. L-2-1 complexity query block
+---- No. L-2-1 some complexity query blocks
 ----
 -- No. L-2-1-1
 EXPLAIN (COSTS false)
@@ -1259,7 +1257,9 @@ SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2
 (47 rows)
 
 /*+
-Leading(bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2)
+Leading(bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
 */
 EXPLAIN (COSTS false)
 SELECT max(bmt1.c1), (
@@ -1271,7 +1271,9 @@ SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2)
+Leading(bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
 not used hint:
 duplication hint:
 error hint:
@@ -1406,7 +1408,10 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3
 (63 rows)
 
 /*+
-Leading(bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2 b3t4 b3t1 b3t2 b3t3)
+Leading(bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
+Leading(b3t4 b3t1 b3t2 b3t3)
 */
 EXPLAIN (COSTS false)
 SELECT max(bmt1.c1), (
@@ -1420,7 +1425,10 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2 b3t4 b3t1 b3t2 b3t3)
+Leading(bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
+Leading(b3t4 b3t1 b3t2 b3t3)
 not used hint:
 duplication hint:
 error hint:
@@ -1656,7 +1664,9 @@ SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2
 (48 rows)
 
 /*+
-Leading(bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2)
+Leading(bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
 */
 EXPLAIN (COSTS false)
 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.ctid = '(1,1)' AND bmt1.c1 = bmt2.c1 AND bmt2.ctid = '(1,1)' AND bmt1.c1 = bmt3.c1 AND bmt3.ctid = '(1,1)' AND bmt1.c1 = bmt4.c1 AND bmt4.ctid = '(1,1)'
@@ -1668,7 +1678,9 @@ SELECT max(b2t1.c1) FROM s1.t1 b2t1, s1.t2 b2t2, s1.t3 b2t3, s1.t4 b2t4 WHERE b2
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2)
+Leading(bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
 not used hint:
 duplication hint:
 error hint:
@@ -1805,7 +1817,10 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3
 (64 rows)
 
 /*+
-Leading(bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2 b3t4 b3t1 b3t2 b3t3)
+Leading(bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
+Leading(b3t4 b3t1 b3t2 b3t3)
 */
 EXPLAIN (COSTS false)
 SELECT max(bmt1.c1) FROM s1.t1 bmt1, s1.t2 bmt2, s1.t3 bmt3, s1.t4 bmt4 WHERE bmt1.ctid = '(1,1)' AND bmt1.c1 = bmt2.c1 AND bmt2.ctid = '(1,1)' AND bmt1.c1 = bmt3.c1 AND bmt3.ctid = '(1,1)' AND bmt1.c1 = bmt4.c1 AND bmt4.ctid = '(1,1)'
@@ -1819,7 +1834,10 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2 b3t4 b3t1 b3t2 b3t3)
+Leading(bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
+Leading(b3t4 b3t1 b3t2 b3t3)
 not used hint:
 duplication hint:
 error hint:
@@ -1964,7 +1982,9 @@ AND bmt1.c1 = c2.c1
 (53 rows)
 
 /*+
-Leading(c2 c1 bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2)
+Leading(c2 c1 bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
 */
 EXPLAIN (COSTS false)
 WITH c1 (c1) AS (
@@ -1981,7 +2001,9 @@ AND bmt1.c1 = c2.c1
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(c2 c1 bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2)
+Leading(c2 c1 bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
 not used hint:
 duplication hint:
 error hint:
@@ -2138,7 +2160,10 @@ AND bmt1.c1 = c3.c1
 (72 rows)
 
 /*+
-Leading(c3 c2 c1 bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2 b3t4 b3t1 b3t2 b3t3)
+Leading(c3 c2 c1 bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
+Leading(b3t4 b3t1 b3t2 b3t3)
 */
 EXPLAIN (COSTS false)
 WITH c1 (c1) AS (
@@ -2159,7 +2184,10 @@ AND bmt1.c1 = c3.c1
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(c3 c2 c1 bmt1 bmt2 bmt3 bmt4 b1t2 b1t3 b1t4 b1t1 b2t3 b2t4 b2t1 b2t2 b3t4 b3t1 b3t2 b3t3)
+Leading(c3 c2 c1 bmt1 bmt2 bmt3 bmt4)
+Leading(b1t2 b1t3 b1t4 b1t1)
+Leading(b2t3 b2t4 b2t1 b2t2)
+Leading(b3t4 b3t1 b3t2 b3t3)
 not used hint:
 duplication hint:
 error hint:
@@ -2288,7 +2316,7 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1 WHERE b3t1.ctid = '(1,1)' AND b3t1.c1 = 1
 (27 rows)
 
 /*+
-Leading(c1 bmt1 b1t1 b2t1 b3t1)
+Leading(c1 bmt1)
 */
 EXPLAIN (COSTS false)
 WITH c1 (c1) AS (
@@ -2304,7 +2332,7 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1 WHERE b3t1.ctid = '(1,1)' AND b3t1.c1 = 1
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(c1 bmt1 b1t1 b2t1 b3t1)
+Leading(c1 bmt1)
 not used hint:
 duplication hint:
 error hint:
@@ -2394,7 +2422,10 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2 WHERE b3t1.ctid = '(1,1)' AND b3
 (35 rows)
 
 /*+
-Leading(c1 bmt2 b1t2 b2t2 b3t2 bmt1 b1t1 b2t1 b3t1)
+Leading(c1 bmt2 bmt1)
+Leading(b1t2 b1t1)
+Leading(b2t2 b2t1)
+Leading(b3t2 b3t1)
 */
 EXPLAIN (COSTS false)
 WITH c1 (c1) AS (
@@ -2411,7 +2442,10 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2 WHERE b3t1.ctid = '(1,1)' AND b3
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(c1 bmt2 b1t2 b2t2 b3t2 bmt1 b1t1 b2t1 b3t1)
+Leading(c1 bmt2 bmt1)
+Leading(b1t2 b1t1)
+Leading(b2t2 b2t1)
+Leading(b3t2 b3t1)
 not used hint:
 duplication hint:
 error hint:
@@ -2540,7 +2574,10 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3
 (67 rows)
 
 /*+
-Leading(c1 bmt4 b1t4 b2t4 b3t4 bmt3 b1t3 b2t3 b3t3 bmt2 b1t2 b2t2 b3t2 bmt1 b1t1 b2t1 b3t1)
+Leading(c1 bmt4 bmt3 bmt2 bmt1)
+Leading(b1t4 b1t3 b1t2 b1t1)
+Leading(b2t4 b2t3 b2t2 b2t1)
+Leading(b3t4 b3t3 b3t2 b3t1)
 */
 EXPLAIN (COSTS false)
 WITH c1 (c1) AS (
@@ -2556,7 +2593,10 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1, s1.t2 b3t2, s1.t3 b3t3, s1.t4 b3t4 WHERE b3
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(c1 bmt4 b1t4 b2t4 b3t4 bmt3 b1t3 b2t3 b3t3 bmt2 b1t2 b2t2 b3t2 bmt1 b1t1 b2t1 b3t1)
+Leading(c1 bmt4 bmt3 bmt2 bmt1)
+Leading(b1t4 b1t3 b1t2 b1t1)
+Leading(b2t4 b2t3 b2t2 b2t1)
+Leading(b3t4 b3t3 b3t2 b3t1)
 not used hint:
 duplication hint:
 error hint:
@@ -2696,7 +2736,8 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1 WHERE b3t1.ctid = '(1,1)'
 (46 rows)
 
 /*+
-Leading(c1 bmt4 b1t4 bmt3 b1t3 bmt2 b1t2 bmt1 b1t1 b2t1 b3t1)
+Leading(c1 bmt4 bmt3 bmt2 bmt1)
+Leading(b1t4 b1t3 b1t2 b1t1)
 */
 EXPLAIN (COSTS false)
 WITH c1 (c1) AS (
@@ -2712,7 +2753,8 @@ SELECT max(b3t1.c1) FROM s1.t1 b3t1 WHERE b3t1.ctid = '(1,1)'
 ;
 LOG:  pg_hint_plan:
 used hint:
-Leading(c1 bmt4 b1t4 bmt3 b1t3 bmt2 b1t2 bmt1 b1t1 b2t1 b3t1)
+Leading(c1 bmt4 bmt3 bmt2 bmt1)
+Leading(b1t4 b1t3 b1t2 b1t1)
 not used hint:
 duplication hint:
 error hint:
@@ -2768,7 +2810,7 @@ error hint:
 (46 rows)
 
 ----
----- No. L-2-3 RULE definition table
+---- No. L-2-3 RULE or VIEW
 ----
 -- No. L-2-3-1
 EXPLAIN (COSTS false) UPDATE s1.r1 SET c1 = c1 WHERE c1 = 1 AND ctid = '(1,1)';
@@ -3031,22 +3073,24 @@ EXPLAIN (COSTS false) UPDATE s1.r2_ SET c1 = c1 WHERE c1 = 1 AND ctid = '(1,1)';
                TID Cond: (ctid = '(1,1)'::tid)
 (39 rows)
 
-/*+Leading(
-b1t1 b1t2 b1t3 b1t4 
-b2t1 b2t2 b2t3 b2t4 r2_
-*/
+/*+
+Leading(b1t1 b1t2 b1t3 b1t4 r2_)
+Leading(b2t1 b2t2 b2t3 b2t4 r2_)
+*/
 EXPLAIN (COSTS false) UPDATE s1.r2_ SET c1 = c1 WHERE c1 = 1 AND ctid = '(1,1)';
 LOG:  pg_hint_plan:
 used hint:
-Leading(b1t1 b1t2 b1t3 b1t4 b2t1 b2t2 b2t3 b2t4 r2_)
+Leading(b1t1 b1t2 b1t3 b1t4 r2_)
 not used hint:
+Leading(b2t1 b2t2 b2t3 b2t4 r2_)
 duplication hint:
 error hint:
 
 LOG:  pg_hint_plan:
 used hint:
-Leading(b1t1 b1t2 b1t3 b1t4 b2t1 b2t2 b2t3 b2t4 r2_)
+Leading(b2t1 b2t2 b2t3 b2t4 r2_)
 not used hint:
+Leading(b1t1 b1t2 b1t3 b1t4 r2_)
 duplication hint:
 error hint:
 
@@ -3308,30 +3352,36 @@ EXPLAIN (COSTS false) UPDATE s1.r3_ SET c1 = c1 WHERE c1 = 1 AND ctid = '(1,1)';
                TID Cond: (ctid = '(1,1)'::tid)
 (59 rows)
 
-/*+Leading(
-b1t1 b1t2 b1t3 b1t4
-b2t1 b2t2 b2t3 b2t4
-b3t1 b3t2 b3t3 b3t4 r3_
-*/
+/*+
+Leading(b1t1 b1t2 b1t3 b1t4 r3_)
+Leading(b2t1 b2t2 b2t3 b2t4 r3_)
+Leading(b3t1 b3t2 b3t3 b3t4 r3_)
+*/
 EXPLAIN (COSTS false) UPDATE s1.r3_ SET c1 = c1 WHERE c1 = 1 AND ctid = '(1,1)';
 LOG:  pg_hint_plan:
 used hint:
-Leading(b1t1 b1t2 b1t3 b1t4 b2t1 b2t2 b2t3 b2t4 b3t1 b3t2 b3t3 b3t4 r3_)
+Leading(b1t1 b1t2 b1t3 b1t4 r3_)
 not used hint:
+Leading(b2t1 b2t2 b2t3 b2t4 r3_)
+Leading(b3t1 b3t2 b3t3 b3t4 r3_)
 duplication hint:
 error hint:
 
 LOG:  pg_hint_plan:
 used hint:
-Leading(b1t1 b1t2 b1t3 b1t4 b2t1 b2t2 b2t3 b2t4 b3t1 b3t2 b3t3 b3t4 r3_)
+Leading(b2t1 b2t2 b2t3 b2t4 r3_)
 not used hint:
+Leading(b1t1 b1t2 b1t3 b1t4 r3_)
+Leading(b3t1 b3t2 b3t3 b3t4 r3_)
 duplication hint:
 error hint:
 
 LOG:  pg_hint_plan:
 used hint:
-Leading(b1t1 b1t2 b1t3 b1t4 b2t1 b2t2 b2t3 b2t4 b3t1 b3t2 b3t3 b3t4 r3_)
+Leading(b3t1 b3t2 b3t3 b3t4 r3_)
 not used hint:
+Leading(b1t1 b1t2 b1t3 b1t4 r3_)
+Leading(b2t1 b2t2 b2t3 b2t4 r3_)
 duplication hint:
 error hint:
 
@@ -3398,6 +3448,126 @@ error hint:
                Filter: (c1 = 1)
 (59 rows)
 
+-- No. L-2-3-4
+EXPLAIN (COSTS false) SELECT * FROM s1.v1 v1, s1.v1 v2 WHERE v1.c1 = v2.c1;
+            QUERY PLAN            
+----------------------------------
+ Hash Join
+   Hash Cond: (v1t1.c1 = v1t1.c1)
+   ->  Seq Scan on t1 v1t1
+   ->  Hash
+         ->  Seq Scan on t1 v1t1
+(5 rows)
+
+/*+Leading(v1t1 v1t1)*/
+EXPLAIN (COSTS false) SELECT * FROM s1.v1 v1, s1.v1 v2 WHERE v1.c1 = v2.c1;
+INFO:  hint syntax error at or near "Leading(v1t1 v1t1)"
+DETAIL:  Relation name "v1t1" is ambiguous.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading(v1t1 v1t1)
+
+            QUERY PLAN            
+----------------------------------
+ Hash Join
+   Hash Cond: (v1t1.c1 = v1t1.c1)
+   ->  Seq Scan on t1 v1t1
+   ->  Hash
+         ->  Seq Scan on t1 v1t1
+(5 rows)
+
+-- No. L-2-3-5
+EXPLAIN (COSTS false) SELECT * FROM s1.v1 v1, s1.v1_ v2 WHERE v1.c1 = v2.c1;
+            QUERY PLAN             
+-----------------------------------
+ Hash Join
+   Hash Cond: (v1t1.c1 = v1t1_.c1)
+   ->  Seq Scan on t1 v1t1
+   ->  Hash
+         ->  Seq Scan on t1 v1t1_
+(5 rows)
+
+/*+Leading(v1t1 v1t1_)*/
+EXPLAIN (COSTS false) SELECT * FROM s1.v1 v1, s1.v1_ v2 WHERE v1.c1 = v2.c1;
+LOG:  pg_hint_plan:
+used hint:
+Leading(v1t1 v1t1_)
+not used hint:
+duplication hint:
+error hint:
+
+            QUERY PLAN             
+-----------------------------------
+ Hash Join
+   Hash Cond: (v1t1.c1 = v1t1_.c1)
+   ->  Seq Scan on t1 v1t1
+   ->  Hash
+         ->  Seq Scan on t1 v1t1_
+(5 rows)
+
+-- No. L-2-3-6
+EXPLAIN (COSTS false) SELECT * FROM s1.r4 t1, s1.r4 t2 WHERE t1.c1 = t2.c1;
+            QUERY PLAN            
+----------------------------------
+ Hash Join
+   Hash Cond: (r4t1.c1 = r4t1.c1)
+   ->  Seq Scan on t1 r4t1
+   ->  Hash
+         ->  Seq Scan on t1 r4t1
+(5 rows)
+
+/*+Leading(r4t1 r4t1)*/
+EXPLAIN (COSTS false) SELECT * FROM s1.r4 t1, s1.r4 t2 WHERE t1.c1 = t2.c1;
+INFO:  hint syntax error at or near "Leading(r4t1 r4t1)"
+DETAIL:  Relation name "r4t1" is ambiguous.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading(r4t1 r4t1)
+
+            QUERY PLAN            
+----------------------------------
+ Hash Join
+   Hash Cond: (r4t1.c1 = r4t1.c1)
+   ->  Seq Scan on t1 r4t1
+   ->  Hash
+         ->  Seq Scan on t1 r4t1
+(5 rows)
+
+-- No. L-2-3-7
+EXPLAIN (COSTS false) SELECT * FROM s1.r4 t1, s1.r5 t2 WHERE t1.c1 = t2.c1;
+            QUERY PLAN            
+----------------------------------
+ Hash Join
+   Hash Cond: (r4t1.c1 = r5t1.c1)
+   ->  Seq Scan on t1 r4t1
+   ->  Hash
+         ->  Seq Scan on t1 r5t1
+(5 rows)
+
+/*+Leading(r4t1 r5t1)*/
+EXPLAIN (COSTS false) SELECT * FROM s1.r4 t1, s1.r5 t2 WHERE t1.c1 = t2.c1;
+LOG:  pg_hint_plan:
+used hint:
+Leading(r4t1 r5t1)
+not used hint:
+duplication hint:
+error hint:
+
+            QUERY PLAN            
+----------------------------------
+ Hash Join
+   Hash Cond: (r4t1.c1 = r5t1.c1)
+   ->  Seq Scan on t1 r4t1
+   ->  Hash
+         ->  Seq Scan on t1 r5t1
+(5 rows)
+
 ----
 ---- No. L-2-4 VALUES clause
 ----
@@ -3421,23 +3591,24 @@ EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1')) AS t3 (c1,
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1')) AS t3 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1;
 LOG:  pg_hint_plan:
 used hint:
-Leading(t3 t1 t2)
 not used hint:
+Leading(t3 t1 t2)
 duplication hint:
 error hint:
 
-                 QUERY PLAN                  
----------------------------------------------
- Nested Loop
-   Join Filter: (t1.c1 = "*VALUES*".column1)
-   ->  Values Scan on "*VALUES*"
-   ->  Merge Join
-         Merge Cond: (t1.c1 = t2.c1)
-         ->  Index Scan using t1_i1 on t1
-         ->  Sort
-               Sort Key: t2.c1
+                      QUERY PLAN                       
+-------------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.c1 = t2.c1)
+   ->  Index Scan using t1_i1 on t1
+   ->  Sort
+         Sort Key: t2.c1
+         ->  Hash Join
+               Hash Cond: (t2.c1 = "*VALUES*".column1)
                ->  Seq Scan on t2
-(9 rows)
+               ->  Hash
+                     ->  Values Scan on "*VALUES*"
+(10 rows)
 
 /*+ Leading(*VALUES* t1 t2) */
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1')) AS t3 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1;
@@ -3483,26 +3654,27 @@ EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1')) AS t3 (c1,
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1')) AS t3 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t4 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
 LOG:  pg_hint_plan:
 used hint:
-Leading(t4 t3 t2 t1)
 not used hint:
+Leading(t4 t3 t2 t1)
 duplication hint:
 error hint:
 
-                           QUERY PLAN                           
-----------------------------------------------------------------
+                         QUERY PLAN                          
+-------------------------------------------------------------
  Nested Loop
    Join Filter: (t1.c1 = "*VALUES*".column1)
-   ->  Nested Loop
-         Join Filter: ("*VALUES*".column1 = "*VALUES*".column1)
-         ->  Values Scan on "*VALUES*"
-         ->  Values Scan on "*VALUES*"
    ->  Merge Join
          Merge Cond: (t1.c1 = t2.c1)
          ->  Index Scan using t1_i1 on t1
          ->  Sort
                Sort Key: t2.c1
-               ->  Seq Scan on t2
-(12 rows)
+               ->  Hash Join
+                     Hash Cond: (t2.c1 = "*VALUES*".column1)
+                     ->  Seq Scan on t2
+                     ->  Hash
+                           ->  Values Scan on "*VALUES*"
+   ->  Values Scan on "*VALUES*"
+(13 rows)
 
 /*+ Leading(*VALUES* t3 t2 t1) */
 EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, (VALUES(1,1,1,'1')) AS t3 (c1, c2, c3, c4), (VALUES(1,1,1,'1'), (2,2,2,'2')) AS t4 (c1, c2, c3, c4) WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
@@ -3511,9 +3683,9 @@ DETAIL:  Relation name "*VALUES*" is ambiguous.
 LOG:  pg_hint_plan:
 used hint:
 not used hint:
-Leading(*VALUES* t3 t2 t1)
 duplication hint:
 error hint:
+Leading(*VALUES* t3 t2 t1)
 
                          QUERY PLAN                          
 -------------------------------------------------------------
@@ -3993,13 +4165,11 @@ EXPLAIN (COSTS false) SELECT * FROM s1.t1
   JOIN s1.t3 ON (t1.c1 = t3.c1);
 INFO:  hint syntax error at or near "Leading()"
 DETAIL:  Leading hint requires at least two relations.
-INFO:  hint syntax error at or near "Leading(t2 t3 t1)Leading()"
-DETAIL:  Conflict leading hint.
 LOG:  pg_hint_plan:
 used hint:
+Leading(t2 t3 t1)
 not used hint:
 duplication hint:
-Leading(t2 t3 t1)
 error hint:
 Leading()
 
@@ -4007,14 +4177,15 @@ Leading()
 ------------------------------------------
  Merge Join
    Merge Cond: (t1.c1 = t2.c1)
-   ->  Merge Join
-         Merge Cond: (t1.c1 = t3.c1)
-         ->  Index Scan using t1_i1 on t1
-         ->  Index Scan using t3_i1 on t3
+   ->  Index Scan using t1_i1 on t1
    ->  Sort
          Sort Key: t2.c1
-         ->  Seq Scan on t2
-(9 rows)
+         ->  Hash Join
+               Hash Cond: (t3.c1 = t2.c1)
+               ->  Seq Scan on t3
+               ->  Hash
+                     ->  Seq Scan on t2
+(10 rows)
 
 -- No. L-3-4-4
 /*+Leading(t3 t1 t2)Leading(t2 t3 t1)Leading()*/
@@ -4025,14 +4196,12 @@ INFO:  hint syntax error at or near "Leading()"
 DETAIL:  Leading hint requires at least two relations.
 INFO:  hint syntax error at or near "Leading(t3 t1 t2)Leading(t2 t3 t1)Leading()"
 DETAIL:  Conflict leading hint.
-INFO:  hint syntax error at or near "Leading(t2 t3 t1)Leading()"
-DETAIL:  Conflict leading hint.
 LOG:  pg_hint_plan:
 used hint:
+Leading(t2 t3 t1)
 not used hint:
 duplication hint:
 Leading(t3 t1 t2)
-Leading(t2 t3 t1)
 error hint:
 Leading()
 
@@ -4040,14 +4209,15 @@ Leading()
 ------------------------------------------
  Merge Join
    Merge Cond: (t1.c1 = t2.c1)
-   ->  Merge Join
-         Merge Cond: (t1.c1 = t3.c1)
-         ->  Index Scan using t1_i1 on t1
-         ->  Index Scan using t3_i1 on t3
+   ->  Index Scan using t1_i1 on t1
    ->  Sort
          Sort Key: t2.c1
-         ->  Seq Scan on t2
-(9 rows)
+         ->  Hash Join
+               Hash Cond: (t3.c1 = t2.c1)
+               ->  Seq Scan on t3
+               ->  Hash
+                     ->  Seq Scan on t2
+(10 rows)
 
 ----
 ---- No. L-3-5 hint state output
@@ -4157,3 +4327,170 @@ error hint:
                      ->  Seq Scan on t2
 (10 rows)
 
+----
+---- No. L-3-6 specified Inner/Outer side
+----
+-- No. L-3-6-1
+/*+Leading((t2))*/
+EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+INFO:  hint syntax error at or near "Leading((t2))"
+DETAIL:  Leading hint requires two sets of relations when parentheses nests.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading((t2))
+
+                   QUERY PLAN                   
+------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.c1 = t2.c1)
+   ->  Merge Join
+         Merge Cond: (t1.c1 = t4.c1)
+         ->  Merge Join
+               Merge Cond: (t1.c1 = t3.c1)
+               ->  Index Scan using t1_i1 on t1
+               ->  Index Scan using t3_i1 on t3
+         ->  Index Scan using t4_i1 on t4
+   ->  Sort
+         Sort Key: t2.c1
+         ->  Seq Scan on t2
+(12 rows)
+
+-- No. L-3-6-2
+/*+Leading((t2 t3))*/
+EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+LOG:  pg_hint_plan:
+used hint:
+Leading((t2 t3))
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                   
+------------------------------------------------
+ Nested Loop
+   ->  Nested Loop
+         ->  Merge Join
+               Merge Cond: (t2.c1 = t3.c1)
+               ->  Index Scan using t2_i1 on t2
+               ->  Index Scan using t3_i1 on t3
+         ->  Index Scan using t1_i1 on t1
+               Index Cond: (c1 = t2.c1)
+   ->  Index Scan using t4_i1 on t4
+         Index Cond: (c1 = t1.c1)
+(10 rows)
+
+-- No. L-3-6-3
+/*+Leading((t2 t3 t4))*/
+EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+INFO:  hint syntax error at or near "Leading((t2 t3 t4))"
+DETAIL:  Leading hint requires two sets of relations when parentheses nests.
+LOG:  pg_hint_plan:
+used hint:
+not used hint:
+duplication hint:
+error hint:
+Leading((t2 t3 t4))
+
+                   QUERY PLAN                   
+------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.c1 = t2.c1)
+   ->  Merge Join
+         Merge Cond: (t1.c1 = t4.c1)
+         ->  Merge Join
+               Merge Cond: (t1.c1 = t3.c1)
+               ->  Index Scan using t1_i1 on t1
+               ->  Index Scan using t3_i1 on t3
+         ->  Index Scan using t4_i1 on t4
+   ->  Sort
+         Sort Key: t2.c1
+         ->  Seq Scan on t2
+(12 rows)
+
+-- No. L-3-6-4
+/*+Leading(((t1 t2) (t3 t4)))*/
+EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+LOG:  pg_hint_plan:
+used hint:
+Leading(((t1 t2) (t3 t4)))
+not used hint:
+duplication hint:
+error hint:
+
+                QUERY PLAN                
+------------------------------------------
+ Hash Join
+   Hash Cond: (t1.c1 = t3.c1)
+   ->  Merge Join
+         Merge Cond: (t1.c1 = t2.c1)
+         ->  Index Scan using t1_i1 on t1
+         ->  Sort
+               Sort Key: t2.c1
+               ->  Seq Scan on t2
+   ->  Hash
+         ->  Hash Join
+               Hash Cond: (t3.c1 = t4.c1)
+               ->  Seq Scan on t3
+               ->  Hash
+                     ->  Seq Scan on t4
+(14 rows)
+
+-- No. L-3-6-5
+/*+Leading((((t1 t3) t4) t2)))*/
+EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+INFO:  hint syntax error at or near ")"
+DETAIL:  Unrecognized hint keyword ")".
+LOG:  pg_hint_plan:
+used hint:
+Leading((((t1 t3) t4) t2))
+not used hint:
+duplication hint:
+error hint:
+
+                   QUERY PLAN                   
+------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.c1 = t2.c1)
+   ->  Merge Join
+         Merge Cond: (t1.c1 = t4.c1)
+         ->  Merge Join
+               Merge Cond: (t1.c1 = t3.c1)
+               ->  Index Scan using t1_i1 on t1
+               ->  Index Scan using t3_i1 on t3
+         ->  Index Scan using t4_i1 on t4
+   ->  Sort
+         Sort Key: t2.c1
+         ->  Seq Scan on t2
+(12 rows)
+
+-- No. L-3-6-6
+/*+Leading((t1 (t3 (t4 t2))))*/
+EXPLAIN (COSTS false) SELECT * FROM s1.t1, s1.t2, s1.t3, s1.t4 WHERE t1.c1 = t2.c1 AND t1.c1 = t3.c1 AND t1.c1 = t4.c1;
+LOG:  pg_hint_plan:
+used hint:
+Leading((t1 (t3 (t4 t2))))
+not used hint:
+duplication hint:
+error hint:
+
+                      QUERY PLAN                      
+------------------------------------------------------
+ Merge Join
+   Merge Cond: (t1.c1 = t2.c1)
+   ->  Index Scan using t1_i1 on t1
+   ->  Sort
+         Sort Key: t2.c1
+         ->  Hash Join
+               Hash Cond: (t3.c1 = t2.c1)
+               ->  Seq Scan on t3
+               ->  Hash
+                     ->  Hash Join
+                           Hash Cond: (t4.c1 = t2.c1)
+                           ->  Seq Scan on t4
+                           ->  Hash
+                                 ->  Seq Scan on t2
+(14 rows)
+