EOS
$plan_no = -1;
-$title = "###### Plan $plan_no: all properties";
+$title = "###### Plan $plan_no: all properties 1/2";
setplan0(0); # Without "Unknown Key"
print "($plan_no, \'$title\',\n";
print " $escape'$plan')";
$plan_no--;
-$title = "###### Plan $plan_no: all properties plus unknown key";
+$title = "###### Plan $plan_no: all properties 2/2";
+setplan1();
+print ",($plan_no, \'$title\',\n";
+print " $escape'$plan')";
+$plan_no--;
+
+$title = "###### Plan $plan_no: some properties plus unknown key";
setplan0(1); # With "Unknown Key"
print ",($plan_no, \'$title\',\n";
print " $escape'$plan')";
$plan_no = 1;
$state = 0;
+$indent = "";
while(<>) {
chomp;
if ($state == 0) {
$title = "###### Plan $plan_no: $1";
$state = 1;
} elsif ($state == 1) {
+ # edit auto_explain's result
+ next if (/^psql:makeplanfile.sql/);
+
if (/[}\]:,]/) {
die("??? : $_");
}
- next if (!/^ { *\+$/);
+ next if (!/^( *)\{ *\+?$/);
+ $indent = $1;
$plan = $_;
$plan =~ s/^ (.*[^ ]) *\+$/$1\n/;
+ chomp($plan);
+ $plan .= "\n";
$state = 2;
} elsif ($state == 2) {
- if (/^ } *\+$/) {
+ # edit auto_explain's result
+ next if (/^ "Query Text":/);
+
+ if (/^$indent} *\+?$/) {
$state = 3;
}
$l = $_;
UPDATE plans SET splan = pg_store_plans_shorten(lplan);
\echo ###### tag abbreviation test
-SELECT splan FROM plans WHERE id = -1;
+SELECT splan FROM plans WHERE id in (-1, -2);
-\echo ###### JSON properties round-trip test
+\echo ###### JSON properties round-trip test: !!! This shouldn''''t return a row
SELECT id FROM plans
where pg_store_plans_jsonplan(splan) <> lplan;
\echo ###### text format output test
SELECT '### '||'TEXT-short '||title||E'\n'||
pg_store_plans_textplan(splan)
- FROM plans ORDER BY id;
+ FROM plans WHERE id >= 0 ORDER BY id;
+
\echo ###### long-json-as-a-source test
SELECT '### '||'yaml-long JSON '||title||E'\n'||
\echo ###### normalize test
SELECT '### '||'normalize '||title||E'\n'||
pg_store_plans_normalize(lplan)
- FROM plans WHERE id BETWEEN 1 AND 7 ORDER BY id;
+ FROM plans ORDER BY id;
EOS
"Node Type": "Function Scan",
"Node Type": "Values Scan",
"Node Type": "CTE Scan",
- "Node Type": "Workable Scan",
+ "Node Type": "WorkTable Scan",
"Node Type": "Foreign Scan",
"Node Type": "Nested Loop",
"Node Type": "Merge Join",
"Node Type": "SetOp",
"Node Type": "LockRows",
"Node Type": "Limit",
+ "Node Type": "Sample Scan",
+ "Node Type": "Gather",
+ "Node Type": "ProjectSet",
+ "Node Type": "Table Function Scan",
+ "Node Type": "Named Tuplestore Scan",
+ "Node Type": "Gather Merge",
"Parent Relationship": "Outer",
"Parent Relationship": "Inner",
"Parent Relationship": "Subquery",
"Strategy": "Plain",
"Strategy": "Sorted",
"Strategy": "Hashed",
+ "Strategy": "Mixed",
"Join Type": "Inner",
"Join Type": "Left",
"Join Type": "Full",
"Sort Method": "external merge",
"Sort Method": "still in progress",
"Sort Key": "a",
+ "Group Key": "a",
+ "Grouping Sets": "a",
+ "Group Keys": "a",
+ "Hash Keys": "a",
+ "Hash Key": "a",
+ "Parallel Aware": "true",
+ "Workers Planned": "0",
+ "Workers Launched": "0",
+ "Workers": "x",
+ "Worker Number": "0",
+ "Async Capable": "false",
"Filter": "a",
"Join Filter": "a",
"Hash Cond": "a",
"Index Cond": "a",
"TID Cond": "a",
"Recheck Cond": "a",
+ "Conflict Resolution": "a",
+ "Conflict Arbiter Indexes": "a",
+ "Tuples Inserted": 0,
+ "Conflicting Tuples": 0,
+ "Target Tables": "a",
"Operation": "Insert",
"Operation": "Delete",
"Operation": "Update",
"Sort Space Type": "Memory",
"Peak Memory Usage": 0,
"Original Hash Batches": 0,
+ "Original Hash Buckets": 0
+EOS
+chop $plan;
+if ($addunknown) {
+ $plan .= ",\n \"Unknown Key\": \"Unknown Value\"";
+}
+$plan .= "\n}";
+
+}
+
+sub setplan1 {
+ my($addunknown) = @_;
+ $plan = << 'EOS';
+{
"Hash Batches": 0,
"Hash Buckets": 0,
"Rows Removed by Filter": 0,
"Execution Time": 0,
"Exact Heap Blocks": 0,
"Lossy Heap Blocks": 0,
- "Rows Removed by Join Filter": 0
+ "Rows Removed by Join Filter": 0,
+ "Target Tables": "dummy",
+ "Conflict Resolution": "NOTHING",
+ "Conflict Arbiter Indexes": "ia",
+ "Tuples Inserted": 123,
+ "Conflicting Tuples": 234,
+ "Sampling Method": "system",
+ "Sampling Parameters": ["''10''::real"],
+ "Repeatable Seed": "''0''::double precision",
+ "Workers": "dummy",
+ "Worker Number": 0,
+ "Async Capable": 0
EOS
-chop $plan;
-if ($addunknown) {
- $plan .= ",\n \"Unknown Key\": \"Unknown Value\"";
-}
-$plan .= "\n}";
+
+# Avoid trailing new line
+$plan .= "}";
}
+
+