Compile a statement.
| 143 | |
| 144 | // Compile a statement. |
| 145 | Statement* CMP_compile(thread_db* tdbb, const UCHAR* blr, ULONG blrLength, bool internalFlag, |
| 146 | ULONG dbginfoLength, const UCHAR* dbginfo) |
| 147 | { |
| 148 | Statement* statement = nullptr; |
| 149 | |
| 150 | SET_TDBB(tdbb); |
| 151 | const auto att = tdbb->getAttachment(); |
| 152 | |
| 153 | // 26.09.2002 Nickolay Samofatov: default memory pool will become statement pool |
| 154 | // and will be freed by CMP_release |
| 155 | const auto newPool = att->createPool(); |
| 156 | |
| 157 | try |
| 158 | { |
| 159 | Jrd::ContextPoolHolder context(tdbb, newPool); |
| 160 | |
| 161 | const auto csb = PAR_parse(tdbb, blr, blrLength, internalFlag, dbginfoLength, dbginfo); |
| 162 | |
| 163 | statement = Statement::makeStatement(tdbb, csb, internalFlag); |
| 164 | |
| 165 | #ifdef CMP_DEBUG |
| 166 | if (csb->csb_dump.hasData()) |
| 167 | { |
| 168 | csb->dump("streams:\n"); |
| 169 | for (StreamType i = 0; i < csb->csb_n_stream; ++i) |
| 170 | { |
| 171 | const CompilerScratch::csb_repeat& s = csb->csb_rpt[i]; |
| 172 | csb->dump( |
| 173 | "\t%2d - view_stream: %2d; alias: %s; relation: %s; procedure: %s; view: %s\n", |
| 174 | i, s.csb_view_stream, |
| 175 | (s.csb_alias ? s.csb_alias->c_str() : ""), |
| 176 | (s.csb_relation ? s.csb_relation->rel_name.c_str() : ""), |
| 177 | (s.csb_procedure ? s.csb_procedure->getName().toString().c_str() : ""), |
| 178 | (s.csb_view ? s.csb_view->rel_name.c_str() : "")); |
| 179 | } |
| 180 | |
| 181 | cmp_trace("\n%s\n", csb->csb_dump.c_str()); |
| 182 | } |
| 183 | #endif |
| 184 | |
| 185 | statement->verifyAccess(tdbb); |
| 186 | |
| 187 | delete csb; |
| 188 | } |
| 189 | catch (const Firebird::Exception& ex) |
| 190 | { |
| 191 | ex.stuffException(tdbb->tdbb_status_vector); |
| 192 | if (statement) |
| 193 | statement->release(tdbb); |
| 194 | else |
| 195 | att->deletePool(newPool); |
| 196 | ERR_punt(); |
| 197 | } |
| 198 | |
| 199 | return statement; |
| 200 | } |
| 201 | |
| 202 | Request* CMP_compile_request(thread_db* tdbb, const UCHAR* blr, ULONG blrLength, bool internalFlag) |
no test coverage detected