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

Method populate

src/jrd/Mapping.cpp:310–415  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

308}
309
310bool Mapping::Cache::populate(IAttachment *att)
311{
312 FbLocalStatus st;
313
314 if (dataFlag)
315 {
316 return false;
317 }
318
319 if (!att)
320 {
321 dataFlag = true;
322 return false;
323 }
324
325 MAP_DEBUG(fprintf(stderr, "Populate cache for %s\n", name.c_str()));
326
327 ITransaction* tra = nullptr;
328 IResultSet* curs = nullptr;
329
330 try
331 {
332 ClumpletWriter readOnly(ClumpletWriter::Tpb, MAX_DPB_SIZE, isc_tpb_version1);
333 readOnly.insertTag(isc_tpb_read);
334 readOnly.insertTag(isc_tpb_wait);
335 tra = att->startTransaction(&st, readOnly.getBufferLength(), readOnly.getBuffer());
336 check("IAttachment::startTransaction", &st);
337
338 Message mMap;
339 Field<Text> usng(mMap, 1);
340 Field<Varying> plugin(mMap, MAX_SQL_IDENTIFIER_SIZE);
341 Field<Varying> db(mMap, MAX_SQL_IDENTIFIER_SIZE);
342 Field<Varying> fromType(mMap, MAX_SQL_IDENTIFIER_SIZE);
343 Field<Varying> from(mMap, 255);
344 Field<SSHORT> role(mMap);
345 Field<Varying> to(mMap, MAX_SQL_IDENTIFIER_SIZE);
346
347 curs = att->openCursor(&st, tra, 0,
348 "SELECT RDB$MAP_USING, RDB$MAP_PLUGIN, RDB$MAP_DB, RDB$MAP_FROM_TYPE, "
349 " RDB$MAP_FROM, RDB$MAP_TO_TYPE, RDB$MAP_TO "
350 "FROM RDB$AUTH_MAPPING",
351 3, nullptr, nullptr, mMap.getMetadata(), nullptr, 0);
352 if (st->getState() & IStatus::STATE_ERRORS)
353 {
354 if (fb_utils::containsErrorCode(st->getErrors(), isc_dsql_relation_err))
355 {
356 // isc_dsql_relation_err when opening cursor - i.e. table RDB$AUTH_MAPPING
357 // is missing due to non-FB3 security DB
358 tra->release();
359 dataFlag = true;
360 return false;
361 }
362 check("IAttachment::openCursor", &st);
363 }
364
365 while (curs->fetchNext(&st, mMap.getBuffer()) == IStatus::RESULT_OK)
366 {
367 const char* expandedDb = "*";

Callers 6

populateSpbFromSwitchesFunction · 0.45
testSvcFunction · 0.45
populateMethod · 0.45
populateMethod · 0.45
ensureCachePresenceMethod · 0.45
mapUserMethod · 0.45

Calls 15

containsErrorCodeFunction · 0.85
expandDatabaseNameFunction · 0.85
MapClass · 0.85
makeHashKeyMethod · 0.80
checkFunction · 0.70
addFunction · 0.50
c_strMethod · 0.45
insertTagMethod · 0.45
startTransactionMethod · 0.45
getBufferLengthMethod · 0.45
getBufferMethod · 0.45
openCursorMethod · 0.45

Tested by

no test coverage detected