-
-
Notifications
You must be signed in to change notification settings - Fork 259
Open
Labels
Description
As reported by @Ev3nt execution of a singleton query returning a data doesn't return isc_stream_eof error if no record was found.
Proposed patch:
diff --git a/src/dsql/DsqlRequests.cpp b/src/dsql/DsqlRequests.cpp
index 17059c7717..dac79823d1 100644
--- a/src/dsql/DsqlRequests.cpp
+++ b/src/dsql/DsqlRequests.cpp
@@ -596,19 +596,28 @@ void DsqlDmlRequest::doExecute(thread_db* tdbb, jrd_tra** traHandle,
// if this is a singleton select that return some data, make sure there's in fact one record
- if (singleton && (request->req_flags & req_active) && outMsgLength > 0)
+ if (singleton)
{
- // Create a temp message buffer and try one more receive.
- // If it succeed then the next record exists.
+ if (outMsgLength > 0)
+ {
+ // No record returned though expected
+ if (!(request->req_flags & req_active))
+ {
+ status_exception::raise(Arg::Gds(isc_stream_eof));
+ }
- std::unique_ptr<UCHAR[]> message_buffer(new UCHAR[outMsgLength]);
+ // Create a temp message buffer and try one more receive.
+ // If it succeed then the next record exists.
- JRD_receive(tdbb, request, message->msg_number, outMsgLength, message_buffer.get());
+ std::unique_ptr<UCHAR[]> message_buffer(new UCHAR[outMsgLength]);
- // Still active request means that second record exists
- if ((request->req_flags & req_active))
- {
- status_exception::raise(Arg::Gds(isc_sing_select_err));
+ JRD_receive(tdbb, request, message->msg_number, outMsgLength, message_buffer.get());
+
+ // Still active request means that second record exists
+ if ((request->req_flags & req_active))
+ {
+ status_exception::raise(Arg::Gds(isc_sing_select_err));
+ }
}
}
}