Changeset: 0f906e93845c for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0f906e93845c
Modified Files:
        monetdb5/modules/mal/tablet.c
Branch: Dec2016
Log Message:

Fix crashes when first column is not used for COPY INTO.


diffs (57 lines):

diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -958,6 +958,9 @@ SQLworker_column(READERtask *task, int c
        int i;
        Column *fmt = task->as->format;
 
+       if (fmt[col].c == NULL)
+               return 0;
+
        /* watch out for concurrent threads */
        MT_lock_set(&mal_copyLock);
        if (!fmt[col].skip && BATcapacity(fmt[col].c) < BATcount(fmt[col].c) + 
task->next) {
@@ -1616,6 +1619,7 @@ SQLload_file(Client cntxt, Tablet *as, b
        BUN cnt = 0, cntstart = 0, leftover = 0;
        int res = 0;            /* < 0: error, > 0: success, == 0: continue 
processing */
        int j;
+       BUN firstcol;
        BUN i, attr;
        READERtask *task = (READERtask *) GDKzalloc(sizeof(READERtask));
        READERtask ptask[MAXWORKERS];
@@ -1761,10 +1765,13 @@ SQLload_file(Client cntxt, Tablet *as, b
 #ifdef MLOCK_TST
        mlock(task->b->buf, task->b->size);
 #endif
+       for (firstcol = 0; firstcol < task->as->nr_attrs; firstcol++)
+               if (task->as->format[firstcol].c != NULL)
+                       break;
        while (res == 0 && cnt < task->maxrow) {
 
                // track how many elements are in the aggregated BATs
-               cntstart = BATcount(task->as->format[0].c);
+               cntstart = BATcount(task->as->format[firstcol].c);
                /* block until the producer has data available */
                MT_sema_down(&task->consumer);
                cnt += task->top[task->cur];
@@ -1856,9 +1863,9 @@ SQLload_file(Client cntxt, Tablet *as, b
 
 #ifdef _DEBUG_TABLET_
                mnstr_printf(GDKout, "#Trim bbest %d table size " BUNFMT " rows 
found so far " BUNFMT "\n",
-                                        best, BATcount(as->format[0].c), 
task->cnt);
+                                        best, 
BATcount(as->format[firstcol].c), task->cnt);
 #endif
-               if (best && BATcount(as->format[0].c)) {
+               if (best && BATcount(as->format[firstcol].c)) {
                        BUN limit;
                        int width;
 
@@ -1919,7 +1926,7 @@ SQLload_file(Client cntxt, Tablet *as, b
                                 task->ateof, res);
 #endif
 
-       cnt = BATcount(task->as->format[0].c);
+       cnt = BATcount(task->as->format[firstcol].c);
        if (GDKdebug & GRPalgorithms) {
                mnstr_printf(GDKout, "#COPY reader time " LLFMT " line break " 
LLFMT " io " LLFMT "\n",
                                         total, lio, iototal);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to