OSDN Git Service

プランナを再帰的に呼び出す場合の試験用ファイルを作成した
authorTakashi Suzuki <suzuki.takashi@metrosystems.co.jp>
Fri, 2 Nov 2012 06:48:52 +0000 (15:48 +0900)
committerTakashi Suzuki <suzuki.takashi@metrosystems.co.jp>
Fri, 2 Nov 2012 06:48:52 +0000 (15:48 +0900)
Makefile
expected/ut-A2.out [new file with mode: 0644]
sql/ut-A2.sql [new file with mode: 0644]

index a4c1418..944a940 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@
 #
 
 MODULES = pg_hint_plan
-REGRESS = init base_plan pg_hint_plan prepare fdw ut-init ut-A ut-S ut-J ut-L ut-G ut-fini
+REGRESS = init base_plan pg_hint_plan prepare fdw ut-init ut-A ut-A2 ut-S ut-J ut-L ut-G ut-fini
 #REGRESS = ut-init ut-J ut-fini
 
 EXTRA_CLEAN = sql/fdw.sql expected/base_plan.out expected/prepare.out expected/fdw.out
diff --git a/expected/ut-A2.out b/expected/ut-A2.out
new file mode 100644 (file)
index 0000000..4d704e1
--- /dev/null
@@ -0,0 +1,51 @@
+LOAD 'pg_hint_plan';
+SET pg_hint_plan.enable TO on;
+SET pg_hint_plan.debug_print TO on;
+SET client_min_messages TO LOG;
+SET search_path TO public;
+----
+---- No. A-13 call planner recursively
+----
+CREATE OR REPLACE FUNCTION nested_planner(cnt int) RETURNS int AS $$
+DECLARE
+    new_cnt int;
+BEGIN
+    RAISE NOTICE 'nested_planner(%)', cnt;
+
+    /* 再帰終了の判断 */
+    IF cnt <= 1 THEN
+        RETURN 0;
+    END IF;
+
+    EXECUTE '/*+ IndexScan(t_1) */'
+            ' SELECT nested_planner($1) FROM s1.t1 t_1'
+            ' JOIN s1.t2 t_2 ON (t_1.c1 = t_2.c1)'
+            ' ORDER BY t_1.c1 LIMIT 1'
+        INTO new_cnt USING cnt - 1;
+
+    RETURN new_cnt;
+END;
+$$ LANGUAGE plpgsql IMMUTABLE;
+----
+---- No. A-13-2 use hint of main query
+----
+--No.13-2-1
+--No.13-2-2
+--No.13-2-3
+----
+---- No. A-13-3 output number of times of debugging log
+----
+--No.13-3-1
+--No.13-3-2
+--No.13-3-3
+----
+---- No. A-13-4 output of debugging log on hint status
+----
+--No.13-4-1
+--No.13-4-2
+--No.13-4-3
+--No.13-4-4
+--No.13-4-5
+--No.13-4-6
+--No.13-4-7
+--No.13-4-8
diff --git a/sql/ut-A2.sql b/sql/ut-A2.sql
new file mode 100644 (file)
index 0000000..3984a92
--- /dev/null
@@ -0,0 +1,70 @@
+LOAD 'pg_hint_plan';
+SET pg_hint_plan.enable TO on;
+SET pg_hint_plan.debug_print TO on;
+SET client_min_messages TO LOG;
+SET search_path TO public;
+
+----
+---- No. A-13 call planner recursively
+----
+
+CREATE OR REPLACE FUNCTION nested_planner(cnt int) RETURNS int AS $$
+DECLARE
+    new_cnt int;
+BEGIN
+    RAISE NOTICE 'nested_planner(%)', cnt;
+
+    /* 再帰終了の判断 */
+    IF cnt <= 1 THEN
+        RETURN 0;
+    END IF;
+
+    EXECUTE '/*+ IndexScan(t_1) */'
+            ' SELECT nested_planner($1) FROM s1.t1 t_1'
+            ' JOIN s1.t2 t_2 ON (t_1.c1 = t_2.c1)'
+            ' ORDER BY t_1.c1 LIMIT 1'
+        INTO new_cnt USING cnt - 1;
+
+    RETURN new_cnt;
+END;
+$$ LANGUAGE plpgsql IMMUTABLE;
+
+----
+---- No. A-13-2 use hint of main query
+----
+
+--No.13-2-1
+
+--No.13-2-2
+
+--No.13-2-3
+
+----
+---- No. A-13-3 output number of times of debugging log
+----
+
+--No.13-3-1
+
+--No.13-3-2
+
+--No.13-3-3
+
+----
+---- No. A-13-4 output of debugging log on hint status
+----
+
+--No.13-4-1
+
+--No.13-4-2
+
+--No.13-4-3
+
+--No.13-4-4
+
+--No.13-4-5
+
+--No.13-4-6
+
+--No.13-4-7
+
+--No.13-4-8