From 4b6335f5decfc730a4aa4692453d2716da9e14d4 Mon Sep 17 00:00:00 2001 From: Therese Magnusson Date: Thu, 2 Dec 2021 10:40:14 +0100 Subject: [PATCH] The DROP INDEX/CONSTRAINT by schema commands are removed --- .../execution-plan-groups/operators.asciidoc | 28 +------ .../execution-plans-operator-summary.asciidoc | 34 +------- .../index.asciidoc | 29 ------- .../src/docs/dev/ql/constraints/examples.adoc | 12 --- .../src/docs/dev/ql/constraints/syntax.adoc | 67 +-------------- .../neo4j/cypher/docgen/ConstraintsTest.scala | 60 -------------- .../neo4j/cypher/docgen/QueryPlanTest.scala | 83 +------------------ .../neo4j/cypher/docgen/SchemaIndexTest.scala | 21 ----- .../docgen/tooling/PrettifierParser.scala | 2 - 9 files changed, 10 insertions(+), 326 deletions(-) diff --git a/cypher/cypher-docs/src/docs/dev/execution-plan-groups/operators.asciidoc b/cypher/cypher-docs/src/docs/dev/execution-plan-groups/operators.asciidoc index 4ab70d4fee8..9a4e5c13967 100644 --- a/cypher/cypher-docs/src/docs/dev/execution-plan-groups/operators.asciidoc +++ b/cypher/cypher-docs/src/docs/dev/execution-plan-groups/operators.asciidoc @@ -86,17 +86,12 @@ If that is the case, the example queries will be prefixed with an option to choo // * <> // * <> // * <> -// * <> // * <> -// * <> // * <> -// * <> // * <> -// * <> -// * <> +// * <> // * <> -// * <> -// * <> +// * <> include::../ql/query-plan/all-nodes-scan.asciidoc[] @@ -289,27 +284,15 @@ include::../ql/query-plan/set-property.asciidoc[] include::../ql/query-plan/create-unique-constraint.asciidoc[] -[role=deprecated] -include::../ql/query-plan/drop-unique-constraint.asciidoc[] - include::../ql/query-plan/create-constraint-only-if-it-does-not-already-exist.asciidoc[] include::../ql/query-plan/create-node-property-existence-constraint.asciidoc[] -[role=deprecated] -include::../ql/query-plan/drop-node-property-existence-constraint.asciidoc[] - include::../ql/query-plan/create-node-key-constraint.asciidoc[] -[role=deprecated] -include::../ql/query-plan/drop-node-key-constraint.asciidoc[] - include::../ql/query-plan/create-relationship-property-existence-constraint.asciidoc[] -[role=deprecated] -include::../ql/query-plan/drop-relationship-property-existence-constraint.asciidoc[] - -include::../ql/query-plan/drop-constraint-by-name.asciidoc[] +include::../ql/query-plan/drop-constraint.asciidoc[] include::../ql/query-plan/listing-constraints.asciidoc[] @@ -317,10 +300,7 @@ include::../ql/query-plan/create-index.asciidoc[] include::../ql/query-plan/create-index-only-if-it-does-not-already-exist.asciidoc[] -[role=deprecated] -include::../ql/query-plan/drop-index-by-schema.asciidoc[] - -include::../ql/query-plan/drop-index-by-name.asciidoc[] +include::../ql/query-plan/drop-index.asciidoc[] include::../ql/query-plan/listing-indexes.asciidoc[] diff --git a/cypher/cypher-docs/src/docs/dev/execution-plans-operator-summary.asciidoc b/cypher/cypher-docs/src/docs/dev/execution-plans-operator-summary.asciidoc index 0475d6d0ece..43d9ddfd13d 100644 --- a/cypher/cypher-docs/src/docs/dev/execution-plans-operator-summary.asciidoc +++ b/cypher/cypher-docs/src/docs/dev/execution-plans-operator-summary.asciidoc @@ -142,48 +142,18 @@ Tests for the absence of a pattern predicate. | | -| <> -| Drops an index from a property for all nodes having a certain label. -| label:yes[] -| label:yes[] -| label:deprecated[] - -| <> +| <> | Drops an index using its name. | label:yes[] | label:yes[] | -| <> +| <> | Drops a constraint using its name. | label:yes[] | label:yes[] | -| <> -| Drops a node key constraint from a set of properties for all nodes having a certain label. -| label:yes[] -| label:yes[] -| label:deprecated[] - -| <> -| Drops an existence constraint from a property for all nodes having a certain label. -| label:yes[] -| label:yes[] -| label:deprecated[] - -| <> -| Drops an existence constraint from a property for all relationships of a certain type. -| label:yes[] -| label:yes[] -| label:deprecated[] - -| <> -| Drops a unique constraint from a set of properties for all nodes having a certain label. -| label:yes[] -| label:yes[] -| label:deprecated[] - | <> | For isolation purposes, `Eager` ensures that operations affecting subsequent operations are executed fully for the whole dataset before continuing execution. | diff --git a/cypher/cypher-docs/src/docs/dev/ql/administration/indexes-for-search-performance/index.asciidoc b/cypher/cypher-docs/src/docs/dev/ql/administration/indexes-for-search-performance/index.asciidoc index 48e2a7bed0b..bd4a0b75349 100644 --- a/cypher/cypher-docs/src/docs/dev/ql/administration/indexes-for-search-performance/index.asciidoc +++ b/cypher/cypher-docs/src/docs/dev/ql/administration/indexes-for-search-performance/index.asciidoc @@ -182,21 +182,6 @@ SHOW [ALL\|BTREE\|FULLTEXT\|LOOKUP\|TEXT] INDEX[ES] | List indexes in the database, either all or filtered on index type. | When using the `RETURN` clause, the `YIELD` clause is mandatory and must not be omitted. -| [source, cypher, role=noplay] ----- -DROP INDEX ON :LabelName(propertyName) ----- -| Drop a single-property index on nodes without specifying a name. -.2+.^| [deprecated]#This syntax is deprecated.# - -| [source, cypher, role=noplay] ----- -DROP INDEX ON :LabelName (n.propertyName_1, -n.propertyName_2, -… -n.propertyName_n) ----- -| Drop a composite index on nodes without specifying a name. |=== Creating an index requires <>, @@ -547,17 +532,3 @@ include::../indexes/create-a-point-index-specifying-the-index-provider.asciidoc[ include::../indexes/create-a-point-index-specifying-the-index-configuration.asciidoc[leveloffset=+1] include::../indexes/create-a-point-index-specifying-both-the-index-provider-and-configuration.asciidoc[leveloffset=+1] - - -[role=deprecated] -[[administration-indexes-examples-deprecated-syntax]] -== Deprecated syntax - -[NOTE] -==== -This syntax only supports dropping b-tree node property indexes, all others can only be dropped by name. -==== - -include::../indexes/drop-a-single-property-index.asciidoc[leveloffset=+1] - -include::../indexes/drop-a-composite-index.asciidoc[leveloffset=+1] diff --git a/cypher/cypher-docs/src/docs/dev/ql/constraints/examples.adoc b/cypher/cypher-docs/src/docs/dev/ql/constraints/examples.adoc index e739e46781d..cb9d9e089a2 100644 --- a/cypher/cypher-docs/src/docs/dev/ql/constraints/examples.adoc +++ b/cypher/cypher-docs/src/docs/dev/ql/constraints/examples.adoc @@ -148,29 +148,17 @@ include::../administration/constraints/listing-constraints-with-filtering.asciid [discrete] include::../administration/constraints/create-a-unique-constraint-using-deprecated-syntax.asciidoc[leveloffset=+1] -[discrete] -include::../administration/constraints/drop-a-unique-constraint.asciidoc[leveloffset=+1] - [discrete] include::../administration/constraints/create-a-node-property-existence-constraint-using-deprecated-syntax-1.asciidoc[leveloffset=+1] [discrete] include::../administration/constraints/create-a-node-property-existence-constraint-using-deprecated-syntax-2.asciidoc[leveloffset=+1] -[discrete] -include::../administration/constraints/drop-a-node-property-existence-constraint.asciidoc[leveloffset=+1] - [discrete] include::../administration/constraints/create-a-relationship-property-existence-constraint-using-deprecated-syntax-1.asciidoc[leveloffset=+1] [discrete] include::../administration/constraints/create-a-relationship-property-existence-constraint-using-deprecated-syntax-2.asciidoc[leveloffset=+1] -[discrete] -include::../administration/constraints/drop-a-relationship-property-existence-constraint.asciidoc[leveloffset=+1] - [discrete] include::../administration/constraints/create-a-node-key-constraint-using-deprecated-syntax.asciidoc[leveloffset=+1] - -[discrete] -include::../administration/constraints/drop-a-node-key-constraint.asciidoc[leveloffset=+1] diff --git a/cypher/cypher-docs/src/docs/dev/ql/constraints/syntax.adoc b/cypher/cypher-docs/src/docs/dev/ql/constraints/syntax.adoc index 318e57bec2a..836ae7c6b97 100644 --- a/cypher/cypher-docs/src/docs/dev/ql/constraints/syntax.adoc +++ b/cypher/cypher-docs/src/docs/dev/ql/constraints/syntax.adoc @@ -121,10 +121,7 @@ Index provider and configuration can be specified using the `OPTIONS` clause. [[administration-constraints-syntax-drop]] == Syntax for dropping constraints -[discrete] -=== Drop a constraint - -The preferred way of dropping a constraint is by the name of the constraint. +Dropping a constraint is done by the name of the constraint. This drop command is optionally idempotent, with the default behavior to throw an error if you attempt to drop the same constraint twice. With the `IF EXISTS` flag, no error is thrown and nothing happens should the constraint not exist. @@ -136,68 +133,6 @@ Dropping a constraint requires the < executePreparationQueries(List("CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE")), - assertions = _ => assertNodeConstraintDoesNotExist("Book", "isbn") - ) - } - @Test def play_nice_with_unique_property_constraint() { generateConsole = false @@ -245,18 +233,6 @@ class ConstraintsTest extends DocumentingTestBase with SoftReset { ) } - @Test def drop_node_property_existence_constraint() { - generateConsole = false - - prepareAndTestQuery( - title = "Drop a node property existence constraint", - text = "By using `DROP CONSTRAINT`, a node property existence constraint is removed from the database.", - queryText = "DROP CONSTRAINT ON (book:Book) ASSERT exists(book.isbn)", - prepare = _ => executePreparationQueries(List("CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS NOT NULL")), - assertions = _ => assertNodeConstraintDoesNotExist("Book", "isbn") - ) - } - @Test def play_nice_with_node_property_existence_constraint() { generateConsole = false @@ -347,18 +323,6 @@ class ConstraintsTest extends DocumentingTestBase with SoftReset { ) } - @Test def drop_relationship_property_existence_constraint() { - generateConsole = false - - prepareAndTestQuery( - title = "Drop a relationship property existence constraint", - text = "To remove a relationship property existence constraint from the database, use `DROP CONSTRAINT`.", - queryText = "DROP CONSTRAINT ON ()-[like:LIKED]-() ASSERT exists(like.day)", - prepare = _ => executePreparationQueries(List("CREATE CONSTRAINT FOR ()-[like:LIKED]-() REQUIRE like.day IS NOT NULL")), - assertions = _ => assertRelationshipConstraintDoesNotExist("LIKED", "day") - ) - } - @Test def play_nice_with_relationship_property_existence_constraint() { generateConsole = false @@ -486,18 +450,6 @@ class ConstraintsTest extends DocumentingTestBase with SoftReset { ) } - @Test def drop_node_key_constraint() { - generateConsole = false - - prepareAndTestQuery( - title = "Drop a node key constraint", - text = "Use `DROP CONSTRAINT` to remove a b-tree index-backed node key constraint from the database.", - queryText = "DROP CONSTRAINT ON (n:Person) ASSERT (n.firstname, n.surname) IS NODE KEY", - prepare = _ => executePreparationQueries(List("CREATE CONSTRAINT FOR (n:Person) REQUIRE (n.firstname, n.surname) IS NODE KEY")), - assertions = _ => assertNodeKeyConstraintDoesNotExist("Person", "firstname", "surname") - ) - } - @Test def play_nice_with_node_key_constraint() { generateConsole = false @@ -592,22 +544,10 @@ class ConstraintsTest extends DocumentingTestBase with SoftReset { assert(hasNodeKeyConstraint(labelName, propNames.toSeq)) } - private def assertNodeConstraintDoesNotExist(labelName: String, propName: String) { - assert(!hasNodeConstraint(labelName, propName)) - } - - private def assertNodeKeyConstraintDoesNotExist(labelName: String, propNames: String*) { - assert(!hasNodeKeyConstraint(labelName, propNames.toSeq)) - } - private def assertRelationshipConstraintExist(typeName: String, propName: String) { assert(hasRelationshipConstraint(typeName, propName)) } - private def assertRelationshipConstraintDoesNotExist(typeName: String, propName: String) { - assert(!hasRelationshipConstraint(typeName, propName)) - } - def assertConstraintWithNameExists(name: String, expectedLabelOrType: String, expectedProperties: List[String], forRelationship: Boolean = false) { val transaction = db.beginTx() try { diff --git a/cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/QueryPlanTest.scala b/cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/QueryPlanTest.scala index 79d17ef0607..9a7efbce906 100644 --- a/cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/QueryPlanTest.scala +++ b/cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/QueryPlanTest.scala @@ -121,21 +121,6 @@ class QueryPlanTest extends DocumentingTestBase with SoftReset { ) } - @Test def dropUniqueConstraint() { - executePreparationQueries { - List("CREATE CONSTRAINT FOR (c:Country) REQUIRE c.name is UNIQUE") - } - - profileQuery( - title = "Drop Unique Constraint", - text = - """The `DropUniqueConstraint` operator removes a unique constraint from all nodes having a certain set of properties and label. - |The following query will drop a unique constraint on the `name` property of nodes with the `Country` label.""".stripMargin, - queryText = """DROP CONSTRAINT ON (c:Country) ASSERT c.name is UNIQUE""", - assertions = p => assertThat(p.executionPlanString(), containsString("DropConstraint")) - ) - } - @Test def doNothingIfExistsForConstraint() { profileQuery( title = "Create Constraint only if it does not already exist", @@ -171,22 +156,6 @@ class QueryPlanTest extends DocumentingTestBase with SoftReset { ) } - @Test def dropNodePropertyExistenceConstraint() { - executePreparationQueries { - List("CREATE CONSTRAINT FOR (p:Person) REQUIRE p.name IS NOT NULL") - } - - profileQuery( - title = "Drop Node Property Existence Constraint", - text = - """The `DropNodePropertyExistenceConstraint` operator removes an existence constraint from a property for all nodes having a certain label. - |This will only appear in Enterprise Edition. - """.stripMargin, - queryText = """DROP CONSTRAINT ON (p:Person) ASSERT exists(p.name)""", - assertions = p => assertThat(p.executionPlanString(), containsString("DropConstraint")) - ) - } - @Test def createNodeKeyConstraint() { profileQuery( title = "Create Node Key Constraint", @@ -204,22 +173,6 @@ class QueryPlanTest extends DocumentingTestBase with SoftReset { ) } - @Test def dropNodeKeyConstraint() { - executePreparationQueries { - List("CREATE CONSTRAINT FOR (e:Employee) REQUIRE (e.firstname, e.surname) IS NODE KEY") - } - - profileQuery( - title = "Drop Node Key Constraint", - text = - """The `DropNodeKeyConstraint` operator removes a node key constraint from a set of properties for all nodes having a certain label. - |This will only appear in Enterprise Edition. - """.stripMargin, - queryText = """DROP CONSTRAINT ON (e:Employee) ASSERT (e.firstname, e.surname) IS NODE KEY""", - assertions = p => assertThat(p.executionPlanString(), containsString("DropConstraint")) - ) - } - @Test def createRelationshipPropertyExistenceConstraint() { profileQuery( title = "Create Relationship Property Existence Constraint", @@ -236,28 +189,13 @@ class QueryPlanTest extends DocumentingTestBase with SoftReset { ) } - @Test def dropRelationshipPropertyExistenceConstraint() { - executePreparationQueries { - List("CREATE CONSTRAINT FOR ()-[l:LIKED]-() REQUIRE l.when IS NOT NULL") - } - - profileQuery( - title = "Drop Relationship Property Existence Constraint", - text = - """The `DropRelationshipPropertyExistenceConstraint` operator removes an existence constraint from a property for all relationships of a certain type. - |This will only appear in Enterprise Edition.""".stripMargin, - queryText = """DROP CONSTRAINT ON ()-[l:LIKED]-() ASSERT exists(l.when)""", - assertions = p => assertThat(p.executionPlanString(), containsString("DropConstraint")) - ) - } - - @Test def dropNamedConstraint() { + @Test def dropConstraint() { executePreparationQueries { List("CREATE CONSTRAINT name FOR (c:Country) REQUIRE c.name is UNIQUE") } profileQuery( - title = "Drop Constraint by name", + title = "Drop Constraint", text = """The `DropConstraint` operator removes a constraint using the name of the constraint, no matter the type.""".stripMargin, queryText = """DROP CONSTRAINT name""", @@ -324,27 +262,12 @@ class QueryPlanTest extends DocumentingTestBase with SoftReset { } @Test def dropIndex() { - executePreparationQueries { - List("CREATE INDEX FOR (c:Country) ON (c.name)") - } - - profileQuery( - title = "Drop Index by schema", - text = - """The `DropIndex` operator removes an index from a property for all nodes having a certain label. - |The following query will drop an index on the `name` property of nodes with the `Country` label.""".stripMargin, - queryText = """DROP INDEX ON :Country(name)""", - assertions = p => assertThat(p.executionPlanString(), containsString("DropIndex")) - ) - } - - @Test def dropNamedIndex() { executePreparationQueries { List("CREATE INDEX name FOR (c:Country) ON (c.name)") } profileQuery( - title = "Drop Index by name", + title = "Drop Index", text = """The `DropIndex` operator removes an index using the name of the index.""".stripMargin, queryText = """DROP INDEX name""", diff --git a/cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/SchemaIndexTest.scala b/cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/SchemaIndexTest.scala index 6bd55d98445..5ea14951e79 100644 --- a/cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/SchemaIndexTest.scala +++ b/cypher/cypher-docs/src/test/scala/org/neo4j/cypher/docgen/SchemaIndexTest.scala @@ -460,27 +460,6 @@ class SchemaIndexTest extends DocumentingTestBase with QueryStatisticsTestSuppor ) } - @Test def drop_index_on_a_label_single_property() { - prepareAndTestQuery( - title = "Drop a single-property index", - text = "A b-tree index on all nodes with a label and single property combination can be dropped with `DROP INDEX ON :Label(property)`.", - prepare = _ => executePreparationQueries(List("create btree index for (p:Person) on (p.firstname)")), - queryText = "DROP INDEX ON :Person(firstname)", - assertions = _ => assertIndexesOnLabels("Person", List(List("middlename"), List("surname"), List("location"), List("highScore"))) - ) - } - - @Test def drop_index_on_a_label_composite_property() { - prepareAndTestQuery( - title = "Drop a composite index", - text = "A composite b-tree index on all nodes with a label and multiple property combination can be dropped with `DROP INDEX ON :Label(prop1, ..., propN)`. " + - "The following statement will drop a composite index on all nodes labeled with `Person` and which have both an `age` and `country` property: ", - prepare = _ => executePreparationQueries(List("create btree index for (p:Person) on (p.age, p.country)")), - queryText = "DROP INDEX ON :Person(age, country)", - assertions = _ => assertIndexesOnLabels("Person", List(List("firstname"), List("middlename"), List("surname"), List("location"), List("highScore"))) - ) - } - @Test def drop_index() { prepareAndTestQuery( title = "Drop an index", diff --git a/cypher/cypher-prettifier/src/main/scala/org/neo4j/cypher/docgen/tooling/PrettifierParser.scala b/cypher/cypher-prettifier/src/main/scala/org/neo4j/cypher/docgen/tooling/PrettifierParser.scala index 286cb847146..fe1239ac52c 100644 --- a/cypher/cypher-prettifier/src/main/scala/org/neo4j/cypher/docgen/tooling/PrettifierParser.scala +++ b/cypher/cypher-prettifier/src/main/scala/org/neo4j/cypher/docgen/tooling/PrettifierParser.scala @@ -116,12 +116,10 @@ class PrettifierParser(val keepMyNewlines: Boolean) extends Parser with Base wit keyword("CREATE INDEX") | // These are for the named versions, sadly they will break the query on the ON keyword keyword("CREATE BTREE INDEX") | // Sadly these will break the query on the ON keyword keyword("CREATE LOOKUP INDEX") | // Sadly these will break the query on the ON keyword - keyword("DROP INDEX ON") | // Deprecated keyword("DROP INDEX") | showIndexBreakingKeyword | keyword("CREATE CONSTRAINT ON") | keyword("CREATE CONSTRAINT") | // These are for the named versions, sadly they will break the query on the ON keyword - keyword("DROP CONSTRAINT ON") | // Deprecated keyword("DROP CONSTRAINT") | showConstraintBreakingKeyword | keyword("USING PERIODIC COMMIT") |