clone-5.5.23-build

2012-03-29T13:07:54Z

Patch for Bug#13805127: Stored program cache produces wrong result in…

… same THD.

Background:

- as described in MySQL Internals Prepared Stored
(http://forge.mysql.com/wiki/MySQL_Internals_Prepared_Stored),
the Optimizer sometimes does destructive changes to the parsed
LEX-object (Item-tree), which makes it impossible to re-use
that tree for PS/SP re-execution.

- in order to be able to re-use the Item-tree, the destructive
changes are remembered and rolled back after the statement execution.

The problem, discovered by this bug, was that the objects representing
GROUP-BY clause did not restored after query execution. So, the GROUP-BY
part of the statement could not be properly re-initialized for re-execution
after destructive changes.

Those objects do not take part in the Item-tree, so they can not be saved
using the approach for Item-tree.

The fix is as follows:

- introduce a new array in st_select_lex to store the original
ORDER pointers, representing the GROUP-BY clause;

- Initialize this array in fix_prepare_information().

- restore the list of GROUP-BY items in reinit_stmt_before_use().

--BZR--
revision-id: tor.didriksen@oracle.com-20120329130754-vr7xb7e5fbvoekzg
property-branch-nick: 5.5
testament3-sha1: e6d46503ec5e864c578aeb6842802c6ca2832f96