1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fixed BUG#16474: SP crashed MySQL

fix_fields() was not called for "order by" variables if the type was a
  "constant integer", and thus interpreted as a column index.
  However, a local variable is an expression and should not be interpreted
  as a column index. Instead it behaves just like when using a user variable
  for instance (i.e. it will not affect the ordering).



mysql-test/r/sp.result:
  Updated results for new test case (BUG#16474).
mysql-test/t/sp.test:
  New test case for BUG#16474.
sql/sql_select.cc:
  When processing order list,
This commit is contained in:
unknown
2006-03-10 14:04:56 +01:00
parent e889f9efcc
commit fb36d923ce
3 changed files with 65 additions and 1 deletions

View File

@ -12325,7 +12325,11 @@ find_order_in_list(THD *thd, Item **ref_pointer_array, TABLE_LIST *tables,
Item **select_item; /* The corresponding item from the SELECT clause. */
Field *from_field; /* The corresponding field from the FROM clause. */
if (order_item->type() == Item::INT_ITEM)
/*
Local SP variables may be int but are expressions, not positions.
(And they must be fixed.)
*/
if (order_item->type() == Item::INT_ITEM && !order_item->is_splocal())
{ /* Order by position */
uint count= (uint) order_item->val_int();
if (!count || count > fields.elements)