| 71 | } |
| 72 | |
| 73 | RefPtr<DsqlStatement> DsqlStatementCache::getStatement(thread_db* tdbb, const string& text, USHORT clientDialect, |
| 74 | bool isInternalRequest) |
| 75 | { |
| 76 | RefStrPtr key; |
| 77 | buildStatementKey(tdbb, key, text, clientDialect, isInternalRequest); |
| 78 | |
| 79 | if (const auto entryPtr = map.get(key)) |
| 80 | { |
| 81 | const auto entry = *entryPtr; |
| 82 | auto dsqlStatement(entry->dsqlStatement); |
| 83 | |
| 84 | string verifyKey; |
| 85 | buildVerifyKey(tdbb, verifyKey, isInternalRequest); |
| 86 | |
| 87 | FB_SIZE_T verifyPos; |
| 88 | if (!entry->verifyCache.find(verifyKey, verifyPos)) |
| 89 | { |
| 90 | dsqlStatement->getStatement()->verifyAccess(tdbb); |
| 91 | entry->verifyCache.insert(verifyPos, verifyKey); |
| 92 | } |
| 93 | |
| 94 | if (!entry->active) |
| 95 | { |
| 96 | entry->dsqlStatement->setCacheKey(key); |
| 97 | // Active statement has cacheKey and will tell us when it's going to be released. |
| 98 | entry->dsqlStatement->release(); |
| 99 | |
| 100 | entry->active = true; |
| 101 | |
| 102 | cacheSize -= entry->size; |
| 103 | |
| 104 | activeStatementList.splice(activeStatementList.end(), inactiveStatementList, entry); |
| 105 | } |
| 106 | |
| 107 | #ifdef DSQL_STATEMENT_CACHE_DEBUG |
| 108 | dump(); |
| 109 | #endif |
| 110 | |
| 111 | return dsqlStatement; |
| 112 | } |
| 113 | |
| 114 | return {}; |
| 115 | } |
| 116 | |
| 117 | void DsqlStatementCache::putStatement(thread_db* tdbb, const string& text, USHORT clientDialect, |
| 118 | bool isInternalRequest, RefPtr<DsqlStatement> dsqlStatement) |
nothing calls this directly
no test coverage detected