MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / fetch

Method fetch

src/remote/server/server.cpp:4025–4405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4023
4024
4025ISC_STATUS rem_port::fetch(P_SQLDATA * sqldata, PACKET* sendL, bool scroll)
4026{
4027/*****************************************
4028 *
4029 * f e t c h
4030 *
4031 *****************************************
4032 *
4033 * Functional description
4034 * Fetch next record from a dynamic SQL cursor.
4035 *
4036 *****************************************/
4037 LocalStatus ls;
4038 CheckStatusWrapper status_vector(&ls);
4039 Rsr* statement;
4040 getHandle(statement, sqldata->p_sqldata_statement);
4041
4042 // The default (and legacy) scrolling option is FETCH NEXT
4043 const auto operation = scroll ? sqldata->p_sqldata_fetch_op : fetch_next;
4044 const auto position = scroll ? sqldata->p_sqldata_fetch_pos : 0;
4045
4046 // Whether we're fetching in the forward direction
4047 const bool forward =
4048 (operation == fetch_next || operation == fetch_last ||
4049 ((operation == fetch_absolute || operation == fetch_relative) && position > 0));
4050
4051 // Whether we're fetching relatively to the current position
4052 const bool relative =
4053 (operation == fetch_next || operation == fetch_prior || operation == fetch_relative);
4054
4055 if (!statement->rsr_flags.test(Rsr::FETCHED))
4056 {
4057 // On first fetch, clear the end-of-stream flag & reset the message buffers
4058
4059 statement->rsr_flags.clear(Rsr::STREAM_END | Rsr::STREAM_ERR);
4060 statement->rsr_fetch_operation = operation;
4061 statement->rsr_fetch_position = position;
4062 statement->clearException();
4063
4064 RMessage* message = statement->rsr_message;
4065
4066 if (message)
4067 {
4068 statement->rsr_buffer = message;
4069
4070 while (true)
4071 {
4072 message->msg_address = NULL;
4073 message = message->msg_next;
4074
4075 if (message == statement->rsr_message)
4076 break;
4077 }
4078 }
4079 }
4080 else if (!relative)
4081 {
4082 // Clear the end-of-stream flag if the fetch is positioned absolutely

Callers 1

process_packetFunction · 0.45

Calls 15

send_responseMethod · 0.95
send_partialMethod · 0.95
sendMethod · 0.95
GdsClass · 0.85
NumClass · 0.85
checkCursorMethod · 0.80
getCursorAdjustmentMethod · 0.80
saveExceptionMethod · 0.60
checkFunction · 0.50
RMessageClass · 0.50
testMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected