Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Network support for bi-directional cursors #7051

Closed
dyemanov opened this issue Nov 25, 2021 · 3 comments
Closed

Network support for bi-directional cursors #7051

dyemanov opened this issue Nov 25, 2021 · 3 comments

Comments

@dyemanov
Copy link
Member

This ticket complements #1189. The original implementation of bi-directional (aka scrollable) cursors covered only the engine and API, thus being limited to PSQL and embedded connections using DSQL. The complete implementation, however, should also support scrollable cursors for remote connections as well. The remote protocol needs to be extended for that.

@dyemanov
Copy link
Member Author

dyemanov commented Nov 26, 2021

Implementation fully supports the packet prefetch logic existed before. However, it's enabled only for fetchNext() and fetchPrior() operations, other scrolling options discard the priorly prefetched rows (if any) and switch to fetching one-by-one. There should be no performance difference in uni-directional fetching between regular and scrollable cursors, except the server-side caching cost for scrollable cursors.

Network protocol changes:

  1. op_execute and op_execute2 packets are extended to include cursor flags (LONG), this corresponds to the last parameter in openCursor() API method.
if (port->port_protocol >= PROTOCOL_FETCH_SCROLL)
	MAP(xdr_u_long, sqldata->p_sqldata_cursor_flags);

  1. New packet op_fetch_scroll is introduced. It mirrors op_fetch with two additional fields added - fetch operation (SHORT) and fetch position (LONG). Possible fetch operations are: NEXT, PRIOR, FIRST, LAST, ABSOLUTE, RELATIVE.
enum P_FETCH
{
	fetch_next = 0,
	fetch_prior = 1,
	fetch_first = 2,
	fetch_last = 3,
	fetch_absolute = 4,
	fetch_relative = 5
};

if (p->p_operation == op_fetch_scroll)
{
	MAP(xdr_short, reinterpret_cast<SSHORT&>(sqldata->p_sqldata_fetch_op));
	MAP(xdr_long, sqldata->p_sqldata_fetch_pos);
}

op_fetch packet may still be used for fetching forward even if the cursor is open as scrollable. {op_scroll_fetch, NEXT} may be used for fetching forward even if the cursor is open as non-scrollable.

@pavel-zotov
Copy link

Test will be added after migration to pytest/firebird-driver framework.

@pavel-zotov
Copy link

QA note.
Issue is covered by test for #7056 (see notes there about remote protocol; fix was pushed in 5.0.0.320, commit #5a5a2992, 26-nov-2021 09:11)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants