Skip to content

Commit

Permalink
Merge #40616
Browse files Browse the repository at this point in the history
40616: sql: fix getPlanColumns for hookFnNode r=RaduBerinde a=RaduBerinde

`getPlanColumns` allows the caller to directly mutate the columns of a
`hookFnNode`; but these columns can be defined globally and should not
be modified in place.

Fixes #40585.

Release note: None

Co-authored-by: Radu Berinde <radu@cockroachlabs.com>
  • Loading branch information
craig[bot] and RaduBerinde committed Sep 10, 2019
2 parents 3ad8bda + bdb9b87 commit a41355d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/sql/plan_columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func getPlanColumns(plan planNode, mut bool) sqlbase.ResultColumns {
return n.columns
case *groupNode:
return n.columns
case *hookFnNode:
return n.header
case *joinNode:
return n.columns
case *ordinalityNode:
Expand Down Expand Up @@ -120,6 +118,11 @@ func getPlanColumns(plan planNode, mut bool) sqlbase.ResultColumns {
case *exportNode:
return n.getColumns(mut, sqlbase.ExportColumns)

// The columns in the hookFnNode are returned by the hook function; we don't
// know if they can be modified in place or not.
case *hookFnNode:
return n.getColumns(mut, n.header)

// Nodes that have the same schema as their source or their
// valueNode helper.
case *bufferNode:
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/planhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ func AddWrappedPlanHook(f wrappedPlanHookFn) {
// provided function during Start and serves the results it returns over the
// channel.
type hookFnNode struct {
optColumnsSlot

f PlanHookRowFn
header sqlbase.ResultColumns
subplans []planNode
Expand Down

0 comments on commit a41355d

Please sign in to comment.