Repository navigation
Description
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
fix(#9646): DROP CONSTRAINT <name> undoes what CREATE CONSTRAINT <nam…
robfrank commentedon Oct 11, 2026
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 withIF NOT EXISTS). Dropping an unknown name raises an error unlessIF EXISTSis 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, soDROP INDEX <name>does nothing. #9706, where dropping a namedIS TYPEDconstraint 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.
fix(ArcadeData#9646): DROP CONSTRAINT <name> undoes what CREATE CONST…
fix(#9646): DROP CONSTRAINT <name> undoes what CREATE CONSTRAINT <nam…
fix(#9646): DROP CONSTRAINT <name> undoes what CREATE CONSTRAINT <nam…