Changeset: 49a7b5ffcfab for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=49a7b5ffcfab
Modified Files:
        monetdb5/optimizer/opt_costModel.c
        sql/server/sql_parser.y
Branch: Jun2016
Log Message:

fixed a rather bizarre bug where the optimizer would call log(0) which would 
set errno which would never get cleared which would break a subsequent query 
with LIMIT 1 at the end.


diffs (37 lines):

diff --git a/monetdb5/optimizer/opt_costModel.c 
b/monetdb5/optimizer/opt_costModel.c
--- a/monetdb5/optimizer/opt_costModel.c
+++ b/monetdb5/optimizer/opt_costModel.c
@@ -67,6 +67,10 @@ OPTcostModelImplementation(Client cntxt,
                        } else
                        if (getFunctionId(p) == crossRef) {
                                newRows(1,2,((log((double) c1) + log((double) 
c2) > log(INT_MAX) ? INT_MAX : c1 * c2 +1)),0);
+                               /* log sets errno if it cannot compute the log. 
This will then screw with code that checks errno */
+                               if (errno == ERANGE || errno == EDOM) {
+                                       errno = 0;
+                               }
                        }
                } else if (getModuleId(p) == batcalcRef) {
                        if( getFunctionId(p) == ifthenelseRef) {
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
@@ -5160,7 +5160,8 @@ lngval:
                {
                  char *end = NULL, *s = $1;
                  int l = _strlen(s);
-
+                 // errno might be non-zero due to other people's code
+                 errno = 0;
                  if (l <= 19) {
                        $$ = strtoll(s,&end,10);
                  } else {
@@ -5182,7 +5183,8 @@ intval:
                {
                  char *end = NULL, *s = $1;
                  int l = _strlen(s);
-
+                 // errno might be non-zero due to other people's code
+                 errno = 0;
                  if (l <= 10) {
                        $$ = strtol(s,&end,10);
                  } else {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to