Changeset: 70f483dc6d85 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=70f483dc6d85
Modified Files:
        clients/mapiclient/dump.c
        clients/mapilib/mapi.c
        clients/odbc/driver/ODBCConvert.c
        common/stream/stream.c
        common/utils/msabaoth.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_heap.c
        gdk/gdk_logger.c
        gdk/gdk_posix.c
        gdk/gdk_storage.c
        gdk/gdk_utils.c
        geom/monetdb5/geom.c
        monetdb5/extras/jaql/Tests/json03.mal
        monetdb5/extras/jaql/Tests/json03.stable.out
        monetdb5/extras/jaql/jaqlgencode.c
        monetdb5/extras/jaql/json.c
        monetdb5/extras/jaql/json.h
        monetdb5/extras/jaql/json.mal
        monetdb5/mal/mal_dataflow.c
        monetdb5/modules/atoms/str.c
        sql/server/sql_scan.c
        tools/merovingian/utils/control.c
Branch: default
Log Message:

Merge with Oct2012 branch.


diffs (truncated from 840 to 300 lines):

diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -344,9 +344,6 @@ dump_foreign_keys(Mapi mid, const char *
        } else if (mapi_error(mid))
                mapi_explain(mid, stderr);
 
-       if (query != NULL && maxquerylen != 0)
-               free(query);
-
        return 1;
 }
 
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -2284,7 +2284,6 @@ connect_to_server(Mapi mid)
                userver.sun_family = AF_UNIX;
                strncpy(userver.sun_path, mid->hostname, 
sizeof(userver.sun_path) - 1);
                userver.sun_path[sizeof(userver.sun_path) - 1] = 0;
-               s = socket(PF_UNIX, SOCK_STREAM, 0);
 
                if (connect(s, serv, sizeof(struct sockaddr_un)) < 0) {
                        closesocket(s);
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
@@ -2802,7 +2802,6 @@ ODBCStore(ODBCStmt *stmt,
 #ifdef WITH_WCHAR
        case SQL_C_WCHAR:
                slen = strlen_or_ind_ptr ? *strlen_or_ind_ptr : SQL_NTS;
-               sval = (char *) ptr;
                fixWcharIn((SQLWCHAR *) ptr, slen, char, sval, addStmtError, 
stmt, return SQL_ERROR);
                break;
 #endif
@@ -3212,7 +3211,7 @@ ODBCStore(ODBCStmt *stmt,
                default:
                        /* Restricted data type attribute violation */
                        addStmtError(stmt, "07006", NULL, 0);
-                       return SQL_ERROR;
+                       goto failure;
                }
                break;
        case SQL_TYPE_DATE:
@@ -3238,7 +3237,7 @@ ODBCStore(ODBCStmt *stmt,
                                /* Invalid character value for cast
                                 * specification */
                                addStmtError(stmt, "22018", NULL, 0);
-                               return SQL_ERROR;
+                               goto failure;
                        }
                        /* fall through */
                case SQL_C_TYPE_DATE:
@@ -3251,7 +3250,7 @@ ODBCStore(ODBCStmt *stmt,
                default:
                        /* Restricted data type attribute violation */
                        addStmtError(stmt, "07006", NULL, 0);
-                       return SQL_ERROR;
+                       goto failure;
                }
                break;
        case SQL_TYPE_TIME:
@@ -3277,7 +3276,7 @@ ODBCStore(ODBCStmt *stmt,
                                /* Invalid character value for cast
                                 * specification */
                                addStmtError(stmt, "22018", NULL, 0);
-                               return SQL_ERROR;
+                               goto failure;
                        }
                        /* fall through */
                case SQL_C_TYPE_TIME:
@@ -3290,7 +3289,7 @@ ODBCStore(ODBCStmt *stmt,
                default:
                        /* Restricted data type attribute violation */
                        addStmtError(stmt, "07006", NULL, 0);
-                       return SQL_ERROR;
+                       goto failure;
                }
                break;
        case SQL_TYPE_TIMESTAMP:
@@ -3337,7 +3336,7 @@ ODBCStore(ODBCStmt *stmt,
                                                 * value for cast
                                                 * specification */
                                                addStmtError(stmt, "22018", 
NULL, 0);
-                                               return SQL_ERROR;
+                                               goto failure;
                                        }
                                }
                        }
@@ -3361,7 +3360,7 @@ ODBCStore(ODBCStmt *stmt,
                default:
                        /* Restricted data type attribute violation */
                        addStmtError(stmt, "07006", NULL, 0);
-                       return SQL_ERROR;
+                       goto failure;
                }
                break;
        case SQL_INTERVAL_MONTH:
@@ -3377,7 +3376,7 @@ ODBCStore(ODBCStmt *stmt,
                                /* Invalid character value for cast
                                 * specification */
                                addStmtError(stmt, "22018", NULL, 0);
-                               return SQL_ERROR;
+                               goto failure;
                        }
                        break;
                case SQL_C_BIT:
@@ -3402,7 +3401,7 @@ ODBCStore(ODBCStmt *stmt,
                default:
                        /* Restricted data type attribute violation */
                        addStmtError(stmt, "07006", NULL, 0);
-                       return SQL_ERROR;
+                       goto failure;
                }
                switch (ival.interval_type) {
                case SQL_IS_YEAR:
@@ -3439,7 +3438,7 @@ ODBCStore(ODBCStmt *stmt,
                                /* Invalid character value for cast
                                 * specification */
                                addStmtError(stmt, "22018", NULL, 0);
-                               return SQL_ERROR;
+                               goto failure;
                        }
                        break;
                case SQL_C_BIT:
@@ -3471,7 +3470,7 @@ ODBCStore(ODBCStmt *stmt,
                default:
                        /* Restricted data type attribute violation */
                        addStmtError(stmt, "07006", NULL, 0);
-                       return SQL_ERROR;
+                       goto failure;
                }
                snprintf(data, sizeof(data), "INTERVAL %s'%u %u:%u:%u", 
ival.interval_sign ? "" : "- ", (unsigned int) ival.intval.day_second.day, 
(unsigned int) ival.intval.day_second.hour, (unsigned int) 
ival.intval.day_second.minute, (unsigned int) ival.intval.day_second.second);
                assigns(buf, bufpos, buflen, data, stmt);
@@ -3504,7 +3503,7 @@ ODBCStore(ODBCStmt *stmt,
                                /* Invalid character value for cast
                                 * specification */
                                addStmtError(stmt, "22018", NULL, 0);
-                               return SQL_ERROR;
+                               goto failure;
                        }
                        /* fall through */
                case SQL_C_BIT:
@@ -3567,7 +3566,7 @@ ODBCStore(ODBCStmt *stmt,
                default:
                        /* Restricted data type attribute violation */
                        addStmtError(stmt, "07006", NULL, 0);
-                       return SQL_ERROR;
+                       goto failure;
                }
                /* now store value contained in nval */
                {
@@ -3586,7 +3585,7 @@ ODBCStore(ODBCStmt *stmt,
                                default:
                                        /* Numeric value out of range */
                                        addStmtError(stmt, "22003", NULL, 0);
-                                       return SQL_ERROR;
+                                       goto failure;
                                }
                                if (f > 1 && nval.val % f) {
                                        /* String data, right truncation */
@@ -3621,7 +3620,7 @@ ODBCStore(ODBCStmt *stmt,
                        if (!parsedouble(sval, &fval)) {
                                /* Invalid character value for cast 
specification */
                                addStmtError(stmt, "22018", NULL, 0);
-                               return SQL_ERROR;
+                               goto failure;
                        }
                        break;
                case SQL_C_BIT:
@@ -3696,7 +3695,7 @@ ODBCStore(ODBCStmt *stmt,
                default:
                        /* Restricted data type attribute violation */
                        addStmtError(stmt, "07006", NULL, 0);
-                       return SQL_ERROR;
+                       goto failure;
                }
                for (i = 1; i < 18; i++) {
                        snprintf(data, sizeof(data), "%.*e", i, fval);
@@ -3706,8 +3705,19 @@ ODBCStore(ODBCStmt *stmt,
                assigns(buf, bufpos, buflen, data, stmt);
                break;
        }
+#ifdef WITH_WCHAR
+       if (ctype == SQL_C_WCHAR)
+               free(sval);
+#endif
        *bufp = buf;
        *bufposp = bufpos;
        *buflenp = buflen;
        return SQL_SUCCESS;
+
+  failure:
+#ifdef WITH_WCHAR
+       if (ctype == SQL_C_WCHAR)
+               free(sval);
+#endif
+       return SQL_ERROR;
 }
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -1202,8 +1202,10 @@ write_callback(char *buffer, size_t size
        struct curl_data *c = (struct curl_data *) s->stream_data.p;
 
        size *= nitems;
+       if (size == 0)          /* unlikely */
+               return 0;
        /* allocate a buffer if we don't have one yet */
-       if (c->buffer == NULL && size != 0) {
+       if (c->buffer == NULL) {
                /* BLOCK_CURL had better be a power of 2! */
                c->maxsize = (size + BLOCK_CURL - 1) & ~(BLOCK_CURL - 1);
                if ((c->buffer = malloc(c->maxsize)) == NULL)
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -873,7 +873,7 @@ msab_serialise(char **ret, const sabdb *
        avail = sizeof(conns) - 1;
        for (l = db->conns; l != NULL; l = l->next) {
                len = strlen(l->val);
-               if (len > avail)
+               if (len >= avail)
                        break;
                memcpy(p, l->val, len);
                p += len + 1;
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -365,7 +365,11 @@ BATattach(int tt, const char *heapfile)
        bn->batRestricted = BAT_READ;
        bn->T->heap.size = (size_t) st.st_size;
        bn->T->heap.newstorage = bn->T->heap.storage = (bn->T->heap.size < 
REMAP_PAGE_MAXSIZE) ? STORE_MEM : STORE_MMAP;
-       HEAPload(&bn->T->heap, BBP_physical(bn->batCacheid), "tail", TRUE);
+       if (HEAPload(&bn->T->heap, BBP_physical(bn->batCacheid), "tail", TRUE) 
< 0) {
+               HEAPfree(&bn->T->heap);
+               GDKfree(bs);
+               return NULL;
+       }
        BBPcacheit(bs, 1);
        return bn;
 }
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1367,8 +1367,7 @@ BATsubsort(BAT **sorted, BAT **order, BA
                                *order = on;
                        if (groups) {
                                BBPfix(g->batCacheid);
-                               gn = g;
-                               *groups = bn;
+                               *groups = g;
                        }
                        return GDK_SUCCEED;
                }
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -165,21 +165,25 @@ HEAPcacheFind(size_t *maxsz, char *fn, s
 
                                if ((fp = fopen(fn, "rb+")) != NULL &&
 #ifdef _WIN64
-                                  _fseeki64(fp, (ssize_t) *maxsz-1, SEEK_SET) 
>= 0 &&
+                                   _fseeki64(fp, (ssize_t) *maxsz-1, SEEK_SET) 
>= 0 &&
 #else
 #ifdef HAVE_FSEEKO
-                                  fseeko(fp, (off_t) *maxsz-1, SEEK_SET) >= 0 
&&
+                                   fseeko(fp, (off_t) *maxsz-1, SEEK_SET) >= 0 
&&
 #else
-                                  fseek(fp, (long) *maxsz-1, SEEK_SET) >= 0 &&
+                                   fseek(fp, (long) *maxsz-1, SEEK_SET) >= 0 &&
 #endif
 #endif
-                                  fputc('\n', fp) >= 0 &&
-                                  fflush(fp) >= 0 &&
-                                  fclose(fp) >= 0) {
-                                       void *base = GDKload(fn, NULL, *maxsz, 
*maxsz, STORE_MMAP);
-                                       GDKmunmap(e->base, e->maxsz);
-                                       e->base = base;
-                                       e->maxsz = *maxsz;
+                                   fputc('\n', fp) >= 0 &&
+                                   fflush(fp) >= 0) {
+                                       if (fclose(fp) >= 0) {
+                                               void *base = GDKload(fn, NULL, 
*maxsz, *maxsz, STORE_MMAP);
+                                               GDKmunmap(e->base, e->maxsz);
+                                               e->base = base;
+                                               e->maxsz = *maxsz;
+                                       }
+                                       /* after fclose, successful or
+                                        * not, we can't call fclose
+                                        * again */
                                        fp = NULL;
                                }
                                if (fp) {
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -766,7 +766,11 @@ logger_readlog(logger *lg, char *filenam
                lg->log = NULL;
                return 0;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to