Skip to content
Merged
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
17 changes: 17 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/cursor
Original file line number Diff line number Diff line change
Expand Up @@ -943,3 +943,20 @@ statement ok
CLOSE foo;

subtest end

# Regression test for FETCH FIRST on a persisted WITH HOLD cursor over an
# empty result set returning an internal error instead of zero rows (#171238).
subtest regression_171238

statement ok
BEGIN;
DECLARE foo_first CURSOR WITH HOLD FOR SELECT * FROM empty;
COMMIT;

query empty
FETCH FIRST FROM foo_first;

statement ok
CLOSE foo_first;

subtest end
4 changes: 2 additions & 2 deletions pkg/sql/sql_cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,8 @@ func (b *fetchMoveNodeBase) nextInternal(ctx context.Context) (bool, error) {
case tree.FetchFirst:
switch b.cursor.curRow {
case 0:
_, err := b.cursor.Next(ctx)
return true, err
more, err := b.cursor.Next(ctx)
return more, err
case 1:
return true, nil
}
Expand Down
Loading