Changeset: b98c6cfbdeff for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b98c6cfbdeff
Modified Files:
        clients/ChangeLog.Feb2013
        clients/odbc/driver/ODBCConvert.c
        clients/odbc/driver/SQLGetConnectAttr.c
        clients/odbc/driver/SQLGetInfo.c
        clients/odbc/driver/SQLSetConnectAttr.c
        clients/odbc/samples/arraytest.c
        gdk/gdk_utils.c
        monetdb5/mal/mal_dataflow.c
Branch: Feb2013
Log Message:

Merge with stable


diffs (truncated from 554 to 300 lines):

diff --git a/clients/ChangeLog.Feb2013 b/clients/ChangeLog.Feb2013
--- a/clients/ChangeLog.Feb2013
+++ b/clients/ChangeLog.Feb2013
@@ -1,3 +1,12 @@
 # ChangeLog file for clients
 # This file is updated with Maddlog
 
+* Wed Nov  6 2013 Sjoerd Mullender <[email protected]>
+- ODBC: Fixed interpretation SQL_C_SLONG/SQL_C_ULONG/SQL_C_LONG to
+  refer to a 32 bit integer always (i.e. "int" on 64 bit architectures
+  despite the name and the Microsoft documentation).  This seems to be
+  the consensus.
+- ODBC: Fixed transaction level: MonetDB only supports the highest level
+  (SQL_TXN_SERIALIZABLE), so setting the transaction level can be accepted
+  and ignored.
+
diff --git a/clients/odbc/driver/ODBCConvert.c 
b/clients/odbc/driver/ODBCConvert.c
--- a/clients/odbc/driver/ODBCConvert.c
+++ b/clients/odbc/driver/ODBCConvert.c
@@ -1985,9 +1985,9 @@ ODBCFetch(ODBCStmt *stmt,
                case SQL_C_LONG:
                        maxval <<= 31;
                        if (lenp)
-                               *lenp = sizeof(long);
+                               *lenp = sizeof(int);
                        if (ardrec && row > 0)
-                               ptr = (SQLPOINTER) ((char *) ptr + row * 
(bind_type == SQL_BIND_BY_COLUMN ? sizeof(long) : bind_type));
+                               ptr = (SQLPOINTER) ((char *) ptr + row * 
(bind_type == SQL_BIND_BY_COLUMN ? sizeof(int) : bind_type));
                        break;
                case SQL_C_SBIGINT:
                        maxval <<= 63;
@@ -2047,7 +2047,7 @@ ODBCFetch(ODBCStmt *stmt,
                                break;
                        case SQL_C_SLONG:
                        case SQL_C_LONG:
-                               *(long *) ptr = nval.sign ? (long) nval.val : 
-(long) nval.val;
+                               *(int *) ptr = nval.sign ? (int) nval.val : 
-(int) nval.val;
                                break;
                        case SQL_C_SBIGINT:
                                *(SQLBIGINT *) ptr = nval.sign ? (SQLBIGINT) 
nval.val : -(SQLBIGINT) nval.val;
@@ -2086,9 +2086,9 @@ ODBCFetch(ODBCStmt *stmt,
                case SQL_C_ULONG:
                        maxval <<= 32;
                        if (lenp)
-                               *lenp = sizeof(unsigned long);
+                               *lenp = sizeof(unsigned int);
                        if (ardrec && row > 0)
-                               ptr = (SQLPOINTER) ((char *) ptr + row * 
(bind_type == SQL_BIND_BY_COLUMN ? sizeof(unsigned long) : bind_type));
+                               ptr = (SQLPOINTER) ((char *) ptr + row * 
(bind_type == SQL_BIND_BY_COLUMN ? sizeof(unsigned int) : bind_type));
                        break;
                case SQL_C_UBIGINT:
                        if (lenp)
@@ -2145,7 +2145,7 @@ ODBCFetch(ODBCStmt *stmt,
                                *(unsigned short *) ptr = (unsigned short) 
nval.val;
                                break;
                        case SQL_C_ULONG:
-                               *(unsigned long *) ptr = (unsigned long) 
nval.val;
+                               *(unsigned int *) ptr = (unsigned int) nval.val;
                                break;
                        case SQL_C_UBIGINT:
                                *(SQLUBIGINT *) ptr = (SQLUBIGINT) nval.val;
diff --git a/clients/odbc/driver/SQLGetConnectAttr.c 
b/clients/odbc/driver/SQLGetConnectAttr.c
--- a/clients/odbc/driver/SQLGetConnectAttr.c
+++ b/clients/odbc/driver/SQLGetConnectAttr.c
@@ -93,6 +93,9 @@ SQLGetConnectAttr_(ODBCDbc *dbc,
                           BufferLength, StringLengthPtr, SQLINTEGER,
                           addDbcError, dbc, return SQL_ERROR);
                break;
+       case SQL_ATTR_TXN_ISOLATION:
+               *(SQLUINTEGER *) ValuePtr = SQL_TXN_SERIALIZABLE;
+               break;
 
 /* TODO: implement all the other Connection Attributes */
        case SQL_ATTR_DISCONNECT_BEHAVIOR:
@@ -103,7 +106,6 @@ SQLGetConnectAttr_(ODBCDbc *dbc,
        case SQL_ATTR_TRACEFILE:
        case SQL_ATTR_TRANSLATE_LIB:
        case SQL_ATTR_TRANSLATE_OPTION:
-       case SQL_ATTR_TXN_ISOLATION:
                /* Optional feature not implemented */
                addDbcError(dbc, "HYC00", NULL, 0);
                return SQL_ERROR;
diff --git a/clients/odbc/driver/SQLGetInfo.c b/clients/odbc/driver/SQLGetInfo.c
--- a/clients/odbc/driver/SQLGetInfo.c
+++ b/clients/odbc/driver/SQLGetInfo.c
@@ -436,7 +436,7 @@ SQLGetInfo_(ODBCDbc *dbc,
                sValue = "N";
                break;
        case SQL_DEFAULT_TXN_ISOLATION:
-               nValue = SQL_TXN_READ_COMMITTED;
+               nValue = SQL_TXN_SERIALIZABLE;
                len = sizeof(SQLUINTEGER);
                break;
        case SQL_EXPRESSIONS_IN_ORDERBY:
@@ -568,7 +568,7 @@ SQLGetInfo_(ODBCDbc *dbc,
                len = sizeof(SQLUINTEGER);
                break;
        case SQL_TXN_ISOLATION_OPTION:
-               nValue = SQL_TXN_REPEATABLE_READ;
+               nValue = SQL_TXN_SERIALIZABLE;
                len = sizeof(SQLUINTEGER);
                break;
        case SQL_INTEGRITY:
diff --git a/clients/odbc/driver/SQLSetConnectAttr.c 
b/clients/odbc/driver/SQLSetConnectAttr.c
--- a/clients/odbc/driver/SQLSetConnectAttr.c
+++ b/clients/odbc/driver/SQLSetConnectAttr.c
@@ -101,6 +101,9 @@ SQLSetConnectAttr_(ODBCDbc *dbc,
                if (dbc->mid)
                        mapi_timeout(dbc->mid, 
dbc->sql_attr_connection_timeout);
                break;
+       case SQL_ATTR_TXN_ISOLATION:
+               /* nothing to change, we only do the highest level */
+               break;
 
                /* TODO: implement connection attribute behavior */
        case SQL_ATTR_ACCESS_MODE:
@@ -113,7 +116,6 @@ SQLSetConnectAttr_(ODBCDbc *dbc,
        case SQL_ATTR_TRACEFILE:
        case SQL_ATTR_TRANSLATE_LIB:
        case SQL_ATTR_TRANSLATE_OPTION:
-       case SQL_ATTR_TXN_ISOLATION:
                /* Optional feature not implemented */
                addDbcError(dbc, "HYC00", NULL, 0);
                return SQL_ERROR;
diff --git a/clients/odbc/samples/arraytest.c b/clients/odbc/samples/arraytest.c
--- a/clients/odbc/samples/arraytest.c
+++ b/clients/odbc/samples/arraytest.c
@@ -126,7 +126,7 @@ main(int argc, char **argv)
        SQLULEN *processed;
        SQLUSMALLINT *status;
        SQLINTEGER offset;
-       long *data_i;
+       int *data_i;
        char (*data_s)[20];
        SQLLEN *data_slen;
        float *data_f;
@@ -370,7 +370,7 @@ main(int argc, char **argv)
                                data[i].t.hour, data[i].t.minute,
                                data[i].t.second);
                        fprintf(stderr,
-                               "%ld %g %s %04d-%02d-%02d %02d:%02d:%02d\n",
+                               "%d %g %s %04d-%02d-%02d %02d:%02d:%02d\n",
                                data_i[i], data_f[i], data_s[i],
                                data_d[i].year, data_d[i].month, data_d[i].day,
                                data_t[i].hour, data_t[i].minute,
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -336,8 +336,8 @@ static MT_Lock GDKstoppedLock;
 #endif
 #endif
 
-size_t _MT_pagesize = 0;       /* variable holding memory size */
-size_t _MT_npages = 0;         /* variable holding page size */
+size_t _MT_pagesize = 0;       /* variable holding page size */
+size_t _MT_npages = 0;         /* variable holding memory size in pages */
 
 void
 MT_init(void)
@@ -1006,12 +1006,6 @@ GDKinit(opt *set, int setlen)
 
        /* Mserver by default takes 80% of all memory as a default */
        GDK_mem_maxsize = GDK_mem_maxsize_max = (size_t) ((double) MT_npages() 
* (double) MT_pagesize() * 0.815);
-#ifdef NATIVE_WIN32
-       GDK_mmap_minsize = GDK_mem_maxsize_max;
-#else
-       GDK_mmap_minsize = MIN( 1<<30 , GDK_mem_maxsize_max/6 );
-       /*   per op:  2 args + 1 res, each with head & tail  =>  (2+1)*2 = 6  ^ 
*/
-#endif
        GDK_mem_bigsize = 1024*1024;
        GDKremovedir(DELDIR);
        BBPinit();
@@ -1054,6 +1048,10 @@ GDKinit(opt *set, int setlen)
                GDKsetenv(n[i].name, n[i].value);
        free(n);
 
+       GDKnr_threads = GDKgetenv_int("gdk_nr_threads", 0);
+       if (GDKnr_threads == 0)
+               GDKnr_threads = MT_check_nr_cores();
+
        if ((p = GDKgetenv("gdk_dbpath")) != NULL &&
            (p = strrchr(p, DIR_SEP)) != NULL) {
                GDKsetenv("gdk_dbname", p + 1);
@@ -1079,6 +1077,13 @@ GDKinit(opt *set, int setlen)
        }
        if ((p = GDKgetenv("gdk_mmap_minsize"))) {
                GDK_mmap_minsize = MAX(REMAP_PAGE_MAXSIZE, (size_t) strtoll(p, 
NULL, 10));
+       } else {
+#ifdef NATIVE_WIN32
+               GDK_mmap_minsize = GDK_mem_maxsize_max / (GDKnr_threads ? 
GDKnr_threads : 1);
+#else
+               GDK_mmap_minsize = MIN(1 << 30, (GDK_mem_maxsize_max / 6) / 
(GDKnr_threads ? GDKnr_threads : 1));
+               /* per op: 2 args + 1 res, each with head & tail => (2+1)*2 = 6 
*/
+#endif
        }
        if (GDKgetenv("gdk_mem_pagebits") == NULL) {
                snprintf(buf, sizeof(buf), "%d", GDK_mem_pagebits);
@@ -1093,18 +1098,6 @@ GDKinit(opt *set, int setlen)
                GDKsetenv("monet_pid", buf);
        }
 
-       GDKnr_threads = GDKgetenv_int("gdk_nr_threads", 0);
-       if (GDKnr_threads == 0)
-               GDKnr_threads = MT_check_nr_cores();
-#ifdef NATIVE_WIN32
-       GDK_mmap_minsize /= (GDKnr_threads ? GDKnr_threads : 1);
-#else
-       /* WARNING: This unconditionally overwrites above settings, */
-       /* incl. setting via MonetDB env. var. "gdk_mmap_minsize" ! */
-       GDK_mmap_minsize = MIN( 1<<30 , (GDK_mem_maxsize_max/6) / 
(GDKnr_threads ? GDKnr_threads : 1) );
-       /*    per op:  2 args + 1 res, each with head & tail  =>  (2+1)*2 = 6  
^ */
-#endif
-
        if ((p = mo_find_option(set, setlen, "gdk_vmtrim")) == NULL ||
            strcasecmp(p, "yes") == 0)
                MT_create_thread(&GDKvmtrim_id, GDKvmtrim, &GDK_mem_maxsize,
diff --git a/monetdb5/mal/mal_dataflow.c b/monetdb5/mal/mal_dataflow.c
--- a/monetdb5/mal/mal_dataflow.c
+++ b/monetdb5/mal/mal_dataflow.c
@@ -88,6 +88,8 @@ typedef struct DATAFLOW {
 static struct worker {
        MT_Id id;
        enum {IDLE, RUNNING, EXITED} flag;
+       Client cntxt;                           /* client we do work for (NULL 
-> any) */
+       MT_Sema s;
 } workers[THREADS];
 static Queue *todo = 0;        /* pending instructions */
 static int volatile exiting = 0;
@@ -207,16 +209,33 @@ q_requeue(Queue *q, FlowEvent d)
 }
 #endif
 
-static void *
-q_dequeue(Queue *q)
+static FlowEvent
+q_dequeue(Queue *q, Client cntxt)
 {
-       void *r = NULL;
+       FlowEvent r = NULL;
 
        assert(q);
        MT_sema_down(&q->s, "q_dequeue");
        if (exiting)
                return NULL;
        MT_lock_set(&q->l, "q_dequeue");
+       if (cntxt) {
+               int i;
+
+               for (i = q->last - 1; i >= 0; i--) {
+                       if (q->data[i]->flow->cntxt == cntxt) {
+                               r = q->data[i];
+                               q->last--;
+                               while (i < q->last) {
+                                       q->data[i] = q->data[i + 1];
+                                       i++;
+                               }
+                               break;
+                       }
+               }
+               MT_lock_unset(&q->l, "q_dequeue");
+               return r;
+       }
        if (q->exitcount > 0) {
                q->exitcount--;
                MT_lock_unset(&q->l, "q_dequeue");
@@ -228,7 +247,7 @@ q_dequeue(Queue *q)
        assert(q->last > 0);
        if (q->last > 0) {
                /* LIFO favors garbage collection */
-               r = (void*) q->data[--q->last];
+               r = q->data[--q->last];
                q->data[q->last] = 0;
        }
        /* else: terminating */
@@ -281,10 +300,28 @@ DFLOWworker(void *T)
 
        GDKsetbuf(GDKmalloc(GDKMAXERRLEN)); /* where to leave errors */
        GDKerrbuf[0] = 0;
+       if (t->cntxt) {
+               /* wait until we are allowed to start working */
+               MT_sema_down(&t->s, "DFLOWworker");
+       }
        while (1) {
                if (fnxt == 0) {
-                       if ((fe = q_dequeue(todo)) == NULL)
-                               break;;
+                       Client cntxt = t->cntxt;
+                       fe = q_dequeue(todo, cntxt);
+                       if (fe == NULL) {
+                               if (cntxt) {
+                                       /* we're not done yet with work for the 
current
+                                        * client (as far as we know), so give 
up the CPU
+                                        * and let the scheduler enter some 
more work, but
+                                        * first compensate for the down we did 
in
+                                        * dequeue */
+                                       MT_sema_up(&todo->s, "DFLOWworker");
+                                       MT_sleep_ms(1);
+                                       continue;
+                               }
+                               /* no more work to be done: exit */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to