Skip to content

Regression: no isc_stream_eof returned by IStatement::execute() #8734

@aafemt

Description

@aafemt

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));
+					}
 				}
 			}
 		}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions