IResultSet behavior on record error

8 views
Skip to first unread message

Dimitry Sibiryakov

unread,
Nov 30, 2022, 10:44:17 AM11/30/22
to Firebird Developers List
Hello All,

another conceptual question: if IResultSet::fetchXXX encounter some error for
this particular record, what should be consequences?
Shall the result set to be invalidated so any following call to fetchXXX fail
as well? Or it is allowed to return (previous for example) record successfully?

--
WBR, SD.

Dmitry Yemanov

unread,
Nov 30, 2022, 11:17:48 AM11/30/22
to firebir...@googlegroups.com
Currently it's allowed to continue fetching. Although effects may in
fact depend on where the error comes from. In the worst case the cursor
position may become broken, I'm afraid.


Dmitry

Dimitry Sibiryakov

unread,
Dec 2, 2022, 10:32:11 AM12/2/22
to firebir...@googlegroups.com
Dmitry Yemanov wrote 30.11.2022 17:15:
>>    Shall the result set to be invalidated so any following call to fetchXXX
>> fail as well? Or it is allowed to return (previous for example) record
>> successfully?
>
> Currently it's allowed to continue fetching. Although effects may in fact depend
> on where the error comes from. In the worst case the cursor position may become
> broken, I'm afraid.

If fetchAbsolute() fail, following fetchRelative/Next/Prev is supposed to
work from "old current record" or from one that fetchAbsolute() was called with?

--
WBR, SD.

Dmitry Yemanov

unread,
Dec 2, 2022, 11:25:06 AM12/2/22
to firebir...@googlegroups.com
02.12.2022 18:32, 'Dimitry Sibiryakov' via firebird-devel wrote:
>
> If fetchAbsolute() fail, following fetchRelative/Next/Prev is
> supposed to work from "old current record" or from one that
> fetchAbsolute() was called with?

From the old position.


Dmitry

Dimitry Sibiryakov

unread,
Dec 2, 2022, 11:39:02 AM12/2/22
to firebir...@googlegroups.com
Dmitry Yemanov wrote 02.12.2022 17:25:
>> If fetchAbsolute() fail, following fetchRelative/Next/Prev is supposed to work
>> from "old current record" or from one that fetchAbsolute() was called with?
>
> From the old position.

This somehow contradict with rules for fetchNext/Prev that would use new
position in such case.
Let's consider following record set:

1. Normal record;
2. Broken record;
3. Normal record.

Current position is 1.
fetchNext() will return error.
fetchPrev() after that should return record 1 again or fetchNext() return
record 3. Right?

fetchAbsolute(2) will return error.
If following calls use old current position then fetchPrev() will return
NO_DATA while I would expect record 1. Wrong?

--
WBR, SD.

Dmitry Yemanov

unread,
Dec 2, 2022, 11:52:56 AM12/2/22
to firebir...@googlegroups.com
02.12.2022 19:39, 'Dimitry Sibiryakov' wrote:

>   Let's consider following record set:
>
> 1. Normal record;
> 2. Broken record;
> 3. Normal record.
>
>   Current position is 1.
>   fetchNext() will return error.
>   fetchPrev() after that should return record 1 again or fetchNext()
> return record 3. Right?

Nope. Error means that position did not change, it's still 1. So
fetchPrev() should return BOF (NO_DATA) and fetchNext() should fail again.


Dmitry

Dimitry Sibiryakov

unread,
Dec 2, 2022, 11:55:14 AM12/2/22
to firebir...@googlegroups.com
Dmitry Yemanov wrote 02.12.2022 17:52:
>
> Nope. Error means that position did not change, it's still 1. So fetchPrev()
> should return BOF (NO_DATA) and fetchNext() should fail again.

So there is no way to skip problematic record and salvage as much data as
possible. Ok...

--
WBR, SD.

Dmitry Yemanov

unread,
Dec 2, 2022, 12:02:20 PM12/2/22
to firebir...@googlegroups.com
FetchAbsolute(N+1), then fetchNext()


Dmitry

Dimitry Sibiryakov

unread,
Dec 2, 2022, 12:05:13 PM12/2/22
to firebir...@googlegroups.com
Dmitry Yemanov wrote 02.12.2022 18:02:
>
> FetchAbsolute(N+1), then fetchNext()

FetchAbsolute(N+1) will return error so current record is still 1. May be
fetchRelative(2)?..

Are forwarding fetchAbsolute/Relative allowed on non-scrollable result set at
all?

--
WBR, SD.

Dmitry Yemanov

unread,
Dec 2, 2022, 12:22:48 PM12/2/22
to firebir...@googlegroups.com
02.12.2022 20:05, 'Dimitry Sibiryakov' wrote:

>> FetchAbsolute(N+1), then fetchNext()
>
>   FetchAbsolute(N+1) will return error so current record is still 1.
> May be fetchRelative(2)?..

In your example, record 2 is broken and fetchAbsolute(3) should work.
But of course fetchRelative(2) is also an option.

Although in fact, everything depends on where the error originates from.
If it cannot be read from a data page, none of the options would work,
the cursor will be stuck at the first error without any chance to scroll
over. If error is raised during mapping data to the output parameters,
for example, then scrolling gonna be possible.

> Are forwarding fetchAbsolute/Relative allowed on non-scrollable
> result set at all?

Nope, only fetchNext() is allowed.


Dmitry

Reply all
Reply to author
Forward
0 new messages