Changeset: a99e407e0d42 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a99e407e0d42
Added Files:
        sql/test/BugTracker-2014/Tests/integer-cast.Bug-3424.sql
        sql/test/BugTracker-2014/Tests/integer-cast.Bug-3424.stable.err
        sql/test/BugTracker-2014/Tests/integer-cast.Bug-3424.stable.out
        sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.SQL.py
        sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.stable.err
        sql/test/BugTracker-2014/Tests/python-microseconds.Bug-3439.stable.out
Modified Files:
        clients/mapiclient/dump.c
        clients/mapiclient/mclient.c
        clients/odbc/driver/ODBCConvert.c
        clients/odbc/driver/ODBCUtil.c
        clients/python2/monetdb/sql/pythonize.py
        clients/python3/monetdb/sql/pythonize.py
        common/utils/mutils.c
        configure.ag
        gdk/gdk_bat.c
        gdk/gdk_bbp.c
        gdk/gdk_calc.c
        gdk/gdk_heap.c
        gdk/gdk_join.c
        gdk/gdk_logger.c
        gdk/gdk_posix.c
        monetdb5/mal/mal_instruction.c
        monetdb5/mal/mal_linker.c
        sql/backends/monet5/sql_gencode.c
        sql/test/ADT2006/bram.sql
        sql/test/BugTracker-2014/Tests/All
Branch: Jan2014
Log Message:

Merger


diffs (truncated from 1439 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
@@ -786,70 +786,69 @@ describe_table(Mapi mid, char *schema, c
        if (view) {
                /* the table is actually a view */
                mnstr_printf(toConsole, "%s\n", view);
-               goto doreturn;
+       } else {
+               /* the table is a real table */
+               mnstr_printf(toConsole, "CREATE TABLE \"%s\".\"%s\" ", schema, 
tname);
+
+               if (dump_column_definition(mid, toConsole, schema, tname, NULL, 
foreign))
+                       goto bailout;
+               mnstr_printf(toConsole, ";\n");
+
+               snprintf(query, maxquerylen,
+                        "SELECT \"i\".\"name\", "              /* 0 */
+                               "\"k\".\"name\", "              /* 1 */
+                               "\"kc\".\"nr\", "               /* 2 */
+                               "\"c\".\"name\" "               /* 3 */
+                        "FROM \"sys\".\"idxs\" AS \"i\" LEFT JOIN 
\"sys\".\"keys\" AS \"k\" "
+                                       "ON \"i\".\"name\" = \"k\".\"name\", "
+                             "\"sys\".\"objects\" AS \"kc\", "
+                             "\"sys\".\"_columns\" AS \"c\", "
+                             "\"sys\".\"schemas\" \"s\", "
+                             "\"sys\".\"_tables\" AS \"t\" "
+                        "WHERE \"i\".\"table_id\" = \"t\".\"id\" AND "
+                              "\"i\".\"id\" = \"kc\".\"id\" AND "
+                              "\"t\".\"id\" = \"c\".\"table_id\" AND "
+                              "\"kc\".\"name\" = \"c\".\"name\" AND "
+                              "(\"k\".\"type\" IS NULL OR \"k\".\"type\" = 1) 
AND "
+                              "\"t\".\"schema_id\" = \"s\".\"id\" AND "
+                              "\"s\".\"name\" = '%s' AND "
+                              "\"t\".\"name\" = '%s' "
+                        "ORDER BY \"i\".\"name\", \"kc\".\"nr\"", schema, 
tname);
+               if ((hdl = mapi_query(mid, query)) == NULL || mapi_error(mid))
+                       goto bailout;
+               cnt = 0;
+               while (mapi_fetch_row(hdl) != 0) {
+                       char *i_name = mapi_fetch_field(hdl, 0);
+                       char *k_name = mapi_fetch_field(hdl, 1);
+                       char *kc_nr = mapi_fetch_field(hdl, 2);
+                       char *c_name = mapi_fetch_field(hdl, 3);
+
+                       if (mapi_error(mid))
+                               goto bailout;
+                       if (k_name != NULL) {
+                               /* unique key, already handled */
+                               continue;
+                       }
+
+                       if (strcmp(kc_nr, "0") == 0) {
+                               if (cnt)
+                                       mnstr_printf(toConsole, ");\n");
+                               mnstr_printf(toConsole,
+                                            "CREATE INDEX \"%s\" ON 
\"%s\".\"%s\" (",
+                                            i_name, schema, tname);
+                               cnt = 1;
+                       } else
+                               mnstr_printf(toConsole, ", ");
+                       mnstr_printf(toConsole, "\"%s\"", c_name);
+                       if (mnstr_errnr(toConsole))
+                               goto bailout;
+               }
+               if (cnt)
+                       mnstr_printf(toConsole, ");\n");
+               if (mapi_error(mid))
+                       goto bailout;
        }
 
-       mnstr_printf(toConsole, "CREATE TABLE \"%s\".\"%s\" ", schema, tname);
-
-       if (dump_column_definition(mid, toConsole, schema, tname, NULL, 
foreign))
-               goto bailout;
-       mnstr_printf(toConsole, ";\n");
-
-       snprintf(query, maxquerylen,
-                "SELECT \"i\".\"name\", "              /* 0 */
-                       "\"k\".\"name\", "              /* 1 */
-                       "\"kc\".\"nr\", "               /* 2 */
-                       "\"c\".\"name\" "               /* 3 */
-                "FROM \"sys\".\"idxs\" AS \"i\" LEFT JOIN \"sys\".\"keys\" AS 
\"k\" "
-                               "ON \"i\".\"name\" = \"k\".\"name\", "
-                     "\"sys\".\"objects\" AS \"kc\", "
-                     "\"sys\".\"_columns\" AS \"c\", "
-                     "\"sys\".\"schemas\" \"s\", "
-                     "\"sys\".\"_tables\" AS \"t\" "
-                "WHERE \"i\".\"table_id\" = \"t\".\"id\" AND "
-                      "\"i\".\"id\" = \"kc\".\"id\" AND "
-                      "\"t\".\"id\" = \"c\".\"table_id\" AND "
-                      "\"kc\".\"name\" = \"c\".\"name\" AND "
-                      "(\"k\".\"type\" IS NULL OR \"k\".\"type\" = 1) AND "
-                      "\"t\".\"schema_id\" = \"s\".\"id\" AND "
-                      "\"s\".\"name\" = '%s' AND "
-                      "\"t\".\"name\" = '%s' "
-                "ORDER BY \"i\".\"name\", \"kc\".\"nr\"", schema, tname);
-       if ((hdl = mapi_query(mid, query)) == NULL || mapi_error(mid))
-               goto bailout;
-       cnt = 0;
-       while (mapi_fetch_row(hdl) != 0) {
-               char *i_name = mapi_fetch_field(hdl, 0);
-               char *k_name = mapi_fetch_field(hdl, 1);
-               char *kc_nr = mapi_fetch_field(hdl, 2);
-               char *c_name = mapi_fetch_field(hdl, 3);
-
-               if (mapi_error(mid))
-                       goto bailout;
-               if (k_name != NULL) {
-                       /* unique key, already handled */
-                       continue;
-               }
-
-               if (strcmp(kc_nr, "0") == 0) {
-                       if (cnt)
-                               mnstr_printf(toConsole, ");\n");
-                       mnstr_printf(toConsole,
-                                    "CREATE INDEX \"%s\" ON \"%s\".\"%s\" (",
-                                    i_name, schema, tname);
-                       cnt = 1;
-               } else
-                       mnstr_printf(toConsole, ", ");
-               mnstr_printf(toConsole, "\"%s\"", c_name);
-               if (mnstr_errnr(toConsole))
-                       goto bailout;
-       }
-       if (cnt)
-               mnstr_printf(toConsole, ");\n");
-       if (mapi_error(mid))
-               goto bailout;
-
-  doreturn:
        if (hdl)
                mapi_close_handle(hdl);
        if (view)
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1636,7 +1636,7 @@ doRequest(Mapi mid, const char *buf)
        return 0;
 }
 
-#define CHECK_RESULT(mid, hdl, buf, break_or_continue,freebuf)                 
\
+#define CHECK_RESULT(mid, hdl, buf, break_or_continue, freebuf)                
\
                switch (mapi_error(mid)) {                              \
                case MOK:                                               \
                        /* everything A OK */                           \
@@ -1671,7 +1671,8 @@ doRequest(Mapi mid, const char *buf)
                                mapi_explain(mid, stderr);              \
                        errseen = 1;                                    \
                        timerEnd();                                     \
-                       if( freebuf) free(freebuf);                             
        \
+                       if (freebuf)                                    \
+                               free(freebuf);                          \
                        return 1;                                       \
                }
 
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
@@ -2822,6 +2822,7 @@ ODBCStore(ODBCStmt *stmt,
        case SQL_C_WCHAR:
                slen = strlen_or_ind_ptr ? *strlen_or_ind_ptr : SQL_NTS;
                fixWcharIn((SQLWCHAR *) ptr, slen, char, sval, addStmtError, 
stmt, return SQL_ERROR);
+               slen = strlen(sval);
                break;
        case SQL_C_BIT:
                nval.precision = 1;
@@ -3054,7 +3055,9 @@ ODBCStore(ODBCStmt *stmt,
                        for (i = 0; i < slen; i++) {
                                unsigned char c = (unsigned char) sval[i];
 
-                               if (c < 0x20 /* || c >= 0x7F */) {
+                               if (c == 0) {
+                                       break;
+                               } else if (c < 0x20 /* || c >= 0x7F */) {
                                        assign(buf, bufpos, buflen, '\\', stmt);
                                        assign(buf, bufpos, buflen, '0' + (c >> 
6), stmt);
                                        assign(buf, bufpos, buflen, '0' + ((c 
>> 3) & 0x7), stmt);
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -124,7 +124,7 @@ ODBCwchar2utf8(const SQLWCHAR *s, SQLLEN
        e = s + length;
        /* count necessary length */
        l = 1;                  /* space for NULL byte */
-       for (s1 = s; s1 < e; s1++) {
+       for (s1 = s; s1 < e && *s1; s1++) {
                c = *s1;
                if (0xD800 <= c && c <= 0xDBFF) {
                        /* high surrogate, must be followed by low surrogate */
@@ -159,7 +159,7 @@ ODBCwchar2utf8(const SQLWCHAR *s, SQLLEN
                        *errmsg = "Memory allocation error";
                return NULL;
        }
-       for (s1 = s, p = buf; s1 < e; s1++) {
+       for (s1 = s, p = buf; s1 < e && *s1; s1++) {
                c = *s1;
                if (0xD800 <= c && c <= 0xDBFF) {
                        /* high surrogate followed by low surrogate */
diff --git a/clients/python2/monetdb/sql/pythonize.py 
b/clients/python2/monetdb/sql/pythonize.py
--- a/clients/python2/monetdb/sql/pythonize.py
+++ b/clients/python2/monetdb/sql/pythonize.py
@@ -27,19 +27,16 @@ from monetdb.exceptions import Programmi
 
 
 def _extract_timezone(data):
-    if data.find('+') != -1:
-        (dt, tz) = data.split("+")
-        (tzhour, tzmin) = [int(x) for x in tz.split(':')]
-    elif data.find('-') != -1:
-        (dt, tz) = data.split("-")
-        (tzhour, tzmin) = [int(x) for x in tz.split(':')]
-        tzhour *= -1
-        tzmin *= -1
+    sign_symbol = data[-6]
+
+    if sign_symbol == '+':
+        sign = 1
+    elif sign_symbol == '-':
+        sign = -1
     else:
         raise ProgrammingError("no + or - in %s" % data)
 
-    return dt, tzhour, tzmin
-
+    return data[:-6], datetime.timedelta(hours=sign * int(data[-5:-3]), 
minutes=sign * int(data[-2:]))
 
 def strip(data):
     """ returns a python string, with chopped off quotes,
@@ -55,42 +52,33 @@ def py_bool(data):
 def py_time(data):
     """ returns a python Time
     """
-    return Time(*[int(float(x)) for x in data.split(':')])
+    return datetime.datetime.strptime(data, '%H:%M:%S').time()
 
 
 def py_timetz(data):
     """ returns a python Time where data contains a tz code
     """
-    dt, tzhour, tzmin = _extract_timezone(data)
-    hour, minute, second = [int(float(x)) for x in dt.split(':')]
-    return Time(hour + tzhour, minute + tzmin, second)
+    t, timezone_delta = _extract_timezone(data)
+    return (datetime.datetime.strptime(t, '%H:%M:%S') + timezone_delta).time()
 
 
 def py_date(data):
     """ Returns a python Date
     """
-    return Date(*[int(float(x)) for x in data.split('-')])
+    return datetime.datetime.strptime(data, '%Y-%m-%d').date()
 
 
 def py_timestamp(data):
     """ Returns a python Timestamp
     """
-    splitted = data.split(" ")
-    date = [int(float(x)) for x in splitted[0].split('-')]
-    time = [int(float(x)) for x in splitted[1].split(':')]
-    return Timestamp(*(date + time))
+    return datetime.datetime.strptime(data, '%Y-%m-%d %H:%M:%S.%f')
 
 
 def py_timestamptz(data):
     """ Returns a python Timestamp where data contains a tz code
     """
-    dt, tzhour, tzmin = _extract_timezone(data)
-    (datestr, timestr) = dt.split(" ")
-    date = [int(float(x)) for x in datestr.split('-')]
-    time = [int(float(x)) for x in timestr.split(':')]
-    year, month, day = date
-    hour, minute, second = time
-    return Timestamp(year, month, day, hour + tzhour, minute + tzmin, second)
+    dt, timezone_delta = _extract_timezone(data)
+    return datetime.datetime.strptime(dt, '%Y-%m-%d %H:%M:%S.%f') + 
timezone_delta
 
 
 mapping = {
diff --git a/clients/python3/monetdb/sql/pythonize.py 
b/clients/python3/monetdb/sql/pythonize.py
--- a/clients/python3/monetdb/sql/pythonize.py
+++ b/clients/python3/monetdb/sql/pythonize.py
@@ -28,19 +28,16 @@ from monetdb.exceptions import Programmi
 
 
 def _extract_timezone(data):
-    if data.find('+') != -1:
-        (dt, tz) = data.split("+")
-        (tzhour, tzmin) = [int(x) for x in tz.split(':')]
-    elif data.find('-') != -1:
-        (dt, tz) = data.split("-")
-        (tzhour, tzmin) = [int(x) for x in tz.split(':')]
-        tzhour *= -1
-        tzmin *= -1
+    sign_symbol = data[-6]
+
+    if sign_symbol == '+':
+        sign = 1
+    elif sign_symbol == '-':
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to