Changeset: 4bae6a90fe53 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4bae6a90fe53
Modified Files:
        clients/mapilib/mapi.c
        clients/odbc/driver/ODBCConvert.c
        common/stream/stream.c
        common/stream/stream.h
        monetdb5/modules/mal/mal_mapi.c
        sql/backends/monet5/sql_result.c
Branch: protocol
Log Message:

Fix ODBC connection for protocol 10 (inefficiently, todo: more efficiently) and 
add several compilation fixes.


diffs (189 lines):

diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -4048,7 +4048,7 @@ static char* mapi_convert_tinyint(struct
 }
 
 static char* mapi_convert_double(struct MapiColumn *col) {
-       char *dummy = NULL;
+       char *dummy;
        if (*((double*) col->buffer_ptr) == *((double*)col->null_value)) return 
NULL;
        //sprintf(col->write_buf, "%g", *((double*) col->buffer_ptr));
        dummy = gcvt(*((double*) col->buffer_ptr), 2, col->write_buf);
@@ -4202,7 +4202,7 @@ read_into_cache(MapiHdl hdl, int lookahe
                        }
                //      fprintf(stderr, "result_set_id=%d, nr_rows=%llu, 
nr_cols=%lld\n", result_set_id, nr_rows, nr_cols);
                        result->fieldcnt = nr_cols;
-                       result->maxfields = nr_cols;
+                       result->maxfields = (int) nr_cols;
                        result->row_count = nr_rows;
                        result->fields = malloc(sizeof(struct MapiColumn) * 
result->fieldcnt);
                        result->tableid = result_set_id;
@@ -4220,10 +4220,11 @@ read_into_cache(MapiHdl hdl, int lookahe
                                if (!mnstr_readLng(mid->from, 
&col_info_length)) {
                                        return mid->error;
                                }
+                               assert(col_info_length > 0);
                                // possible improvement, set col_info_length to 
max length of the three strings
-                               table_name = malloc(col_info_length);
-                               col_name = malloc(col_info_length);
-                               type_sql_name = malloc(col_info_length);
+                               table_name = malloc((size_t) col_info_length);
+                               col_name = malloc((size_t) col_info_length);
+                               type_sql_name = malloc((size_t) 
col_info_length);
                                if (!table_name || !col_name || !type_sql_name) 
{
                                        return mid->error;
                                }
@@ -5704,6 +5705,10 @@ mapi_fetch_field_len(MapiHdl hdl, int fn
 {
        int cr;
        struct MapiResultSet *result;
+       if (hdl->mid->protocol == prot10 || hdl->mid->protocol == 
prot10compressed) {
+               // this really should not be called for the new protocol
+               return strlen(mapi_fetch_field(hdl, fnr));
+       }
        mapi_hdl_check0(hdl, "mapi_fetch_field_len");
 
        if ((result = hdl->result) == NULL ||
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
@@ -1088,7 +1088,6 @@ ODBCFetch(ODBCStmt *stmt,
 
        /* see SQLExecute.c for possible types */
        switch (sql_type) {
-       case SQL_DECIMAL:
        case SQL_TINYINT:
        case SQL_SMALLINT:
        case SQL_INTEGER:
@@ -1139,6 +1138,7 @@ ODBCFetch(ODBCStmt *stmt,
                        break;
                }
                break;
+       case SQL_DECIMAL:
        case SQL_DOUBLE:
        case SQL_REAL:
                if (!parsedouble(data, &fval)) {
@@ -1338,7 +1338,6 @@ ODBCFetch(ODBCStmt *stmt,
                                *lenp = j;
                        break;
                }
-               case SQL_DECIMAL:
                case SQL_TINYINT:
                case SQL_SMALLINT:
                case SQL_INTEGER:
@@ -1377,6 +1376,7 @@ ODBCFetch(ODBCStmt *stmt,
                        }
                        break;
                }
+               case SQL_DECIMAL:
                case SQL_DOUBLE:
                case SQL_REAL: {
                        data = (char *) ptr;
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -3984,8 +3984,7 @@ typedef struct bs2 {
        compression_method comp;
        char *compbuf;
        size_t compbufsiz;
-       char buf[0];    /* the buffered data (minus the size of
-                                * size-short */
+       char buf[1];    /* the buffered data */
 } bs2;
 
 
diff --git a/common/stream/stream.h b/common/stream/stream.h
--- a/common/stream/stream.h
+++ b/common/stream/stream.h
@@ -239,13 +239,14 @@ typedef enum {
        protauto = 0,
        prot9 = 1,
        prot10 = 2,
-       prot10compressed = 3,
+       prot10compressed = 3
 } protocol_version;
 
 typedef enum {
        COMPRESSION_NONE = 0,
        COMPRESSION_SNAPPY = 1,
-       COMPRESSION_LZ4 = 2
+       COMPRESSION_LZ4 = 2,
+       COMPRESSION_UNKNOWN = 255
 } compression_method;
 
 stream_export stream *block_stream2(stream *s, size_t bufsiz, 
compression_method comp);
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -201,28 +201,36 @@ doChallenge(void *data)
                        fdin = block_stream2(bs_stream(fdin), buflen, 
COMPRESSION_NONE);
                        fdout = block_stream2(bs_stream(fdout), buflen, 
COMPRESSION_NONE);
                } else {
-                       compression_method comp;
+                       compression_method comp = COMPRESSION_NONE;
                        if (strstr(buf, "SNAPPY")) {
+#ifdef HAVE_LIBSNAPPY
                                comp = COMPRESSION_SNAPPY;
+#else
+                               comp = COMPRESSION_UNKNOWN;
+#endif
+
                        } else if (strstr(buf, "LZ4")) {
+#ifdef HAVE_LIBLZ4
                                comp = COMPRESSION_LZ4;
+#else
+                               comp = COMPRESSION_UNKNOWN;
+#endif
                        } else {
                                fprintf(stderr, "Unrecognized compression 
type!\n");
-                               comp = COMPRESSION_SNAPPY;
+                               comp = COMPRESSION_UNKNOWN;
                        }
-#ifdef HAVE_LIBSNAPPY
+                       if (comp == COMPRESSION_UNKNOWN) {
+                               // client requested compressed protocol, but 
server does not support it
+                               mnstr_printf(fdout, "!server does not support 
compressed protocol\n");
+                               close_stream(fdin);
+                               close_stream(fdout);
+                               return;
+                       }
                        // client requests switch to protocol 10
                        protocol = prot10compressed;
                        // compressed protocol 10
                        fdin = block_stream2(bs_stream(fdin), buflen, comp);
                        fdout = block_stream2(bs_stream(fdout), buflen, comp);
-#else
-                       // client requested compressed protocol, but server 
does not support it
-                       mnstr_printf(fdout, "!server does not support 
compressed protocol\n");
-                       close_stream(fdin);
-                       close_stream(fdout);
-                       return;
-#endif
                }
 
                if (fdin == NULL || fdout == NULL) {
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -2014,7 +2014,11 @@ static int mvc_export_resultset_prot10(r
        while (row < (size_t) count)    {
                size_t crow = 0;
                size_t bytes_left = bsize - sizeof(lng) - 1;
+#ifdef CONTINUATION_MESSAGE
                char cont_req, dummy;
+#else
+               (void) c;
+#endif
 #ifdef PROT10_DEBUG
                size_t bufpos;
 #endif
@@ -2149,7 +2153,7 @@ cleanup:
        if (var_col_len) 
                GDKfree(var_col_len);
        if (iterators) {
-               for(i = 0; i < t->nr_cols; i++) {
+               for(i = 0; i < (size_t) t->nr_cols; i++) {
                        if (iterators[i].b) {
                                BBPunfix(iterators[i].b->batCacheid);
                        }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to