Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions client/tablet.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ func (t *Tablet) SetTimestamp(timestamp int64, rowIndex int) {

func (t *Tablet) SetValueAt(value interface{}, columnIndex, rowIndex int) error {

if columnIndex < 0 || columnIndex > len(t.measurementSchemas) {
if columnIndex < 0 || columnIndex >= len(t.measurementSchemas) {
return fmt.Errorf("illegal argument columnIndex %d", columnIndex)
}

if rowIndex < 0 || rowIndex > t.maxRowNumber {
if rowIndex < 0 || rowIndex >= t.maxRowNumber {
return fmt.Errorf("illegal argument rowIndex %d", rowIndex)
}

Expand Down Expand Up @@ -221,11 +221,11 @@ func (t *Tablet) GetMaxRowNumber() int {
}

func (t *Tablet) GetValueAt(columnIndex, rowIndex int) (interface{}, error) {
if columnIndex < 0 || columnIndex > len(t.measurementSchemas) {
if columnIndex < 0 || columnIndex >= len(t.measurementSchemas) {
return nil, fmt.Errorf("illegal argument columnIndex %d", columnIndex)
}

if rowIndex < 0 || rowIndex > t.maxRowNumber {
if rowIndex < 0 || rowIndex >= t.maxRowNumber {
return nil, fmt.Errorf("illegal argument rowIndex %d", rowIndex)
}

Expand Down
30 changes: 30 additions & 0 deletions client/tablet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@ func TestTablet_SetValueAt(t *testing.T) {
rowIndex: 0,
},
wantErr: true,
}, {
name: "columnIndex-out-of-range-boundary",
args: args{
value: 0,
columnIndex: 10,
rowIndex: 0,
},
wantErr: true,
}, {
name: "rowIndex-out-of-range-boundary",
args: args{
value: 0,
columnIndex: 0,
rowIndex: 1,
},
wantErr: true,
}, {
name: "restart_count",
args: args{
Expand Down Expand Up @@ -410,6 +426,20 @@ func TestTablet_GetValueAt(t *testing.T) {
},
want: int64(1608268702780),
wantErr: false,
}, {
name: "columnIndex-out-of-range-boundary",
args: args{
columnIndex: 10,
rowIndex: 0,
},
wantErr: true,
}, {
name: "rowIndex-out-of-range-boundary",
args: args{
columnIndex: 0,
rowIndex: 1,
},
wantErr: true,
},
}
if tablet, err := createTablet(1); err == nil {
Expand Down