Skip to content

Commit

Permalink
changefeedccl: fix avro buglet
Browse files Browse the repository at this point in the history
Classic "taking the address of a for-loop local variable buglet". Was
breaking any columns with width or precision set.

Closes #32471

Release note (bug fix): experimental_avro CHANGEFEEDs now work with
column WIDTHs and PRECISIONs
  • Loading branch information
danhhz committed Nov 19, 2018
1 parent 5449f84 commit 2efb998
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/ccl/changefeedccl/avro.go
Expand Up @@ -252,6 +252,7 @@ func tableToAvroSchema(tableDesc *sqlbase.TableDescriptor) (*avroSchemaRecord, e
colIdxByFieldIdx: make(map[int]int),
}
for colIdx, col := range tableDesc.Columns {
col := col
field, err := columnDescToAvroSchema(&col)
if err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions pkg/ccl/changefeedccl/avro_test.go
Expand Up @@ -190,6 +190,11 @@ func TestAvroSchema(t *testing.T) {
schema: `(a INT PRIMARY KEY, b STRING)`,
values: `(1, 'a')`,
},
{
name: `MULTI_WIDTHS`,
schema: `(a INT PRIMARY KEY, b DECIMAL (3,2), c DECIMAL (2, 1))`,
values: `(1, 1.23, 4.5)`,
},
}
// Generate a test for each column type with a random datum of that type.
for semTypeID, semTypeName := range sqlbase.ColumnType_SemanticType_name {
Expand Down

0 comments on commit 2efb998

Please sign in to comment.