{"record":{"id":"ef95474f98861981","repo":"prestodb/presto","slug":"catalog-not-specified-ef9547","errorCode":"CATALOG_NOT_SPECIFIED","errorMessage":"Catalog must be specified when session catalog is not set","messagePattern":"Catalog must be specified when session catalog is not set","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java","lineNumber":294,"sourceCode":"                        !metadataResolver.getTableHandle(qualifiedTableName).isPresent()) {\n                    throw new SemanticException(MISSING_TABLE, showGrants, \"Table '%s' does not exist\", tableName);\n                }\n\n                catalogName = qualifiedTableName.getCatalogName();\n\n                accessControl.checkCanShowTablesMetadata(\n                        session.getRequiredTransactionId(),\n                        session.getIdentity(),\n                        session.getAccessControlContext(),\n                        new CatalogSchemaName(catalogName, qualifiedTableName.getSchemaName()));\n\n                predicate = Optional.of(combineConjuncts(\n                        equal(identifier(\"table_schema\"), new StringLiteral(qualifiedTableName.getSchemaName())),\n                        equal(identifier(\"table_name\"), new StringLiteral(qualifiedTableName.getObjectName()))));\n            }\n            else {\n                if (catalogName == null) {\n                    throw new SemanticException(CATALOG_NOT_SPECIFIED, showGrants, \"Catalog must be specified when session catalog is not set\");\n                }\n\n                Set<String> allowedSchemas = listSchemas(session, metadata, accessControl, catalogName);\n                for (String schema : allowedSchemas) {\n                    accessControl.checkCanShowTablesMetadata(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), new CatalogSchemaName(catalogName, schema));\n                }\n            }\n\n            return simpleQuery(\n                    selectList(\n                            aliasedName(\"grantor\", \"Grantor\"),\n                            aliasedName(\"grantor_type\", \"Grantor Type\"),\n                            aliasedName(\"grantee\", \"Grantee\"),\n                            aliasedName(\"grantee_type\", \"Grantee Type\"),\n                            aliasedName(\"table_catalog\", \"Catalog\"),\n                            aliasedName(\"table_schema\", \"Schema\"),\n                            aliasedName(\"table_name\", \"Table\"),\n                            aliasedName(\"privilege_type\", \"Privilege\"),","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/rewrite/ShowQueriesRewrite.java#L276-L312","documentation":"SHOW GRANTS without an ON <table> clause needs a catalog to enumerate grants across: either the statement names one, the table clause provided one, or the session has a default catalog. If catalogName is still null after those checks, visitShowGrants throws CATALOG_NOT_SPECIFIED.","triggerScenarios":"Running bare `SHOW GRANTS` while the session has no catalog set (no USE, no default catalog at connect time) and the statement does not include a catalog-qualified schema/table.","commonSituations":"Fresh client sessions without a default catalog; BI tools issuing SHOW GRANTS before any USE; scripts assuming a session catalog configured on the server.","solutions":["Qualify the statement: `SHOW GRANTS FROM <catalog>` (or `SHOW GRANTS ON <catalog>.<schema>.<table>`).","Set the session catalog first: `USE <catalog>.<schema>`.","Configure the client/driver to connect with a default catalog.","In generated SQL, always emit an explicit catalog for administrative SHOW statements."],"exampleFix":"// before\nSHOW GRANTS  -- session catalog unset\n// after\nSHOW GRANTS FROM hive","handlingStrategy":"validation","validationCode":"if (session.getCatalog() == null && !statementSpecifiesCatalog(showGrantsSql)) {\n    throw new IllegalArgumentException(\"Set a session catalog or add FROM <catalog> to SHOW GRANTS\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    session.execute(\"SHOW GRANTS\");\n} catch (SemanticException e) {\n    if (e.getCode() == SemanticErrorCode.CATALOG_NOT_SPECIFIED) {\n        session.execute(\"USE \" + defaultCatalog + \".\" + defaultSchema);\n        session.execute(\"SHOW GRANTS\");\n    } else throw e;\n}","preventionTips":["Always specify the catalog explicitly in administrative SHOW statements","Configure a default catalog in client/driver connection settings","In automation, run USE catalog.schema before catalog-scoped statements","Emit fully qualified SQL from generated queries"],"tags":["sql","show-grants","catalog","session"],"backgroundTag":"catalog-not-specified","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"}