| 3230 | } |
| 3231 | |
| 3232 | TenantInfo TransactionState::getTenantInfo(AllowInvalidTenantID allowInvalidId /* = false */) { |
| 3233 | Optional<TenantName> const& t = tenant(); |
| 3234 | |
| 3235 | if (options.rawAccess) { |
| 3236 | return TenantInfo(); |
| 3237 | } else if (!cx->internal && cx->clientInfo->get().clusterType == ClusterType::METACLUSTER_MANAGEMENT) { |
| 3238 | throw management_cluster_invalid_access(); |
| 3239 | } else if (!cx->internal && cx->clientInfo->get().tenantMode == TenantMode::REQUIRED && !t.present()) { |
| 3240 | throw tenant_name_required(); |
| 3241 | } else if (!t.present()) { |
| 3242 | return TenantInfo(); |
| 3243 | } else if (cx->clientInfo->get().tenantMode == TenantMode::DISABLED && t.present()) { |
| 3244 | // If we are running provisional proxies, we allow a tenant request to go through since we don't know the tenant |
| 3245 | // mode. Such a transaction would not be allowed to commit without enabling provisional commits because either |
| 3246 | // the commit proxies will be provisional or the read version will be too old. |
| 3247 | if (!cx->clientInfo->get().grvProxies.empty() && !cx->clientInfo->get().grvProxies[0].provisional) { |
| 3248 | throw tenants_disabled(); |
| 3249 | } else { |
| 3250 | ASSERT(!useProvisionalProxies); |
| 3251 | } |
| 3252 | } |
| 3253 | |
| 3254 | ASSERT(allowInvalidId || tenantId_ != TenantInfo::INVALID_TENANT); |
| 3255 | return TenantInfo(t, authToken, tenantId_); |
| 3256 | } |
| 3257 | |
| 3258 | // Returns the tenant used in this transaction. If the tenant is unset and raw access isn't specified, then the default |
| 3259 | // tenant from DatabaseContext is applied to this transaction (note: the default tenant is typically unset, but in |
no test coverage detected