Changeset: 87df35b61add for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=87df35b61add
Modified Files:
        clients/odbc/driver/ODBCConvert.c
        clients/odbc/driver/SQLExecute.c
Branch: Aug2011
Log Message:

Accept and ignore time zones.
The server has two types that can contain a time zone: TIME and
TIMESTAMP.  ODBC doesn't do timestamps, so we map these types to the
types without time zone.  But we do have to ignore the time zone
information when parsing the time/timestamp value.


diffs (54 lines):

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
@@ -302,6 +302,18 @@ parsetime(const char *data, TIME_STRUCT 
                        ;
                n = 2;          /* indicate loss of precision */
        }
+       if (*data == '+' || *data == '-') {
+               /* time zone (which we ignore) */
+               short tzhour, tzmin;
+               int i;
+
+               if (sscanf(data, "%hd:%hd%n", &tzhour, &tzmin, &i) < 2)
+                       return 0;
+               data += i;
+               tzmin = tzhour < 0 ? tzhour * 60 - tzmin : tzhour * 60 + tzmin;
+               (void) tzhour;
+               (void) tzmin;
+       }
        if (braces && *data++ != '\'' && *data++ != '}')
                return 0;
        while (space(*data))
@@ -341,6 +353,18 @@ parsetimestamp(const char *data, TIMESTA
                        tsval->fraction += (*data - '0') * n;
                }
        }
+       if (*data == '+' || *data == '-') {
+               /* time zone (which we ignore) */
+               short tzhour, tzmin;
+               int i;
+
+               if (sscanf(data, "%hd:%hd%n", &tzhour, &tzmin, &i) < 2)
+                       return 0;
+               data += i;
+               tzmin = tzhour < 0 ? tzhour * 60 - tzmin : tzhour * 60 + tzmin;
+               (void) tzhour;
+               (void) tzmin;
+       }
        if (braces && *data++ != '\'' && *data++ != '}')
                return 0;
        while (space(*data))
diff --git a/clients/odbc/driver/SQLExecute.c b/clients/odbc/driver/SQLExecute.c
--- a/clients/odbc/driver/SQLExecute.c
+++ b/clients/odbc/driver/SQLExecute.c
@@ -60,7 +60,9 @@ static struct msql_types {
        {"smallint", SQL_SMALLINT},
        {"table", 0},
        {"time", SQL_TYPE_TIME},
+       {"timetz", SQL_TYPE_TIME},
        {"timestamp", SQL_TYPE_TIMESTAMP},
+       {"timestamptz", SQL_TYPE_TIMESTAMP},
        {"tinyint", SQL_TINYINT},
 /*     {"ubyte", SQL_TINYINT}, */
        {"varchar", SQL_VARCHAR},
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to