Skip to content

Commit

Permalink
sql: fix getPlanColumns for hookFnNode
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
RaduBerinde committed Sep 10, 2019
1 parent 55294cf commit bdb9b87
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 bdb9b87

Please sign in to comment.