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

Method init

src/plugins/profiler/Profiler.cpp:266–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

264//--------------------------------------
265
266void ProfilerPlugin::init(ThrowStatusExceptionWrapper* status, IAttachment* attachment, FB_UINT64 aTicksFrequency)
267{
268 userAttachment = attachment;
269 ticksFrequency = (SINT64) aTicksFrequency;
270
271 constexpr auto sql = R"""(
272 select exists(
273 select true
274 from rdb$roles
275 where rdb$role_name = 'PLG$PROFILER'
276 ) metadata_created,
277 rdb$get_context('SYSTEM', 'DB_NAME') db_name,
278 (select rdb$owner_name
279 from rdb$relations
280 where rdb$relation_name = 'RDB$DATABASE'
281 ) owner_name,
282 current_role,
283 rdb$role_in_use('PLG$PROFILER') role_in_use
284 from rdb$database
285 )""";
286
287 FB_MESSAGE(message, ThrowStatusExceptionWrapper,
288 (FB_BOOLEAN, metadataCreated)
289 (FB_INTL_VARCHAR(MAXPATHLEN * 4, CS_METADATA), dbName)
290 (FB_INTL_VARCHAR(MAX_SQL_IDENTIFIER_LEN, CS_METADATA), ownerName)
291 (FB_INTL_VARCHAR(MAX_SQL_IDENTIFIER_LEN, CS_METADATA), currentRole)
292 (FB_BOOLEAN, roleInUse)
293 ) message(status, MasterInterfacePtr());
294 message.clear();
295
296 RefPtr<IAttachment> refAttachment(attachment);
297 RefPtr<ITransaction> refTransaction;
298 string currentRole;
299 bool roleInUse;
300
301 for (unsigned i = 0; i < 2; ++i)
302 {
303 refTransaction = makeNoIncRef(refAttachment->startTransaction(status, 0, nullptr));
304
305 auto resultSet = makeNoIncRef(refAttachment->openCursor(status, refTransaction, 0, sql, SQL_DIALECT_CURRENT,
306 nullptr, nullptr, message.getMetadata(), nullptr, 0));
307
308 if (resultSet->fetchNext(status, message.getData()) == IStatus::RESULT_NO_DATA)
309 {
310 fb_assert(false);
311 return;
312 }
313
314 if (i == 0)
315 {
316 currentRole = string(message->currentRole.str, message->currentRole.length);
317 quote(currentRole);
318
319 roleInUse = message->roleInUse;
320
321 if (message->metadataCreated)
322 break;
323

Callers 4

setKeyMethod · 0.45
encryptMethod · 0.45
decryptMethod · 0.45
getKnownTypesMethod · 0.45

Calls 15

MasterInterfacePtrClass · 0.85
makeNoIncRefFunction · 0.85
quoteFunction · 0.85
messageFunction · 0.50
clearMethod · 0.45
startTransactionMethod · 0.45
openCursorMethod · 0.45
getMetadataMethod · 0.45
fetchNextMethod · 0.45
getDataMethod · 0.45
getDispatcherMethod · 0.45
getUtilInterfaceMethod · 0.45

Tested by

no test coverage detected