Skip to content

Cypher DROP CONSTRAINT <name> is a silent no-op for every constraint kind, and an unknown name reports success #9646

Closed

Description

@ruispereira

Summary

executeDropConstraint resolves the constraint by looking for an INDEX with the constraint's name.
executeCreateConstraint never gives the index that name (it calls schema.buildTypeIndex(typeName, propertyNames), which names the index after the type and properties), and a NOT NULL constraint is
a MANDATORY flag with no index at all. So no DROP CONSTRAINT ever resolves anything, nothing is
dropped, and the statement reports success and increments constraintsRemoved. A name that was
never created reports success too, with no IF EXISTS.

Steps to reproduce

-- IS UNIQUE on T599
   CREATE CONSTRAINT cname FOR (n:T599) REQUIRE n.v IS UNIQUE   : OK
   state         : <undeclared> indexes=[T599[v]]
   index 'cname' exists = false
   DROP CONSTRAINT cname : OK
   state after   : <undeclared> indexes=[T599[v]]
-- IS NOT NULL on T134
   CREATE CONSTRAINT cname FOR (n:T134) REQUIRE n.v IS NOT NULL : OK
   state         : type=STRING mandatory=true indexes=[]
   DROP CONSTRAINT cname : OK
   state after   : type=STRING mandatory=true indexes=[]
-- IS NODE KEY on T473
   CREATE CONSTRAINT cname FOR (n:T473) REQUIRE n.v IS NODE KEY : OK
   state         : type=STRING mandatory=true indexes=[T473[v]]
   DROP CONSTRAINT cname : OK
   state after   : type=STRING mandatory=true indexes=[T473[v]]

   DROP CONSTRAINT nosuchconstraint : OK

Expected

DROP CONSTRAINT cname removes the constraint that CREATE CONSTRAINT cname added: the unique
index for UNIQUE, the MANDATORY flag for NOT NULL, both for NODE KEY. DROP CONSTRAINT on a name
that does not exist raises, unless IF EXISTS is given.

Actual

Nothing is removed in any of the three cases, and every statement, including one naming a
constraint that never existed, reports success.

Where it happens (file:line)

engine/src/main/java/com/arcadedb/query/opencypher/query/OpenCypherQueryEngine.java:1021

  private void executeDropConstraint(final CypherDDLStatement ddl, final Schema schema, final QueryStatistics stats) {
    final String constraintName = ddl.getConstraintName();
    if (ddl.isIfExists()) {
      if (schema.existsIndex(constraintName)) {
        schema.dropIndex(constraintName);
        stats.incConstraintsRemoved();
      }
    } else {
      schema.dropIndex(constraintName);
      stats.incConstraintsRemoved();
    }
  }

against executeCreateConstraint at :634, whose UNIQUE and KEY arms build the index with
schema.buildTypeIndex(typeName, propertyNames) and whose NOT_NULL arm only calls
prop.setMandatory(true).

Suggested fix

Record what each named constraint created (the index name, and the properties whose MANDATORY flag
the statement set) so the drop can undo exactly that, and raise when the name is unknown and
IF EXISTS was not given. Naming the index after the constraint at creation time would cover the
UNIQUE and NODE KEY half, but not the MANDATORY flag.

Version

main at 4289679.


Activity

  1. added
    engine
    severity:major
    on Oct 10, 2026
  2. added this to the 26.11.1 milestone on Oct 10, 2026
  3. self-assigned this
    on Oct 10, 2026
  4. added
    in progress
    on Oct 10, 2026
  5. added a commit that references this issue on Oct 11, 2026
  6. robfrank commented on Oct 11, 2026

    @robfrank
    Collaborator

    Fixed by #9707. DROP CONSTRAINT <name> used to do nothing, so the unique index or NOT NULL flag the constraint created stayed in place. Each named constraint now records what its CREATE statement created, and DROP removes exactly that. Anything declared earlier, such as a SQL MANDATORY flag or an existing index, is kept, as is anything another named constraint still needs. Creating a constraint with a name that is already used now raises an error (or does nothing with IF NOT EXISTS). Dropping an unknown name raises an error unless IF EXISTS is given.

    Upgrade note: named constraints created before this release have no record, so DROP CONSTRAINT <name> raises for them. Drop them by index name or through SQL instead.

    Still open: #9705, where Cypher CREATE INDEX <name> ignores the name, so DROP INDEX <name> does nothing. #9706, where dropping a named IS TYPED constraint keeps the declared type, and unnamed NOT NULL / TYPED constraints cannot be dropped.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  7. removed
    in progress
    on Oct 11, 2026
  8. added a commit that references this issue on Oct 11, 2026
  9. added 2 commits that reference this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugengineopencypherseverity:major

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions