Skip to content

CREATE PROPERTY does not check the values already stored, though the documentation says it fails over incompatible ones: an INTEGER is declared over 'abc' and true and a DATETIME over 'not a date', after which CREATE INDEX fails or the index misses the record #9016

Closed as duplicate

Description

@tae898

The CREATE PROPERTY documentation says "When you create a property, ArcadeDB checks the data for property and type. In the event that persistent data contains incompatible values for the specified type, the property creation fails." In the repro, a record holds v = 'abc', v = true, or v = 'not a date' before CREATE PROPERTY T.v INTEGER (or DATETIME), and the statement is accepted every time. The records keep the old values (String abc, Boolean true, String not a date) under the new declaration. A following CREATE INDEX ON T (v) then either fails (IndexException, caused by NumberFormatException: For input string: "abc") or succeeds and answers WHERE v = true and WHERE v = 'not a date' with 0 rows, where the same query found the record before the index existed.

CreatePropertyStatement creates the property and applies its attributes without reading the type's records (CreatePropertyStatement.java#L99-L108), and LocalDocumentType.createProperty() checks only the schema (LocalDocumentType.java#L838-L876).

Related: #8943 (fixed in #8956) made ALTER PROPERTY ... MANDATORY/NOTNULL true check the existing records; #8999 (merged into #9000) is openCypher CREATE INDEX declaring a type the existing values do not fit. Neither covers CREATE PROPERTY over values of another type.

Repro

# lib/ holds the engine jar built at the commit under test and its dependencies
javac -cp "lib/*" CreatePropertyTypeCheck.java
java -XX:+UseCompactObjectHeaders --add-modules=jdk.incubator.vector --enable-native-access=ALL-UNNAMED -cp "lib/*:." CreatePropertyTypeCheck ./db
import com.arcadedb.database.*;

public class CreatePropertyTypeCheck {
  public static void main(String[] args) {
    System.out.println("ArcadeDB " + com.arcadedb.Constants.getRawVersion() + " (" + com.arcadedb.Constants.getBuildNumber() + "), Java "
        + System.getProperty("java.version"));
    try (Database db = new DatabaseFactory(args[0]).create()) {
      final String[][] cases = { { "INTEGER", "'abc'" }, { "INTEGER", "true" }, { "DATETIME", "'not a date'" } };
      int i = 0;
      for (String[] c : cases) {
        final String t = "T" + (i++);
        db.command("sql", "CREATE DOCUMENT TYPE " + t);
        db.transaction(() -> db.command("sql", "INSERT INTO " + t + " SET v = " + c[1]).close());
        db.command("sql", "CREATE PROPERTY " + t + ".v " + c[0]);
        final Object v = db.query("sql", "SELECT v FROM " + t).next().getProperty("v");
        System.out.println("v = " + c[1] + ", then CREATE PROPERTY " + t + ".v " + c[0] + " -> accepted; v reads " + v.getClass().getSimpleName() + " " + v);
        final Object scan = db.query("sql", "SELECT count(*) AS c FROM " + t + " WHERE v = " + c[1]).next().getProperty("c");
        try {
          db.command("sql", "CREATE INDEX ON " + t + " (v) NOTUNIQUE");
          System.out.println("  WHERE v = " + c[1] + ": " + scan + " row without an index; CREATE INDEX accepted, then " + db.query("sql",
              "SELECT count(*) AS c FROM " + t + " WHERE v = " + c[1]).next().getProperty("c") + " rows");
        } catch (Exception e) {
          Throwable r = e;
          while (r.getCause() != null && r.getCause() != r)
            r = r.getCause();
          System.out.println("  WHERE v = " + c[1] + ": " + scan + " row without an index; CREATE INDEX refused: " + e.getClass().getSimpleName()
              + ", caused by " + r.getClass().getSimpleName() + ": " + r.getMessage());
        }
      }
    }
  }
}

Output on main cecb369df9 (the engine jar's build stamp is 04bb03ebec, the newest commit in it that is not a merge), Temurin 25.0.4 with -XX:+UseCompactObjectHeaders. Temurin 21.0.12 printed the same lines apart from the Java version on the first line.

ArcadeDB 26.10.1-SNAPSHOT (04bb03ebec07fce19101595d65ca1e3bdf516755), Java 25.0.4
v = 'abc', then CREATE PROPERTY T0.v INTEGER -> accepted; v reads String abc
  WHERE v = 'abc': 1 row without an index; CREATE INDEX refused: IndexException, caused by NumberFormatException: For input string: "abc"
v = true, then CREATE PROPERTY T1.v INTEGER -> accepted; v reads Boolean true
  WHERE v = true: 1 row without an index; CREATE INDEX accepted, then 0 rows
v = 'not a date', then CREATE PROPERTY T2.v DATETIME -> accepted; v reads String not a date
  WHERE v = 'not a date': 1 row without an index; CREATE INDEX accepted, then 0 rows

Versions affected: main cecb369df9 on Temurin 25 and 21, main 417314c18 (2026-09-17), and 26.9.1 print the same lines.

Expected: as documented, CREATE PROPERTY fails when a stored value cannot be converted to the declared type, naming the record, so a later index never meets a value of another type. Alternatively the documentation should say that existing values are not checked.

Activity

  1. added
    engine
    severity:minor
    on Oct 3, 2026
  2. added this to the 26.10.1 milestone on Oct 3, 2026
  3. github-actions commented on Oct 3, 2026

    @github-actions
    Contributor

    Merged into #9112, which now tracks this together with the other related issues in engine. Closing here as a duplicate - reopen this issue if the grouping is wrong.

  4. tae898 commented on Oct 4, 2026

    @tae898
    ContributorAuthor

    Verified on upstream main d9f7479 (it contains the merge of #9116; engine, server and plugin jars built from it), the repro from the description, on JDK 25 (compact object headers) and JDK 21. The output is the same on both JDKs.

    417314c (before) d9f7479 (after)
    v = 'abc', then CREATE PROPERTY T0.v INTEGER accepted, v still reads the String CommandExecutionException: "Cannot create property 'T0.v': record #1:0 violates it", no property left
    v = true, then CREATE PROPERTY T1.v INTEGER accepted refused the same way (the repro stops at the first refusal)
    v = 'not a date', then CREATE PROPERTY T2.v DATETIME accepted refused the same way

    The repro now ends with the first refusal as an uncaught exception, because it was written to expect acceptance.

    Thanks for the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugengineseverity:minorsql

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions