{"record":{"id":"d88afb734f6cca0f","repo":"prestodb/presto","slug":"cannot-access-schema","errorCode":null,"errorMessage":"Cannot access schema: ","messagePattern":"Cannot access schema: ","errorType":"error_code","errorClass":"AccessDeniedException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/UseTask.java","lineNumber":102,"sourceCode":"        if (!hasCatalogAccess(session.getIdentity(), session.getAccessControlContext(), catalog, accessControl)) {\n            denyCatalogAccess(catalog);\n        }\n        stateMachine.setSetCatalog(catalog);\n    }\n\n    private void checkAndSetSchema(Use statement, Metadata metadata, QueryStateMachine stateMachine, Session session, AccessControl accessControl)\n    {\n        String catalog = statement.getCatalog()\n                .map(Identifier::getValueLowerCase)\n                .orElseGet(() -> session.getCatalog().map(String::toLowerCase).get());\n\n        Identifier schemaIdentifier = statement.getSchema();\n        String schema = metadata.normalizeIdentifier(session, catalog, schemaIdentifier.getValue());\n        if (!metadata.getMetadataResolver(session).schemaExists(new CatalogSchemaName(catalog, schema))) {\n            throw new SemanticException(MISSING_SCHEMA, format(\"Schema does not exist: %s.%s\", catalog, schema));\n        }\n        if (!hasSchemaAccess(session.getTransactionId().get(), session.getIdentity(), session.getAccessControlContext(), catalog, schema, accessControl)) {\n            throw new AccessDeniedException(\"Cannot access schema: \" + new CatalogSchemaName(catalog, schema));\n        }\n        stateMachine.setSetSchema(schema);\n    }\n\n    private boolean hasCatalogAccess(Identity identity, AccessControlContext context, String catalog, AccessControl accessControl)\n    {\n        return !accessControl.filterCatalogs(identity, context, ImmutableSet.of(catalog)).isEmpty();\n    }\n\n    private boolean hasSchemaAccess(TransactionId transactionId, Identity identity, AccessControlContext context, String catalog, String schema, AccessControl accessControl)\n    {\n        return !accessControl.filterSchemas(transactionId, identity, context, catalog, ImmutableSet.of(schema)).isEmpty();\n    }\n}\n","sourceCodeStart":84,"sourceCodeEnd":117,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/UseTask.java#L84-L117","documentation":"Access-control denial in checkAndSetSchema for the USE statement: the schema exists, but the AccessContext check determined the current identity is not allowed to access it, and the name is appended to the failure message.","triggerScenarios":"Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/UseTask.java:102 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request the required schema privileges from the system administrator","Verify the authenticated user and role are the ones intended","Switch to an identity that has access, or use a schema the identity can read"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}