{"record":{"id":"ec018142506bb72d","repo":"apache/cassandra","slug":"trigger-s-on-s-s-doesn-t-exist","errorCode":null,"errorMessage":"Trigger '%s' on '%s.%s' doesn't exist","messagePattern":"Trigger '(.+?)' on '(.+?)\\.(.+?)' doesn't exist","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/schema/DropTriggerStatement.java","lineNumber":75,"sourceCode":"    public Keyspaces apply(ClusterMetadata metadata)\n    {\n        Keyspaces schema = metadata.schema.getKeyspaces();\n        KeyspaceMetadata keyspace = schema.getNullable(keyspaceName);\n\n        TableMetadata table = null == keyspace\n                            ? null\n                            : keyspace.tables.getNullable(tableName);\n\n        TriggerMetadata trigger = null == table\n                                ? null\n                                : table.triggers.get(triggerName).orElse(null);\n\n        if (null == trigger)\n        {\n            if (ifExists)\n                return schema;\n\n            throw ire(\"Trigger '%s' on '%s.%s' doesn't exist\", triggerName, keyspaceName, tableName);\n        }\n\n        TableMetadata newTable = table.withSwapped(table.triggers.without(triggerName));\n        return schema.withAddedOrUpdated(keyspace.withSwapped(keyspace.tables.withSwapped(newTable)));\n    }\n\n    SchemaChange schemaChangeEvent(KeyspacesDiff diff)\n    {\n        return new SchemaChange(Change.UPDATED, Target.TABLE, keyspaceName, tableName);\n    }\n\n    public void authorize(ClientState client)\n    {\n        client.ensureIsSuperuser(\"Only superusers are allowed to perfrom DROP TRIGGER queries\");\n    }\n\n    @Override\n    public AuditLogContext getAuditLogContext()","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/schema/DropTriggerStatement.java#L57-L93","documentation":"Existence guard in DropTriggerStatement.apply(): the named trigger is not defined on the target table (or the keyspace/table itself is missing), so table.triggers has no entry for triggerName. Without IF EXISTS, the drop is rejected with InvalidRequestException naming the trigger and the table.","triggerScenarios":"Executing DROP TRIGGER <name> ON <ks>.<table> when no trigger with that name exists in the table's trigger metadata; misspelling the trigger name; running against a cluster where the trigger was already dropped.","commonSituations":"Typos in trigger names; re-running DDL scripts that already executed; environments (e.g. staging) where the trigger was never created.","solutions":["Add IF EXISTS to make the drop idempotent; verify the trigger name and table with DESCRIBE TABLE; check that the trigger was not already dropped on another node before retrying."],"exampleFix":"// before\nDROP TRIGGER tg ON ks.tbl;\n// after\nDROP TRIGGER IF EXISTS tg ON ks.tbl;","handlingStrategy":"validation","validationCode":"var exists = session.execute(\"SELECT trigger_name FROM system_schema.triggers WHERE keyspace_name=? AND table_name=? AND trigger_name=?\", ks, table, trigger).iterator().hasNext();\nif (exists) session.execute(\"DROP TRIGGER \" + trigger + \" ON \" + ks + \".\" + table);","typeGuard":null,"tryCatchPattern":"try { session.execute(ddl); } catch (InvalidRequest e) { if (e.getMessage().contains(\"doesn't exist\")) log.info(\"Trigger already absent\"); else throw e; }","preventionTips":["Use IF EXISTS on all DROP TRIGGER statements in scripts","Keep trigger names in a registry/constants file to avoid typos","Check system_schema.triggers before conditional drops"],"tags":["cassandra","cql","ddl","trigger"],"backgroundTag":"entity-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}