{"record":{"id":"65f372194cd86091","repo":"prestodb/presto","slug":"not-supported-65f372","errorCode":"NOT_SUPPORTED","errorMessage":"CASCADE is not yet supported for DROP SCHEMA","messagePattern":"CASCADE is not yet supported for DROP SCHEMA","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/DropSchemaTask.java","lineNumber":57,"sourceCode":"        implements DDLDefinitionTask<DropSchema>\n{\n    @Override\n    public String getName()\n    {\n        return \"DROP SCHEMA\";\n    }\n\n    @Override\n    public String explain(DropSchema statement, List<Expression> parameters)\n    {\n        return \"DROP SCHEMA \" + statement.getSchemaName();\n    }\n\n    @Override\n    public ListenableFuture<?> execute(DropSchema statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        if (statement.isCascade()) {\n            throw new PrestoException(NOT_SUPPORTED, \"CASCADE is not yet supported for DROP SCHEMA\");\n        }\n\n        CatalogSchemaName schema = createCatalogSchemaName(session, statement, Optional.of(statement.getSchemaName()), metadata);\n        MetadataResolver metadataResolver = metadata.getMetadataResolver(session);\n\n        if (!metadataResolver.catalogExists(schema.getCatalogName())) {\n            throw new SemanticException(MISSING_CATALOG, \"Catalog '%s' does not exist\", schema.getCatalogName());\n        }\n\n        if (!metadataResolver.schemaExists(schema)) {\n            if (!statement.isExists()) {\n                throw new SemanticException(MISSING_SCHEMA, statement, \"Schema '%s' does not exist\", schema);\n            }\n            return immediateFuture(null);\n        }\n\n        accessControl.checkCanDropSchema(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), schema);\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/DropSchemaTask.java#L39-L75","documentation":"Thrown by DropSchemaTask.execute when DROP SCHEMA is issued with CASCADE. Presto's implementation only supports RESTRICT semantics for dropping schemas, so any cascade request fails immediately with NOT_SUPPORTED before any existence or permission checks.","triggerScenarios":"Statement.isCascade() is true, i.e. 'DROP SCHEMA schema_name CASCADE'.","commonSituations":"Porting SQL scripts from PostgreSQL/other engines where CASCADE is common; cleanup scripts that assume recursive drop; ORMs generating CASCADE by default.","solutions":["Drop the schema's tables/views explicitly first, then run DROP SCHEMA without CASCADE.","Generate a script of contained objects (query information_schema.tables/views) and drop each before the schema.","Remove CASCADE from generated SQL or change ORM/tooling defaults to RESTRICT."],"exampleFix":"// before\nDROP SCHEMA catalog.db.tmp_schema CASCADE;\n// after\nDROP TABLE IF EXISTS catalog.db.tmp_schema.t1;\nDROP VIEW IF EXISTS catalog.db.tmp_schema.v1;\nDROP SCHEMA catalog.db.tmp_schema;","handlingStrategy":"validation","validationCode":"// reject CASCADE before sending the statement\nif (sql.toLowerCase().contains(\"drop schema\") && sql.toLowerCase().contains(\"cascade\")) {\n  throw new IllegalArgumentException(\"CASCADE unsupported for DROP SCHEMA; drop children first\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use CASCADE with DROP SCHEMA in Presto scripts.","Write teardown helpers that enumerate and drop child tables/views first.","Porting from PostgreSQL: audit DDL for CASCADE keywords before running on Presto."],"tags":["sql","schema","not-supported"],"backgroundTag":"cascade-not-supported","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"}