Skip to content

Commit f757102

Browse files
committed
fix: check for error after calling Next()
1 parent a24cf7f commit f757102

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

spannerlib/api/rows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ func (rows *rows) Next(ctx context.Context) (*structpb.ListValue, error) {
165165
return nil, spanner.ToSpannerError(status.Error(codes.FailedPrecondition, "cannot read more data after returning stats"))
166166
}
167167
ok := rows.backend.Next()
168+
if !ok && rows.backend.Err() != nil {
169+
return nil, rows.backend.Err()
170+
}
168171
if !ok {
169172
rows.done = true
170173
// No more rows. Read stats and return nil.

spannerlib/api/transaction_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestBeginAndCommit(t *testing.T) {
5656
t.Fatalf("ResultSetStats returned unexpected error: %v", err)
5757
}
5858
if g, w := stats.GetRowCountExact(), int64(testutil.UpdateBarSetFooRowCount); g != w {
59-
t.Fatalf("row count mismatch\n Got: %v\nWant: %v", g, w)
59+
t.Fatalf("row count mismatch for rows %d:%d:%d\n Got: %v\nWant: %v", poolId, connId, rowsId, g, w)
6060
}
6161
if err := CloseRows(ctx, poolId, connId, rowsId); err != nil {
6262
t.Fatalf("CloseRows returned unexpected error: %v", err)
@@ -125,7 +125,7 @@ func TestBeginAndRollback(t *testing.T) {
125125
t.Fatalf("ResultSetStats returned unexpected error: %v", err)
126126
}
127127
if g, w := stats.GetRowCountExact(), int64(testutil.UpdateBarSetFooRowCount); g != w {
128-
t.Fatalf("row count mismatch\n Got: %v\nWant: %v", g, w)
128+
t.Fatalf("row count mismatch for rows %d:%d:%d\n Got: %v\nWant: %v", poolId, connId, rowsId, g, w)
129129
}
130130
if err := CloseRows(ctx, poolId, connId, rowsId); err != nil {
131131
t.Fatalf("CloseRows returned unexpected error: %v", err)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
go build -o spannerlib.so -buildmode=c-shared shared_lib.go
2+
mkdir -p ../wrappers/spannerlib-java/src/main/resources/darwin-aarch64
23
cp spannerlib.so ../wrappers/spannerlib-java/src/main/resources/darwin-aarch64/libspanner.dylib

0 commit comments

Comments
 (0)