Changeset: aeb5dcbc8b7d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/aeb5dcbc8b7d
Added Files:
        sql/test/remote/Tests/remote_info_missing.test
Modified Files:
        sql/server/sql_mvc.c
        sql/test/remote/Tests/All
Branch: Dec2023
Log Message:

in case the remote user info is missing still drop the remote table definition.
Added test as well.


diffs (59 lines):

diff --git a/sql/server/sql_mvc.c b/sql/server/sql_mvc.c
--- a/sql/server/sql_mvc.c
+++ b/sql/server/sql_mvc.c
@@ -1296,8 +1296,9 @@ mvc_create_remote(sql_table **t, mvc *m,
 }
 
 static str
-remote_drop(mvc *m, sqlid id)
+remote_drop(mvc *m, sql_table *t)
 {
+       sqlid id = t->base.id;
        int log_res = 0;
        sql_trans *tr = m->session->tr;
        sqlstore *store = tr->store;
@@ -1305,7 +1306,9 @@ remote_drop(mvc *m, sqlid id)
        sql_table *remote_user_info = find_sql_table(tr, sys, REMOTE_USER_INFO);
        sql_column *remote_user_info_id = find_sql_column(remote_user_info, 
"table_id");
        oid rid = store->table_api.column_find_row(tr, remote_user_info_id, 
&id, NULL);
-       if (is_oid_nil(rid) || (log_res = store->table_api.table_delete(tr, 
remote_user_info, rid)) != 0)
+       if (is_oid_nil(rid)) {
+               TRC_WARNING(SQL_TRANS, "Drop table: %s %s no remote info\n", 
t->s->base.name, t->base.name);
+       } else if ((log_res = store->table_api.table_delete(tr, 
remote_user_info, rid)) != 0)
                throw(SQL, "sql.drop_table", SQLSTATE(42000) "Drop table 
failed%s", log_res == LOG_CONFLICT ? " due to conflict with another 
transaction" : "");
        return MAL_SUCCEED;
 }
@@ -1316,7 +1319,7 @@ mvc_drop_table(mvc *m, sql_schema *s, sq
        char *msg = NULL;
        TRC_DEBUG(SQL_TRANS, "Drop table: %s %s\n", s->base.name, t->base.name);
 
-       if (isRemote(t) && (msg = remote_drop(m, t->base.id)) != NULL)
+       if (isRemote(t) && (msg = remote_drop(m, t)) != NULL)
                return msg;
 
        switch (sql_trans_drop_table(m->session->tr, s, t->base.name, 
drop_action ? DROP_CASCADE_START : DROP_RESTRICT)) {
diff --git a/sql/test/remote/Tests/All b/sql/test/remote/Tests/All
--- a/sql/test/remote/Tests/All
+++ b/sql/test/remote/Tests/All
@@ -3,3 +3,4 @@ HAVE_DATA_PATH?creds
 HAVE_DATA_PATH?invalid_creds
 HAVE_DATA_PATH?different_user
 THREADS>=2?partition_elim
+remote_info_missing
diff --git a/sql/test/remote/Tests/remote_info_missing.test 
b/sql/test/remote/Tests/remote_info_missing.test
new file mode 100644
--- /dev/null
+++ b/sql/test/remote/Tests/remote_info_missing.test
@@ -0,0 +1,12 @@
+statement ok
+create remote table t1234 (c int) on 'mapi:monetdb://localhost:50000/demo/t1'
+
+statement ok
+delete from remote_user_info where table_id = (select id from sys._tables 
where name = 't1234')
+
+statement ok
+drop table t1234;
+
+query T
+select name from sys._tables where name = 't1234';
+----
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to