| 133 | } |
| 134 | |
| 135 | void DsqlDmlStatement::dsqlPass(thread_db* tdbb, DsqlCompilerScratch* scratch, ntrace_result_t* traceResult) |
| 136 | { |
| 137 | { // scope |
| 138 | ContextPoolHolder scratchContext(tdbb, &scratch->getPool()); |
| 139 | node = Node::doDsqlPass(scratch, node); |
| 140 | } |
| 141 | |
| 142 | if (scratch->clientDialect > SQL_DIALECT_V5) |
| 143 | scratch->getDsqlStatement()->setBlrVersion(5); |
| 144 | else |
| 145 | scratch->getDsqlStatement()->setBlrVersion(4); |
| 146 | |
| 147 | GEN_statement(scratch, node); |
| 148 | |
| 149 | unsigned messageNumber = 0; |
| 150 | |
| 151 | for (auto message : ports) |
| 152 | message->msg_buffer_number = messageNumber++; |
| 153 | |
| 154 | // have the access method compile the statement |
| 155 | |
| 156 | #ifdef DSQL_DEBUG |
| 157 | if (DSQL_debug & 64) |
| 158 | { |
| 159 | dsql_trace("Resulting BLR code for DSQL:"); |
| 160 | gds__trace_raw("Statement:\n"); |
| 161 | gds__trace_raw(getSqlText()->c_str(), getSqlText()->length()); |
| 162 | gds__trace_raw("\nBLR:\n"); |
| 163 | fb_print_blr(scratch->getBlrData().begin(), |
| 164 | (ULONG) scratch->getBlrData().getCount(), |
| 165 | gds__trace_printer, 0, 0); |
| 166 | } |
| 167 | #endif |
| 168 | |
| 169 | FbLocalStatus localStatus; |
| 170 | |
| 171 | // check for warnings |
| 172 | if (tdbb->tdbb_status_vector->getState() & IStatus::STATE_WARNINGS) |
| 173 | { |
| 174 | // save a status vector |
| 175 | fb_utils::copyStatus(&localStatus, tdbb->tdbb_status_vector); |
| 176 | fb_utils::init_status(tdbb->tdbb_status_vector); |
| 177 | } |
| 178 | |
| 179 | ISC_STATUS status = FB_SUCCESS; |
| 180 | |
| 181 | try |
| 182 | { |
| 183 | const auto attachment = scratch->getAttachment()->dbb_attachment; |
| 184 | const auto& blr = scratch->getBlrData(); |
| 185 | const auto& debugData = scratch->getDebugData(); |
| 186 | |
| 187 | statement = CMP_compile(tdbb, blr.begin(), blr.getCount(), |
| 188 | (scratch->flags & DsqlCompilerScratch::FLAG_INTERNAL_REQUEST), |
| 189 | debugData.getCount(), debugData.begin()); |
| 190 | |
| 191 | if (getSqlText()) |
| 192 | statement->sqlText = getSqlText(); |
nothing calls this directly
no test coverage detected