提交 67c79899 编写于 作者: H Heikki Linnakangas

Move test for an old ORCA EXPLAIN bug to main test suite.

上级 4debd98c
-- Helper function, to return the EXPLAIN ANALYZE output of a query as a normal
-- Helper function, to return the EXPLAIN output of a query as a normal
-- result set, so that you can manipulate it further.
create or replace function get_explain_output(explain_query text) returns setof text as
$$
declare
explainrow text;
begin
for explainrow in execute 'EXPLAIN ' || explain_query
loop
return next explainrow;
end loop;
end;
$$ language plpgsql;
-- Same, for EXPLAIN ANALYZE
create or replace function get_explain_analyze_output(explain_query text) returns setof text as
$$
declare
explainrow text;
begin
......@@ -37,7 +49,7 @@ set explain_memory_verbosity='summary';
-- The plan should consist of a Gather and a Seq Scan, with a
-- "Memory: ..." line on both nodes.
SELECT COUNT(*) from
get_explain_output($$
get_explain_analyze_output($$
SELECT * FROM explaintest;
$$) as et
WHERE et like '%Memory: %';
......@@ -46,3 +58,55 @@ WHERE et like '%Memory: %';
2
(1 row)
reset explain_memory_verbosity;
-- Verify that the column references are OK. This tests for an old ORCA bug,
-- where the Filter clause in the IndexScan of this query was incorrectly
-- printed as something like:
--
-- Filter: "outer".column2 = mpp22263.*::text
CREATE TABLE mpp22263 (
unique1 int4,
unique2 int4,
two int4,
four int4,
ten int4,
twenty int4,
hundred int4,
thousand int4,
twothousand int4,
fivethous int4,
tenthous int4,
odd int4,
even int4,
stringu1 name,
stringu2 name,
string4 name
) distributed by (unique1);
create index mpp22263_idx1 on mpp22263 using btree(unique1);
explain
select * from mpp22263, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j)
WHERE mpp22263.unique1 = v.i and mpp22263.stringu1 = v.j;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=0.06..278.70 rows=14 width=280)
-> Hash Join (cost=0.06..278.70 rows=5 width=280)
Hash Cond: mpp22263.unique1 = "*VALUES*".column1 AND mpp22263.stringu1::text = "*VALUES*".column2
-> Seq Scan on mpp22263 (cost=0.00..219.00 rows=3967 width=244)
-> Hash (cost=0.03..0.03 rows=1 width=36)
-> Values Scan on "*VALUES*" (cost=0.00..0.03 rows=1 width=36)
Optimizer status: legacy query optimizer
(7 rows)
-- atmsort.pm masks out differences in the Filter line, so just memorizing
-- the output of the above EXPLAIN isn't enough to catch a faulty Filter line.
-- Extract the Filter explicitly.
SELECT * from
get_explain_output($$
select * from mpp22263, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j)
WHERE mpp22263.unique1 = v.i and mpp22263.stringu1 = v.j;
$$) as et
WHERE et like '%Filter: %';
et
----
(0 rows)
-- Helper function, to return the EXPLAIN ANALYZE output of a query as a normal
-- Helper function, to return the EXPLAIN output of a query as a normal
-- result set, so that you can manipulate it further.
create or replace function get_explain_output(explain_query text) returns setof text as
$$
declare
explainrow text;
begin
for explainrow in execute 'EXPLAIN ' || explain_query
loop
return next explainrow;
end loop;
end;
$$ language plpgsql;
-- Same, for EXPLAIN ANALYZE
create or replace function get_explain_analyze_output(explain_query text) returns setof text as
$$
declare
explainrow text;
begin
......@@ -39,7 +51,7 @@ set explain_memory_verbosity='summary';
-- The plan should consist of a Gather and a Seq Scan, with a
-- "Memory: ..." line on both nodes.
SELECT COUNT(*) from
get_explain_output($$
get_explain_analyze_output($$
SELECT * FROM explaintest;
$$) as et
WHERE et like '%Memory: %';
......@@ -48,3 +60,63 @@ WHERE et like '%Memory: %';
2
(1 row)
reset explain_memory_verbosity;
-- Verify that the column references are OK. This tests for an old ORCA bug,
-- where the Filter clause in the IndexScan of this query was incorrectly
-- printed as something like:
--
-- Filter: "outer".column2 = mpp22263.*::text
CREATE TABLE mpp22263 (
unique1 int4,
unique2 int4,
two int4,
four int4,
ten int4,
twenty int4,
hundred int4,
thousand int4,
twothousand int4,
fivethous int4,
tenthous int4,
odd int4,
even int4,
stringu1 name,
stringu2 name,
string4 name
) distributed by (unique1);
create index mpp22263_idx1 on mpp22263 using btree(unique1);
explain
select * from mpp22263, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j)
WHERE mpp22263.unique1 = v.i and mpp22263.stringu1 = v.j;
QUERY PLAN
--------------------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..2.00 rows=1 width=256)
-> Nested Loop (cost=0.00..2.00 rows=1 width=256)
Join Filter: true
-> Append (cost=0.00..0.00 rows=1 width=12)
-> Result (cost=0.00..0.00 rows=1 width=12)
-> Result (cost=0.00..0.00 rows=1 width=12)
-> Result (cost=0.00..0.00 rows=1 width=12)
-> Result (cost=0.00..0.00 rows=1 width=12)
-> Index Scan using mpp22263_idx1 on mpp22263 (cost=0.00..2.00 rows=1 width=244)
Index Cond: mpp22263.unique1 = (147)
Filter: mpp22263.stringu1::text = ('RFAAAA'::text)
Settings: optimizer=on
Optimizer status: PQO version 2.7.0
(13 rows)
-- atmsort.pm masks out differences in the Filter line, so just memorizing
-- the output of the above EXPLAIN isn't enough to catch a faulty Filter line.
-- Extract the Filter explicitly.
SELECT * from
get_explain_output($$
select * from mpp22263, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j)
WHERE mpp22263.unique1 = v.i and mpp22263.stringu1 = v.j;
$$) as et
WHERE et like '%Filter: %';
et
------------------------------------------------------------------
Join Filter: true
Filter: mpp22263.stringu1::text = ('RFAAAA'::text)
(2 rows)
-- Helper function, to return the EXPLAIN ANALYZE output of a query as a normal
-- Helper function, to return the EXPLAIN output of a query as a normal
-- result set, so that you can manipulate it further.
create or replace function get_explain_output(explain_query text) returns setof text as
$$
declare
explainrow text;
begin
for explainrow in execute 'EXPLAIN ' || explain_query
loop
return next explainrow;
end loop;
end;
$$ language plpgsql;
-- Same, for EXPLAIN ANALYZE
create or replace function get_explain_analyze_output(explain_query text) returns setof text as
$$
declare
explainrow text;
begin
......@@ -27,7 +40,51 @@ set explain_memory_verbosity='summary';
-- The plan should consist of a Gather and a Seq Scan, with a
-- "Memory: ..." line on both nodes.
SELECT COUNT(*) from
get_explain_output($$
get_explain_analyze_output($$
SELECT * FROM explaintest;
$$) as et
WHERE et like '%Memory: %';
reset explain_memory_verbosity;
-- Verify that the column references are OK. This tests for an old ORCA bug,
-- where the Filter clause in the IndexScan of this query was incorrectly
-- printed as something like:
--
-- Filter: "outer".column2 = mpp22263.*::text
CREATE TABLE mpp22263 (
unique1 int4,
unique2 int4,
two int4,
four int4,
ten int4,
twenty int4,
hundred int4,
thousand int4,
twothousand int4,
fivethous int4,
tenthous int4,
odd int4,
even int4,
stringu1 name,
stringu2 name,
string4 name
) distributed by (unique1);
create index mpp22263_idx1 on mpp22263 using btree(unique1);
explain
select * from mpp22263, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j)
WHERE mpp22263.unique1 = v.i and mpp22263.stringu1 = v.j;
-- atmsort.pm masks out differences in the Filter line, so just memorizing
-- the output of the above EXPLAIN isn't enough to catch a faulty Filter line.
-- Extract the Filter explicitly.
SELECT * from
get_explain_output($$
select * from mpp22263, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j)
WHERE mpp22263.unique1 = v.i and mpp22263.stringu1 = v.j;
$$) as et
WHERE et like '%Filter: %';
-- start_ignore
SET optimizer_log=on;
SET
SET optimizer_enable_indexjoin=on;
SET
SET optimizer=on;
SET
SET optimizer_log=on;
SET
-- end_ignore
-- @author onosen
-- @created 2015-01-08 18:00:00
-- @tags ORCA bfv
-- @gpopt 1.522
-- @description bfv for MPP-22263
\!grep 'Filter: mpp22263.stringu1::text = "outer".column2'
Filter: mpp22263.stringu1::text = "outer".column2
\!grep 'Filter: mpp22263.stringu1::text = "outer".column2'
-- start_matchsubs
m/\\\!grep 'Filter: mpp22263.stringu1::text = "outer".column2'.*/
s/\\\!grep 'Filter: mpp22263.stringu1::text = "outer".column2'.*/\!grep 'Filter: mpp22263.stringu1::text = "outer".column2'/
-- end_matchsubs
\ No newline at end of file
-- @author onosen
-- @created 2015-01-08 18:00:00
-- @tags ORCA bfv
-- @gpopt 1.522
-- @description bfv for MPP-22263
-- @skip MPP-22263
--start_ignore
explain
select * from mpp22263, (values(147, 'RFAAAA'), (931, 'VJAAAA')) as v (i, j)
WHERE mpp22263.unique1 = v.i and mpp22263.stringu1 = v.j;
--end_ignore
\!grep 'Filter: mpp22263.stringu1::text = "outer".column2' %MYD%/output_bfv_other/mpp22263_orca.out
drop table if exists mpp22263;
CREATE TABLE mpp22263 (
unique1 int4,
unique2 int4,
two int4,
four int4,
ten int4,
twenty int4,
hundred int4,
thousand int4,
twothousand int4,
fivethous int4,
tenthous int4,
odd int4,
even int4,
stringu1 name,
stringu2 name,
string4 name
) distributed by (unique1);
create index mpp22263_idx1 on mpp22263 using btree(unique1);
......@@ -22,21 +22,3 @@ class Bfv_IndexApply_index_on_nondist_int(IndexApplyTestCase):
out_dir = 'output_bfv_index_on_nondist_int/'
template_dir = 'template'
template_subs = {'%MYD%':MYD, '%idxtype%':'btree', '%datatype%':'int', '%xDIST%':'i', '%yDIST%':'i', '%xIDX%':'NONE' , '%yIDX%':'j', '%ADD%':'+', '%xPART%':'', '%yPART%':''}
class Bfv_IndexApply_Other(SQLTestCase):
'''
tests for other BFVs that don't fit the scenario from IndexApplyTestCase
@optimizer_mode on
@gucs optimizer_enable_indexjoin=on; optimizer_log=on
@product_version gpdb: [4.3.3-]
'''
sql_dir = 'sql_bfv_other/'
ans_dir = 'expected_bfv_other/'
out_dir = 'output_bfv_other/'
@classmethod
def get_substitutions(self):
MYD = os.path.dirname(os.path.realpath(__file__))
substitutions = { '%MYD%' : MYD }
return substitutions
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册