Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ray6080 committed Jan 22, 2025
1 parent 9a5eaf1 commit 67cf682
Show file tree
Hide file tree
Showing 2 changed files with 314 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/binder/bind/bind_ddl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ void Binder::validateNoIndexOnProperty(const std::string& tableName,
const std::string& propertyName) const {
auto transaction = clientContext->getTransaction();
auto catalog = clientContext->getCatalog();
if (catalog->containsRelGroup(transaction, tableName)) {
// RelGroup does not have indexes.
return;
}
auto tableEntry = catalog->getTableCatalogEntry(transaction, tableName);
for (auto indexCatalogEntry : catalog->getIndexEntries(transaction)) {
if (indexCatalogEntry->getTableID() == tableEntry->getTableID()) {
Expand Down
310 changes: 310 additions & 0 deletions test/test_files/transaction/ddl/ddl_empty.test
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,313 @@ Binder exception: Cannot find property since for k.
2
3
4

-CASE RenameRelGroupCommit
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test RENAME TO test1;
---- ok
-STATEMENT COMMIT;
---- ok
-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 3
0|base1|NODE|local(kuzu)|
1|base2|NODE|local(kuzu)|
0|test1|REL|local(kuzu)|

-CASE RenameRelGroupRollback
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test RENAME TO test1;
---- ok
-STATEMENT ROLLBACK;
---- ok
-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 3
0|base1|NODE|local(kuzu)|
1|base2|NODE|local(kuzu)|
0|test|REL|local(kuzu)|

-CASE RenameRelGroupCommitRecovery
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test RENAME TO test1;
---- ok
-STATEMENT COMMIT;
---- ok
-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 3
0|base1|NODE|local(kuzu)|
1|base2|NODE|local(kuzu)|
0|test1|REL|local(kuzu)|
-RELOADDB
-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 3
0|base1|NODE|local(kuzu)|
1|base2|NODE|local(kuzu)|
0|test1|REL|local(kuzu)|

-CASE RenameRelGroupRollbackRecovery
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test RENAME TO test1;
---- ok
-STATEMENT ROLLBACK;
---- ok
-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 3
0|base1|NODE|local(kuzu)|
1|base2|NODE|local(kuzu)|
0|test|REL|local(kuzu)|
-RELOADDB
-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 3
0|base1|NODE|local(kuzu)|
1|base2|NODE|local(kuzu)|
0|test|REL|local(kuzu)|

-CASE RenameRelGroupPropertyCommit
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2, prop1 INT64);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test RENAME prop1 TO prop2;
---- ok
-STATEMENT COMMIT;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop2|INT64|NULL|both

-CASE RenameRelGroupPropertyRollback
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2, prop1 INT64);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test RENAME prop1 TO prop2;
---- ok
-STATEMENT ROLLBACK;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both

-CASE RenameRelGroupPropertyCommitRecovery
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2, prop1 INT64);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test RENAME prop1 TO prop2;
---- ok
-STATEMENT COMMIT;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop2|INT64|NULL|both
-RELOADDB
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop2|INT64|NULL|both

-CASE RenameRelGroupPropertyRollbackRecovery
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2, prop1 INT64);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test RENAME prop1 TO prop2;
---- ok
-STATEMENT ROLLBACK;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both
-RELOADDB
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both

-CASE AddDropRelGroupPropertyCommit
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test ADD prop1 INT64;
---- ok
-STATEMENT COMMIT;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both

-CASE AddDropRelGroupPropertyRollback
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test ADD prop1 INT64;
---- ok
-STATEMENT ROLLBACK;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 0

-CASE AddDropRelGroupPropertyCommitRecovery
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test ADD prop1 INT64;
---- ok
-STATEMENT COMMIT;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both
-RELOADDB
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both

-CASE AddDropRelGroupPropertyRollbackRecovery
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test ADD prop1 INT64;
---- ok
-STATEMENT ROLLBACK;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 0
-RELOADDB
-STATEMENT CALL table_info("test") RETURN *;
---- 0

-CASE DropRelGroupPropertyCommit
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2, prop1 INT64);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test DROP prop1;
---- ok
-STATEMENT COMMIT;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 0

-CASE DropRelGroupPropertyRollback
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2, prop1 INT64);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test DROP prop1;
---- ok
-STATEMENT ROLLBACK;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both

-CASE DropRelGroupPropertyCommitRecovery
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2, prop1 INT64);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test DROP prop1;
---- ok
-STATEMENT COMMIT;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 0
-RELOADDB
-STATEMENT CALL table_info("test") RETURN *;
---- 0

-CASE DropRelGroupPropertyRollbackRecovery
-STATEMENT CREATE NODE TABLE base1(id INT64, primary key(id));
---- ok
-STATEMENT CREATE NODE TABLE base2(id INT64, primary key(id));
---- ok
-STATEMENT CREATE REL TABLE test(FROM base1 TO base1, FROM base1 TO base2, prop1 INT64);
---- ok
-STATEMENT BEGIN TRANSACTION;
---- ok
-STATEMENT ALTER TABLE test DROP prop1;
---- ok
-STATEMENT ROLLBACK;
---- ok
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both
-RELOADDB
-STATEMENT CALL table_info("test") RETURN *;
---- 1
1|prop1|INT64|NULL|both

0 comments on commit 67cf682

Please sign in to comment.