Changeset: b9cab4aacdb3 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b9cab4aacdb3
Modified Files:
        sql/backends/monet5/sql_cat.c
        sql/backends/monet5/sql_statistics.c
        sql/test/miscellaneous/Tests/transaction_isolation4.SQL.py
Branch: iso
Log Message:

Some more transaction dependency cases


diffs (72 lines):

diff --git a/sql/backends/monet5/sql_cat.c b/sql/backends/monet5/sql_cat.c
--- a/sql/backends/monet5/sql_cat.c
+++ b/sql/backends/monet5/sql_cat.c
@@ -1828,15 +1828,18 @@ SQLcomment_on(Client cntxt, MalBlkPtr mb
                        /* INSERT INTO sys.comments (id, remark) VALUES (%d, 
%s) */
                        ok = store->table_api.table_insert(tx, comments, 
&objid, &remark);
                }
+               if (ok != LOG_OK)
+                       throw(SQL, "sql.comment_on", SQLSTATE(42000) "Comment 
on failed%s", ok == LOG_CONFLICT ? " due to conflict with another transaction" 
: "");
+               if ((ok = sql_trans_add_dependency(tx, objid)) != LOG_OK) /* At 
the moment this adds dependencies for old objects :( */
+                       throw(SQL, "sql.comment_on", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
        } else {
                if (!is_oid_nil(rid)) {
                        // have no remark but found one, so delete row
                        /* DELETE FROM sys.comments WHERE id = %d */
-                       ok = store->table_api.table_delete(tx, comments, rid);
+                       if ((ok = store->table_api.table_delete(tx, comments, 
rid)) != LOG_OK)
+                               throw(SQL, "sql.comment_on", SQLSTATE(42000) 
"Comment on failed%s", ok == LOG_CONFLICT ? " due to conflict with another 
transaction" : "");
                }
        }
-       if (ok != LOG_OK)
-               throw(SQL, "sql.comment_on", SQLSTATE(42000) "Comment on 
failed%s", ok == LOG_CONFLICT ? " due to conflict with another transaction" : 
"");
        return MAL_SUCCEED;
 }
 
diff --git a/sql/backends/monet5/sql_statistics.c 
b/sql/backends/monet5/sql_statistics.c
--- a/sql/backends/monet5/sql_statistics.c
+++ b/sql/backends/monet5/sql_statistics.c
@@ -320,6 +320,11 @@ sql_analyze(Client cntxt, MalBlkPtr mb, 
                                                GDKfree(minval);
                                                throw(SQL, "analyze", 
SQLSTATE(42000) "ANALYZE: failed%s", log_res == LOG_CONFLICT ? " due to 
conflict with another transaction" : "");
                                        }
+                                       if (!isNew(c) && (log_res = 
sql_trans_add_dependency(tr, c->base.id)) != LOG_OK) {
+                                               GDKfree(maxval);
+                                               GDKfree(minval);
+                                               throw(SQL, "analyze", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
+                                       }
                                }
                        }
                }
diff --git a/sql/test/miscellaneous/Tests/transaction_isolation4.SQL.py 
b/sql/test/miscellaneous/Tests/transaction_isolation4.SQL.py
--- a/sql/test/miscellaneous/Tests/transaction_isolation4.SQL.py
+++ b/sql/test/miscellaneous/Tests/transaction_isolation4.SQL.py
@@ -6,6 +6,7 @@ with SQLTestCase() as mdb1:
         mdb2.connect(username="monetdb", password="monetdb")
 
         mdb1.execute("create table myt (i int, j int);").assertSucceeded()
+        mdb1.execute("insert into myt values (1, 1), (2, 2)").assertSucceeded()
         mdb1.execute('start transaction;').assertSucceeded()
         mdb2.execute('start transaction;').assertSucceeded()
         mdb1.execute("alter table myt add primary key (i);").assertSucceeded()
@@ -25,6 +26,20 @@ with SQLTestCase() as mdb1:
         mdb2.execute('commit;').assertFailed(err_code="40000", 
err_message="COMMIT: transaction is aborted because of concurrency conflicts, 
will ROLLBACK instead")
 
         mdb1.execute('start transaction;').assertSucceeded()
+        mdb2.execute('start transaction;').assertSucceeded()
+        mdb1.execute("analyze sys.myt").assertSucceeded()
+        mdb2.execute('drop table myt;').assertSucceeded()
+        mdb1.execute('commit;').assertSucceeded()
+        mdb2.execute('commit;').assertFailed(err_code="40000", 
err_message="COMMIT: transaction is aborted because of concurrency conflicts, 
will ROLLBACK instead")
+
+        mdb1.execute('start transaction;').assertSucceeded()
+        mdb2.execute('start transaction;').assertSucceeded()
+        mdb1.execute('comment on table "sys"."myt" is 
\'amifine?\';').assertSucceeded()
+        mdb2.execute('drop table myt;').assertSucceeded()
+        mdb1.execute('commit;').assertSucceeded()
+        mdb2.execute('commit;').assertFailed(err_code="40000", 
err_message="COMMIT: transaction is aborted because of concurrency conflicts, 
will ROLLBACK instead")
+
+        mdb1.execute('start transaction;').assertSucceeded()
         mdb1.execute('drop table myt;').assertSucceeded()
         mdb1.execute('drop schema mys cascade;').assertSucceeded()
         mdb1.execute('commit;').assertSucceeded()
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to