PDGGK opened a new pull request, #169:
URL: https://github.com/apache/iotdb-client-go/pull/169

   ## Problem
   
   Thanks @HTHou — you noted in #168 that `Tablet.SetTimestamp` writes to
   `t.timestamps[rowIndex]` without validating `rowIndex`, so an out-of-range
   row panics with an index-out-of-range error instead of returning one. For
   example, with a tablet created via `NewTablet(..., 1)` (only row index 0 is
   valid), `SetTimestamp(ts, 1)` panics.
   
   ## Fix
   
   Apply the same bounds check `SetValueAt` and `GetValueAt` already use,
   returning an `illegal argument rowIndex` error for a negative or
   out-of-range row:
   
   ```go
   func (t *Tablet) SetTimestamp(timestamp int64, rowIndex int) error {
        if rowIndex < 0 || rowIndex >= t.maxRowNumber {
                return fmt.Errorf("illegal argument rowIndex %d", rowIndex)
        }
        t.timestamps[rowIndex] = timestamp
        return nil
   }
   ```
   
   You noted this needs an API decision, since `SetTimestamp` has no error
   return. I've taken the consistency direction your comment pointed to:
   `SetTimestamp` now returns an `error`, matching `SetValueAt` / `GetValueAt`.
   It is a signature change, but source-compatible for the common
   statement-form call — the examples already invoke `SetValueAt` that way —
   and `go build ./...` passes unchanged. If you'd prefer a non-breaking shape
   instead, I'm happy to switch.
   
   ## Tests
   
   Added `TestTablet_SetTimestampRowIndexBounds`: a valid row index returns no
   error; out-of-range indices (1 on a one-row tablet, and -1) return an error
   instead of panicking. `go build ./...` and `go test ./client/` pass.
   
   Follow-up to #168.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to