Execute a dynamic SQL statement
| 572 | |
| 573 | // Execute a dynamic SQL statement |
| 574 | void 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) |
nothing calls this directly
no test coverage detected