Bug #48024 Innodb doesn't work with multi-statements
Submitted: 13 Oct 17:35
Reporter: Georgi Kodinov
Status: Verified
Category:Server: InnoDB Severity:S1 (Critical)
Version:5.1+ OS:Any
Assigned to: Marko Mäkelä Target Version:5.1+
Triage: Triaged: D2 (Serious)

[13 Oct 17:35] Georgi Kodinov
Description:
This is a spin-off of bug #40877.

Innodb threats the query text that is passed to it by the server (through thd_query()) as
a null-terminated string.
This causes problems with multi-statements that contain foreign key definition code, as
demonstrated by the example in bug #40877 because the individual statements in such a
multi statement are not null terminated and Innodb gets confused by reading the foreign
key definitions in the next statement(s).

How to repeat:
See the example in bug #40877

Suggested fix:
I will implement a new function for 5.1 that returns a pointer to LEX_STRING instead
(string pointer and length).

Please update the innodb logic to use the new function in 5.1 codebase instead of
thd_query() (that I want to obsolete).
Please update the the 5.0 innodb code to use store and use THD::query_length.

Note that the fix for bug #40877 (the extended API function) is a pre-requisite for this
bug.
[15 Oct 10:09] Gleb Shchepa
Also see bug #38816 -- a lock around InnoDB thd::query access is desirable.