Skip to content

Commit

Permalink
tree: fix panic when encoding tuple
Browse files Browse the repository at this point in the history
This adds a bounds check to avoid a panic.

Release note (bug fix): Fixed a crash that could happen when formatting
a tuple with an unknown type.
  • Loading branch information
rafiss committed Jan 10, 2023
1 parent 6753f7f commit 9cc6a9e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/sql/sem/tree/pgwire_encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ func (d *DTuple) pgwireFormat(ctx *FmtCtx) {
comma := ""
for i, v := range d.D {
ctx.WriteString(comma)
t := d.ResolvedType().TupleContents()[i]
t := v.ResolvedType()
if tc := d.ResolvedType().TupleContents(); i < len(tc) {
t = tc[i]
}
switch dv := UnwrapDOidWrapper(v).(type) {
case dNull:
case *DString:
Expand Down

0 comments on commit 9cc6a9e

Please sign in to comment.