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

Method doExecute

src/dsql/DsqlRequests.cpp:574–702  ·  view source on GitHub ↗

Execute a dynamic SQL statement

Source from the content-addressed store, hash-verified

572
573// Execute a dynamic SQL statement
574void DsqlDmlRequest::doExecute(thread_db* tdbb, jrd_tra** traHandle,
575 IMessageMetadata* outMetadata, UCHAR* outMsg,
576 bool singleton)
577{
578 firstRowFetched = false;
579 const dsql_msg* message = dsqlStatement->getSendMsg();
580
581 if (!message)
582 JRD_start(tdbb, request, req_transaction);
583 else
584 {
585 UCHAR* msgBuffer = req_msg_buffers[message->msg_buffer_number];
586 JRD_start_and_send(tdbb, request, req_transaction, message->msg_number,
587 message->msg_length, msgBuffer);
588 }
589
590 // Selectable execute block should get the "proc fetch" flag assigned,
591 // which ensures that the savepoint stack is preserved while suspending
592 if (dsqlStatement->getType() == DsqlStatement::TYPE_SELECT_BLOCK)
593 request->req_flags |= req_proc_fetch;
594
595 // TYPE_EXEC_BLOCK has no outputs so there are no out_msg
596 // supplied from client side, but TYPE_EXEC_BLOCK requires
597 // 2-byte message for EOS synchronization
598 const bool isBlock = (dsqlStatement->getType() == DsqlStatement::TYPE_EXEC_BLOCK);
599
600 message = dsqlStatement->getReceiveMsg();
601
602 if (outMetadata == DELAYED_OUT_FORMAT)
603 {
604 needDelayedFormat = true;
605 outMetadata = NULL;
606 }
607
608 if (outMetadata && message)
609 parseMetadata(outMetadata, message->msg_parameters);
610
611 if ((outMsg && message) || isBlock)
612 {
613 UCHAR temp_buffer[FB_DOUBLE_ALIGN * 2];
614 dsql_msg temp_msg(*getDefaultMemoryPool());
615
616 // Insure that the metadata for the message is parsed, regardless of
617 // whether anything is found by the call to receive.
618
619 UCHAR* msgBuffer = req_msg_buffers[message->msg_buffer_number];
620
621 if (!outMetadata && isBlock)
622 {
623 message = &temp_msg;
624 temp_msg.msg_number = 1;
625 temp_msg.msg_length = 2;
626 msgBuffer = FB_ALIGN(temp_buffer, FB_DOUBLE_ALIGN);
627 }
628
629 JRD_receive(tdbb, request, message->msg_number, message->msg_length, msgBuffer);
630
631 if (outMsg)

Callers

nothing calls this directly

Calls 14

JRD_startFunction · 0.85
JRD_start_and_sendFunction · 0.85
getDefaultMemoryPoolFunction · 0.85
FB_ALIGNFunction · 0.85
JRD_receiveFunction · 0.85
raiseFunction · 0.85
GdsClass · 0.85
ERRD_postFunction · 0.85
NumClass · 0.85
getSendMsgMethod · 0.80
getReceiveMsgMethod · 0.80
getTypeMethod · 0.45

Tested by

no test coverage detected