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

Function CMP_compile

src/jrd/cmp.cpp:145–200  ·  view source on GitHub ↗

Compile a statement.

Source from the content-addressed store, hash-verified

143
144// Compile a statement.
145Statement* 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
202Request* CMP_compile_request(thread_db* tdbb, const UCHAR* blr, ULONG blrLength, bool internalFlag)

Callers 3

dsqlPassMethod · 0.85
compileRequestMethod · 0.85
CMP_compile_requestFunction · 0.85

Calls 14

SET_TDBBFunction · 0.85
PAR_parseFunction · 0.85
ERR_puntFunction · 0.85
verifyAccessMethod · 0.80
getAttachmentMethod · 0.45
createPoolMethod · 0.45
hasDataMethod · 0.45
dumpMethod · 0.45
c_strMethod · 0.45
toStringMethod · 0.45
getNameMethod · 0.45
stuffExceptionMethod · 0.45

Tested by

no test coverage detected