Skip to content

Commit 3d6a1eb

Browse files
craig[bot]jordanlewis
craig[bot]
andcommitted
Merge #39441
39441: row: fix decoding bug with cfetcher and wide rows r=jordanlewis a=jordanlewis CFetcher was failing to properly decode value columns of tables that had more than 8 columns due to an indexing bug that only manifested when the value tag (the column id and tag, encoded as a varint) was more than a single byte, which only occurs when the column id or type id is large enough. I'm not quite sure how this didn't come up before, since TPCH has tables with more than 8 columns. Updates #38288. Release note: None Co-authored-by: Jordan Lewis <[email protected]>
2 parents 2b23499 + 40ace00 commit 3d6a1eb

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

pkg/sql/logictest/testdata/logic_test/select

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,3 +624,19 @@ CREATE TABLE nocols(x INT); ALTER TABLE nocols DROP COLUMN x
624624
query I
625625
SELECT 1, * FROM nocols
626626
----
627+
628+
# ------------------------------------------------------------------------------
629+
# Wide tables can tickle edge cases.
630+
# ------------------------------------------------------------------------------
631+
632+
statement ok
633+
CREATE TABLE wide (id INT4 NOT NULL, a INT4, b VARCHAR(255), c INT4, d VARCHAR(255), e VARCHAR(255), f INT4, g VARCHAR(255), h VARCHAR(255), i VARCHAR(255), j VARCHAR(255), k INT4,
634+
l FLOAT4, m FLOAT8, n INT2, PRIMARY KEY (id))
635+
636+
statement ok
637+
INSERT INTO wide(id, n) VALUES(0, 10)
638+
639+
query IITITTITTTTIFFI
640+
SELECT * FROM wide
641+
----
642+
0 NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL 10

pkg/sql/row/cfetcher.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,15 +1007,15 @@ func (rf *CFetcher) processValueBytes(
10071007
}
10081008

10091009
var (
1010-
colIDDiff uint32
1011-
lastColID sqlbase.ColumnID
1012-
typeOffset, dataOffset int
1013-
typ encoding.Type
1014-
lastColIDIndex int
1015-
lastNeededColIndex int
1010+
colIDDiff uint32
1011+
lastColID sqlbase.ColumnID
1012+
dataOffset int
1013+
typ encoding.Type
1014+
lastColIDIndex int
1015+
lastNeededColIndex int
10161016
)
10171017
for len(valueBytes) > 0 && rf.machine.remainingValueColsByIdx.Len() > 0 {
1018-
typeOffset, dataOffset, colIDDiff, typ, err = encoding.DecodeValueTag(valueBytes)
1018+
_, dataOffset, colIDDiff, typ, err = encoding.DecodeValueTag(valueBytes)
10191019
if err != nil {
10201020
return "", "", err
10211021
}
@@ -1062,7 +1062,7 @@ func (rf *CFetcher) processValueBytes(
10621062

10631063
valTyp := &table.cols[idx].Type
10641064
valueBytes, err = colencoding.DecodeTableValueToCol(vec, rf.machine.rowIdx, typ, dataOffset, valTyp,
1065-
valueBytes[typeOffset:])
1065+
valueBytes)
10661066
if err != nil {
10671067
return "", "", err
10681068
}

0 commit comments

Comments
 (0)