Changeset: e605acf52e1c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e605acf52e1c
Modified Files:
        sql/backends/monet5/vaults/lidar/lidar.c
Branch: data-vaults
Log Message:

Finally fix the server crash

The following sequence of statements resulted in a crash

create table tbl0 (i int);
call lidarattach('/home/kutsurak/sources/libLAS/test/data/1.0_0.las', 'tbl1', 
'XYZauinrcpedM');
call lidarattach('/home/kutsurak/sources/libLAS/test/data/autzen.las', 'tbl0', 
'XYZauinrcpedM');
call lidarload('tbl0');

Table tbl0 is created independently of the lidar vault. The first call to
lidarattach creates tbl1 as a lidar table, and (more importantly) the lidar
catalog. The second call to lidarattach fails because the lidar vault cannot
create tbl0, since it exists already. Then the call to lidarload for tbl0
crashes the server because the lidar catalog is not queried correctly.


diffs (91 lines):

diff --git a/sql/backends/monet5/vaults/lidar/lidar.c 
b/sql/backends/monet5/vaults/lidar/lidar.c
--- a/sql/backends/monet5/vaults/lidar/lidar.c
+++ b/sql/backends/monet5/vaults/lidar/lidar.c
@@ -1807,6 +1807,7 @@ str LIDARloadTable(Client cntxt, MalBlkP
        char *filenames_query = GDKmalloc(BUFSIZ);
        str etname = NULL;
        res_table *fres = NULL;
+       BAT *b;
 
        if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != MAL_SUCCEED) {
                goto loadtable_cleanup;
@@ -1831,45 +1832,48 @@ str LIDARloadTable(Client cntxt, MalBlkP
                goto loadtable_cleanup;
        }
 
-       if (fres) {
-               BATiter fs_rid = bat_iterator(BATdescriptor(fres->cols[0].b));
-               oid id = 0, cnt = BATcount(fs_rid.b);
+       b = BATdescriptor(fres->cols[0].b);
+       if (b) {
+               if (BATcount(b) > 0) {
+                       BATiter fs_rid = 
bat_iterator(BATdescriptor(fres->cols[0].b));
+                       oid id = 0, cnt = BATcount(fs_rid.b);
 
-               sch = mvc_bind_schema(m, "sys");
-               if (sch == NULL) {
-                       msg = createException(MAL, "lidar.loadtable", "Cannot 
access schema \"sys\"\n");
-                       goto loadtable_cleanup;
-               }
+                       sch = mvc_bind_schema(m, "sys");
+                       if (sch == NULL) {
+                               msg = createException(MAL, "lidar.loadtable", 
"Cannot access schema \"sys\"\n");
+                               goto loadtable_cleanup;
+                       }
 
-               lidar_tbl = mvc_bind_table(m, sch, "lidar_tables");
-               if (lidar_tbl == NULL) {
-                       msg = createException(MAL, "lidar.loadtable", "LIDAR 
catalog is missing.\n");
-                       goto loadtable_cleanup;
-               }
+                       lidar_tbl = mvc_bind_table(m, sch, "lidar_tables");
+                       if (lidar_tbl == NULL) {
+                               msg = createException(MAL, "lidar.loadtable", 
"LIDAR catalog is missing.\n");
+                               goto loadtable_cleanup;
+                       }
 
-               tbl = mvc_bind_table(m, sch, tname);
-               if (tbl == NULL) {
-                       msg = createException(MAL, "lidar.loadtable", "Could 
not find table %s.\n", tname);
-                       goto loadtable_cleanup;
-               }
+                       tbl = mvc_bind_table(m, sch, tname);
+                       if (tbl == NULL) {
+                               msg = createException(MAL, "lidar.loadtable", 
"Could not find table %s.\n", tname);
+                               goto loadtable_cleanup;
+                       }
 
-               col = mvc_bind_column(m, tbl, "x");
-               sz = store_funcs.count_col(m->session->tr, col, 1);
-               if (sz != 0) {
-                       msg = createException(MAL, "lidar.loadtable", "Table %s 
is not empty.\n", tname);
-                       goto loadtable_cleanup;
-               }
+                       col = mvc_bind_column(m, tbl, "x");
+                       sz = store_funcs.count_col(m->session->tr, col, 1);
+                       if (sz != 0) {
+                               msg = createException(MAL, "lidar.loadtable", 
"Table %s is not empty.\n", tname);
+                               goto loadtable_cleanup;
+                       }
 #ifndef NDEBUG
-               fprintf(stderr, "count: " OIDFMT "\n", cnt);
+                       fprintf(stderr, "count: " OIDFMT "\n", cnt);
 #endif
-               for (id = 0; id < cnt; id++) {
-                       int rid = *(int*)BUNtail(fs_rid, id);
+                       for (id = 0; id < cnt; id++) {
+                               int rid = *(int*)BUNtail(fs_rid, id);
 #ifndef NDEBUG
-                       fprintf(stderr, "id, rid: " OIDFMT " %d\n", id, rid);
+                               fprintf(stderr, "id, rid: " OIDFMT " %d\n", id, 
rid);
 #endif
-                       msg = LIDARloadTable_(m, sch, lidar_tbl, tbl, rid - 1);
-                       if (msg != MAL_SUCCEED) {
-                               goto loadtable_cleanup;
+                               msg = LIDARloadTable_(m, sch, lidar_tbl, tbl, 
rid - 1);
+                               if (msg != MAL_SUCCEED) {
+                                       goto loadtable_cleanup;
+                               }
                        }
                }
        }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to