Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-2.1: distsqlplan: fix error in union planning #34913

Merged
merged 1 commit into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions pkg/sql/distsqlplan/physical_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,22 @@ func (p *PhysicalPlan) CheckLastStagePost() error {
// verify this assumption.
for i := 1; i < len(p.ResultRouters); i++ {
pi := &p.Processors[p.ResultRouters[i]].Spec.Post
if pi.Filter != post.Filter || pi.Projection != post.Projection ||
len(pi.OutputColumns) != len(post.OutputColumns) {
if pi.Filter != post.Filter ||
pi.Projection != post.Projection ||
len(pi.OutputColumns) != len(post.OutputColumns) ||
len(pi.RenderExprs) != len(post.RenderExprs) {
return errors.Errorf("inconsistent post-processing: %v vs %v", post, pi)
}
for j, col := range pi.OutputColumns {
if col != post.OutputColumns[j] {
return errors.Errorf("inconsistent post-processing: %v vs %v", post, pi)
}
}
for j, col := range pi.RenderExprs {
if col != post.RenderExprs[j] {
return errors.Errorf("inconsistent post-processing: %v vs %v", post, pi)
}
}
}

return nil
Expand Down
13 changes: 13 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/sqlsmith
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,16 @@ CREATE TABLE a (a INT PRIMARY KEY);

statement ok
SELECT true FROM (SELECT ref_1.a AS c0 FROM crdb_internal.cluster_queries AS ref_0 JOIN a AS ref_1 ON (ref_0.node_id = ref_1.a) WHERE (SELECT a from a limit 1 offset 1) is null);

# Regression: #34437 (union all could produce panic in distsql planning)

statement ok
CREATE TABLE table8 (col1 TIME, col2 BYTES, col4 OID, col6 NAME, col9 TIMESTAMP, PRIMARY KEY (col1));

statement ok
CREATE TABLE table5 (col0 TIME NULL, col1 OID, col3 INET, PRIMARY KEY (col1 ASC));

statement ok
INSERT INTO table8 (col1, col2, col4, col6)
VALUES ('19:06:18.321589', NULL, NULL, NULL)
UNION ALL (SELECT NULL, NULL, NULL, NULL FROM table5 AS tab_8);
5 changes: 5 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/union
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ query I
SELECT a FROM a WHERE a > 2 UNION ALL (SELECT a FROM c WHERE b > 2) LIMIT 1;
----

query III
select *,1 from (values(1,2) union all select 2,2 from c);
----
1 2 1

statement ok
INSERT INTO a VALUES (1)

Expand Down