Skip to content

Commit

Permalink
Merge pull request #40829 from jordanlewis/backport19.1-37597
Browse files Browse the repository at this point in the history
release-19.1: sql: apply join outer cols must be typed null
  • Loading branch information
jordanlewis authored Sep 18, 2019
2 parents d3858f1 + d0b6bc5 commit d6a7e59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/apply_join
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,13 @@ FROM
----
NULL
NULL

# Regression test for #37454: untyped null produced at top level.

statement ok
CREATE TABLE x (a INT8); CREATE TABLE y (b INT8); INSERT INTO x VALUES (1); INSERT INTO y VALUES (2);

query II
SELECT a, (SELECT a FROM y) FROM x
----
1 1
6 changes: 5 additions & 1 deletion pkg/sql/opt/exec/execbuilder/scalar_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ func (b *Builder) indexedVar(
idx, ok := ctx.ivarMap.Get(int(colID))
if !ok {
if b.nullifyMissingVarExprs > 0 {
return tree.DNull
expr, err := tree.ReType(tree.DNull, md.ColumnMeta(colID).Type)
if err != nil {
panic(pgerror.NewAssertionErrorf("unexpected failure during ReType: %v", err))
}
return expr
}
panic(pgerror.NewAssertionErrorf("cannot map variable %d to an indexed var", log.Safe(colID)))
}
Expand Down

0 comments on commit d6a7e59

Please sign in to comment.