diff options
author | unknown <igor@olga.mysql.com> | 2007-01-30 13:06:36 -0800 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2007-01-30 13:06:36 -0800 |
commit | 1944b4ca01165d34b2e0d5449704587129045684 (patch) | |
tree | 88b9d48120e50bd1fb60f17335c644e4ac52ad21 /sql | |
parent | da561a802caff95d755b8d2061c27c248f22e3cd (diff) | |
download | mariadb-git-1944b4ca01165d34b2e0d5449704587129045684.tar.gz |
Fixed bug #24987.
Made the function opt_sum_query to return HA_ERR_KEY_NOT_FOUND when
no matches were found (instead of -1 it returned prior this patch).
This changes allow us to avoid possible conflicts with return values
from user-defined handler methods which also may return -1.
No particular test cases are provided with this fix.
sql/opt_sum.cc:
Fixed bug #24987.
Made the function opt_sum_query to return HA_ERR_KEY_NOT_FOUND when
no matches were found (instead of -1 it returned prior this patch).
This changes allow us to avoid possible conflicts with return values
from user-defined handler methods which also may return -1.
sql/sql_select.cc:
Fixed bug #24987.
Made the function opt_sum_query to return HA_ERR_KEY_NOT_FOUND when
no matches were found (instead of -1 it returned prior this patch).
This changes allow us to avoid possible conflicts with return values
from user-defined handler methods which also may return -1.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/opt_sum.cc | 10 | ||||
-rw-r--r-- | sql/sql_select.cc | 18 |
2 files changed, 15 insertions, 13 deletions
diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 412fc0dc037..f912d67fe06 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -68,9 +68,9 @@ static int maxmin_in_range(bool max_fl, Field* field, COND *cond); GROUP BY part. RETURN VALUES - 0 No errors - 1 if all items were resolved - -1 on impossible conditions + 0 no errors + 1 if all items were resolved + HA_ERR_KEY_NOT_FOUND on impossible conditions OR an error number from my_base.h HA_ERR_... if a deadlock or a lock wait timeout happens, for example */ @@ -216,7 +216,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) if (error) { if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE) - return -1; // No rows matching WHERE + return HA_ERR_KEY_NOT_FOUND; // No rows matching WHERE /* HA_ERR_LOCK_DEADLOCK or some other error */ table->file->print_error(error, MYF(0)); return(error); @@ -303,7 +303,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) if (error) { if (error == HA_ERR_KEY_NOT_FOUND || error == HA_ERR_END_OF_FILE) - return -1; // No rows matching WHERE + return HA_ERR_KEY_NOT_FOUND; // No rows matching WHERE /* HA_ERR_LOCK_DEADLOCK or some other error */ table->file->print_error(error, MYF(0)); return(error); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 97fa6bb7809..0768e54c4da 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -531,23 +531,25 @@ JOIN::optimize() { int res; /* - opt_sum_query() returns -1 if no rows match to the WHERE conditions, - or 1 if all items were resolved, or 0, or an error number HA_ERR_... + opt_sum_query() returns HA_ERR_KEY_NOT_FOUND if no rows match + to the WHERE conditions, + or 1 if all items were resolved, + or 0, or an error number HA_ERR_... */ if ((res=opt_sum_query(tables_list, all_fields, conds))) { + if (res == HA_ERR_KEY_NOT_FOUND) + { + zero_result_cause= "No matching min/max row"; + error=0; + DBUG_RETURN(0); + } if (res > 1) { thd->fatal_error(); error= res; DBUG_RETURN(1); } - if (res < 0) - { - zero_result_cause= "No matching min/max row"; - error=0; - DBUG_RETURN(0); - } zero_result_cause= "Select tables optimized away"; tables_list= 0; // All tables resolved /* |