Restart fetch logic

18 views
Skip to first unread message

Dimitry Sibiryakov

unread,
Jun 27, 2024, 11:11:53 AM (6 days ago) Jun 27
to firebir...@googlegroups.com
Hello All,

in DsqlRequests.cpp I see this:

> // When restart we must execute query
> exec = true;

And I wonder if `fetch` should be reset to false to avoid receiving of the
second record from the cursor instead of expected first one.

--
WBR, SD.

Vlad Khorsun

unread,
Jun 28, 2024, 3:09:36 PM (4 days ago) Jun 28
to firebir...@googlegroups.com
27.06.2024 18:11, 'Dimitry Sibiryakov' via firebird-devel:
No, it shouldn't. First record could be different after query restart.

Regards,
Vlad

Dimitry Sibiryakov

unread,
Jun 28, 2024, 3:21:15 PM (4 days ago) Jun 28
to firebir...@googlegroups.com
Vlad Khorsun wrote 28.06.2024 21:09:
>>    And I wonder if `fetch` should be reset to false to avoid receiving of the
>> second record from the cursor instead of expected first one.
>
>   No, it shouldn't. First record could be different after query restart.

But this routine is called only if `!firstRowFetched` so I thought that it is
supposed to return the first record, not second one.
doExecute() when called with non-nullptr `outMsg` (which is exactly the case
on second loop iteration) performs fetch (call to JRD_receive()) of the first
record itself and then, if `fetch` is still true, JRD_receive() is called once
again thus delivering second record to client. What do I miss?

--
WBR, SD.

Vlad Khorsun

unread,
Jun 28, 2024, 3:31:52 PM (4 days ago) Jun 28
to firebir...@googlegroups.com
28.06.2024 22:21, 'Dimitry Sibiryakov' via firebird-devel:
> Vlad Khorsun wrote 28.06.2024 21:09:
>>>    And I wonder if `fetch` should be reset to false to avoid receiving of the second record from the cursor instead of expected
>>> first one.
>>
>>    No, it shouldn't. First record could be different after query restart.
>
>   But this routine is called only if `!firstRowFetched` so I thought that it is supposed to return the first record, not second one.
>   doExecute() when called with non-nullptr `outMsg` (which is exactly the case on second loop iteration)

Look better. Parameter "fetch" set to "true" only when executeReceiveWithRestarts() was called by
DsqlDmlRequest::fetch(), which passed NULL into outMsg.

Regards,
Vlad

Dimitry Sibiryakov

unread,
Jun 28, 2024, 5:47:14 PM (4 days ago) Jun 28
to firebir...@googlegroups.com
Vlad Khorsun wrote 28.06.2024 21:31:
>
>   Look better. Parameter "fetch" set to "true" only when
> executeReceiveWithRestarts() was called by
> DsqlDmlRequest::fetch(), which passed NULL into outMsg.

Oops... Thanks.

--
WBR, SD.

Reply all
Reply to author
Forward
0 new messages