Changeset: 708c5dc29096 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=708c5dc29096
Modified Files:
        gdk/gdk_atoms.mx
        sql/backends/monet5/sql_result.mx
        sql/server/sql_parser.y
        testing/Mtest.py.in
Branch: Dec2011
Log Message:

Merge with Aug2011 branch.


diffs (truncated from 986 to 300 lines):

diff --git a/clients/Tests/exports.timeout b/clients/Tests/exports.timeout
--- a/clients/Tests/exports.timeout
+++ b/clients/Tests/exports.timeout
@@ -1,1 +1,1 @@
-7
+8
diff --git a/clients/odbc/driver/SQLTables.c b/clients/odbc/driver/SQLTables.c
--- a/clients/odbc/driver/SQLTables.c
+++ b/clients/odbc/driver/SQLTables.c
@@ -189,7 +189,7 @@ SQLTables_(ODBCStmt *stmt,
                        char buf[17];   /* the longest string is "GLOBAL 
TEMPORARY" */
                        int i, j;
 
-                       strcpy(query_end, " and (1 = 0");
+                       strcpy(query_end, " and (");
                        query_end += strlen(query_end);
                        for (i = j = 0; i < NameLength4 + 1; i++) {
                                if (i == NameLength4 || TableType[i] == ',') {
@@ -199,20 +199,28 @@ SQLTables_(ODBCStmt *stmt,
                                        }
                                        buf[j] = 0;
                                        if (strcmp(buf, "VIEW") == 0)
-                                               strcpy(query_end, " or 
t.\"type\" = 1");
+                                               strcpy(query_end, "t.\"type\" = 
1 or ");
                                        else if (strcmp(buf, "TABLE") == 0)
-                                               strcpy(query_end, " or 
(t.\"type\" = 0 and t.\"system\" = false and t.\"temporary\" = 0)");
+                                               strcpy(query_end, "(t.\"type\" 
= 0 and t.\"system\" = false and t.\"temporary\" = 0) or ");
                                        else if (strcmp(buf, "SYSTEM TABLE") == 
0)
-                                               strcpy(query_end, " or 
(t.\"type\" = 0 and t.\"system\" = true and t.\"temporary\" = 0)");
+                                               strcpy(query_end, "(t.\"type\" 
= 0 and t.\"system\" = true and t.\"temporary\" = 0) or ");
                                        else if (strcmp(buf, "LOCAL TEMPORARY") 
== 0)
-                                               strcpy(query_end, " or 
(t.\"type\" = 0 and t.\"system\" = false and t.\"temporary\" = 1)");
+                                               strcpy(query_end, "(t.\"type\" 
= 0 and t.\"system\" = false and t.\"temporary\" = 1) or ");
                                        query_end += strlen(query_end);
                                        j = 0;
                                } else if (j < 17 && TableType[i] != '\'' && (j 
> 0 || TableType[i] != ' '))
                                        buf[j++] = TableType[i];
                        }
-                       strcpy(query_end, ")");
-                       query_end += strlen(query_end);
+                       if (query_end[-1] == '(') {
+                               /* no extra tests added, so remove " and (" */
+                               query_end -= 6;
+                               *query_end = 0;
+                       } else {
+                               /* remove extra " or " at end */
+                               query_end -= 4;
+                               *query_end++ = ')';
+                               *query_end = 0;
+                       }
                }
 
                /* add the ordering */
diff --git a/gdk/gdk_atoms.mx b/gdk/gdk_atoms.mx
--- a/gdk/gdk_atoms.mx
+++ b/gdk/gdk_atoms.mx
@@ -1577,13 +1577,15 @@ dblFromStr(char *src, int *len, dbl **ds
                **dst = dbl_nil;
                p += 3;
        } else {
-               /* on overflow, strtod returns HUGE_VAL and sets errno to
-                  ERANGE; on underflow, it returns 0 and also sets errno to
-                  ERANGE.  We accept 0, but not HUGE_VAL. */
+               /* on overflow, strtod returns HUGE_VAL and sets
+                * errno to ERANGE; on underflow, it returns a value
+                * whose magnitude is no greater than the smallest
+                * normalized double, and may or may not set errno to
+                * ERANGE.  We accept underflow, but not overflow. */
                errno = 0;
                d = strtod(src, &p);
-               if (p == src || (errno == ERANGE && d != 0)) {
-                       **dst = dbl_nil;        /* default return value is nil 
*/
+               if (p == src || (errno == ERANGE && (d < -1 || d > 1))) {
+                       **dst = dbl_nil; /* default return value is nil */
                        p = src;
                } else
                        **dst = (dbl) d;
@@ -1611,13 +1613,15 @@ fltFromStr(char *src, int *len, flt **ds
                p += 3;
        } else {
 #ifdef HAVE_STRTOF
-               /* on overflow, strtof returns HUGE_VALF and sets errno to
-                  ERANGE; on underflow, it returns 0 and also sets errno to
-                  ERANGE.  We accept 0, but not HUGE_VALF. */
+               /* on overflow, strtof returns HUGE_VALF and sets
+                * errno to ERANGE; on underflow, it returns a value
+                * whose magnitude is no greater than the smallest
+                * normalized float, and may or may not set errno to
+                * ERANGE.  We accept underflow, but not overflow. */
                errno = 0;
                f = strtof(src, &p);
                n = (int) (p - src);
-               if (n == 0 || (errno == ERANGE && f != 0)
+               if (n == 0 || (errno == ERANGE && (f < -1 || f > 1))
 #ifdef INFINITY
                    || f == INFINITY
 #endif
@@ -1640,7 +1644,7 @@ fltFromStr(char *src, int *len, flt **ds
                    )
 #endif
                {
-                       **dst = flt_nil;        /* default return value is nil 
*/
+                       **dst = flt_nil; /* default return value is nil */
                        n = 0;
                } else
                        **dst = (flt) f;
diff --git a/sql/backends/monet5/sql_result.mx 
b/sql/backends/monet5/sql_result.mx
--- a/sql/backends/monet5/sql_result.mx
+++ b/sql/backends/monet5/sql_result.mx
@@ -673,18 +673,45 @@ mvc_export_prepare(mvc *c, stream *out, 
 {
        node *n;
        int len = c->params ? list_length(c->params) : 0;
+       size_t len1 = 0;        /* column widths */
+       int len2 = 1, len3 = 1;
+       sql_arg *a;
+       sql_subtype *t;
 
        if (!out)
                return 0;
 
+       /* calculate column widths */
+       if (c->params) {
+               unsigned int max2 = 10, max3 = 10; /* to help calculate widths 
*/
+
+               for (n = c->params->h; n; n = n->next) {
+                       size_t slen;
+
+                       a = n->data;
+                       t = &a->type;
+                       slen = strlen(t->type->sqlname);
+                       if (slen > len1)
+                               len1 = slen;
+                       while (t->digits >= max2) {
+                               len2++;
+                               max2 *= 10;
+                       }
+                       while (t->scale >= max3) {
+                               len3++;
+                               max3 *= 10;
+                       }
+               }
+       }
+
        /* write header, query type: Q_PREPARE */
        if (mnstr_printf(out,
                "&5 %d %d 3 %d\n" /* TODO: add type here: r(esult) or u(pdate) 
*/
-               "%% .prepare,   .prepare,       .prepare # table_name\n"
-               "%% type,       digits, scale # name\n"
-               "%% varchar,    int,    int # type\n"
-               "%% 0,  0,      0 # length\n",
-               q->id, len, len) < 0) {
+               "%% .prepare,\t.prepare,\t.prepare # table_name\n"
+               "%% type,\tdigits,\tscale # name\n"
+               "%% varchar,\tint,\tint # type\n"
+               "%% " SZFMT ",\t%d,\t%d # length\n",
+               q->id, len, len, len1, len2, len3) < 0) {
                return -1;
        }
 
@@ -694,12 +721,12 @@ mvc_export_prepare(mvc *c, stream *out, 
                q->paramlen = len;
                q->params = SA_NEW_ARRAY(q->sa, sql_subtype, len);
                for (n = c->params->h, i=0; n; n = n->next, i++) {
-                       sql_arg *a = n->data;
-                       sql_subtype *t = &a->type;
+                       a = n->data;
+                       t = &a->type;
 
                        if (t) {
                                if (mnstr_printf(out,
-                                       "[ \"%s\",      %d,     %d      ]\n",
+                                       "[ \"%s\",\t%d,\t%d\t]\n",
                                        t->type->sqlname,
                                        t->digits,
                                        t->scale
diff --git a/sql/jdbc/tests/Tests/Test_PSlargeamount.timeout 
b/sql/jdbc/tests/Tests/Test_PSlargeamount.timeout
--- a/sql/jdbc/tests/Tests/Test_PSlargeamount.timeout
+++ b/sql/jdbc/tests/Tests/Test_PSlargeamount.timeout
@@ -1,1 +1,1 @@
-16.65
+16.8
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -3989,12 +3989,23 @@ literal:
                        if (*s == '+' || *s == '-')
                                digits --;
                        sql_find_subtype(&t, "decimal", digits, scale );
-                       $$ = _newAtomNode( atom_dec(SA, &t, value, val)); 
-                  } else { 
-                       double val = strtod($1,NULL);
-
+                       $$ = _newAtomNode( atom_dec(SA, &t, value, val));
+                  } else {
+                       char *p = $1;
+                       double val;
+
+                       errno = 0;
+                       val = strtod($1,&p);
+                       if (p == $1 || (errno == ERANGE && (val < -1 || val > 
1))) {
+                               char *msg = sql_message("Double value too large 
or not a number (%s)", $1);
+
+                               yyerror(msg);
+                               _DELETE(msg);
+                               $$ = NULL;
+                               YYABORT;
+                       }
                        sql_find_subtype(&t, "double", 51, 0 );
-                       $$ = _newAtomNode(atom_float(SA, &t, val)); 
+                       $$ = _newAtomNode(atom_float(SA, &t, val));
                   }
                }
  |  APPROXNUM
@@ -4004,7 +4015,7 @@ literal:
 
                  errno = 0;
                  val = strtod($1,&p);
-                 if (p == $1 || (errno == ERANGE && val != 0)) {
+                 if (p == $1 || (errno == ERANGE && (val < -1 || val > 1))) {
                        char *msg = sql_message("Double value too large or not 
a number (%s)", $1);
 
                        yyerror(msg);
diff --git a/sql/test/ADT2006/Tests/viss.timeout 
b/sql/test/ADT2006/Tests/viss.timeout
--- a/sql/test/ADT2006/Tests/viss.timeout
+++ b/sql/test/ADT2006/Tests/viss.timeout
@@ -1,1 +1,1 @@
-16.65
+16.8
diff --git 
a/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.err
 
b/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.err
--- 
a/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.err
+++ 
b/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.err
@@ -10,10 +10,10 @@ stderr of test 'prepare-where.SF-1238867
 # 13:00:07 >  Mtimeout -timeout 60 MapiClient -lsql -u monetdb -P monetdb 
--host=localhost --port=41457  < 
prepare-where.SF-1238867.1238959.1238965.1240124.sql
 # 13:00:07 >  
 
-MAPI  = monetdb@localhost:35781
+MAPI  = monetdb@ottar:34070
 QUERY = prepare select * from env() as env where ? = ?;
 ERROR = !Cannot have a parameter (?) on both sides of an expression
-MAPI  = monetdb@localhost:35781
+MAPI  = monetdb@ottar:34070
 QUERY = prepare select ? from env() as env;
 ERROR = !SELECT: subquery result missing
 
diff --git 
a/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.out
 
b/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.out
--- 
a/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.out
+++ 
b/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare-where.SF-1238867.1238959.1238965.1240124.stable.out
@@ -21,12 +21,12 @@ Ready.
 % .prepare,    .prepare,       .prepare # table_name
 % type,        digits, scale # name
 % varchar,     int,    int # type
-% 0,   0,      0 # length
+% 7,   1,      1 # length
 [ "tinyint",   8,      0       ]
 % .prepare,    .prepare,       .prepare # table_name
 % type,        digits, scale # name
 % varchar,     int,    int # type
-% 0,   0,      0 # length
+% 7,   4,      1 # length
 [ "varchar",   1024,   0       ]
 
 # 13:00:07 >  
diff --git 
a/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare_doesnot_like_LIKE.SF-1234205.stable.out
 
b/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare_doesnot_like_LIKE.SF-1234205.stable.out
--- 
a/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare_doesnot_like_LIKE.SF-1234205.stable.out
+++ 
b/sql/test/BugDay_2005-12-19_2.9.3/Tests/prepare_doesnot_like_LIKE.SF-1234205.stable.out
@@ -22,7 +22,7 @@ Ready.
 % .prepare,    .prepare,       .prepare # table_name
 % type,        digits, scale # name
 % varchar,     int,    int # type
-% 0,   0,      0 # length
+% 4,   1,      1 # length
 [ "char",      0,      0       ]
 % sys.t1234205 # table_name
 % name # name
@@ -34,7 +34,8 @@ Ready.
 % .prepare,    .prepare,       .prepare # table_name
 % type,        digits, scale # name
 % varchar,     int,    int # type
-% 0,   0,      0 # length
+% 0,   1,      1 # length
+#execute 2 ();
 % sys.t1234205 # table_name
 % name # name
 % varchar # type
diff --git a/sql/test/BugTracker-2009/Tests/AVG_of_SQRT.SF-2757642.timeout 
b/sql/test/BugTracker-2009/Tests/AVG_of_SQRT.SF-2757642.timeout
--- a/sql/test/BugTracker-2009/Tests/AVG_of_SQRT.SF-2757642.timeout
+++ b/sql/test/BugTracker-2009/Tests/AVG_of_SQRT.SF-2757642.timeout
@@ -1,1 +1,1 @@
-16.65
+16.8
diff --git 
a/sql/test/BugTracker-2009/Tests/decimal_needs_truncation.SF-2605686.stable.out 
b/sql/test/BugTracker-2009/Tests/decimal_needs_truncation.SF-2605686.stable.out
--- 
a/sql/test/BugTracker-2009/Tests/decimal_needs_truncation.SF-2605686.stable.out
+++ 
b/sql/test/BugTracker-2009/Tests/decimal_needs_truncation.SF-2605686.stable.out
@@ -33,7 +33,7 @@ Ready.
 % .prepare,    .prepare,       .prepare # table_name
 % type,        digits, scale # name
 % varchar,     int,    int # type
-% 0,   0,      0 # length
+% 7,   1,      1 # length
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to