[MDEV-17246] Stored Functions need their own temporary table namespace Created: 2018-09-19 Updated: 2018-10-16 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Procedure, Stored routines |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Chris Wilson | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
At present stored aggregate functions using temporary tables can only be used once within a particular query. Using the medi_int example from the documentation ( @ https://mariadb.com/kb/en/library/stored-aggregate-functions/ ) one can try:
|
| Comments |
| Comment by Chris Wilson [ 2018-09-19 ] | |||||||||||||||||||
|
In some cases I believe this problem can also be triggered by a query that only uses the Stored Aggregate Function once, but also has a 'HAVING' clause. I need to isolate an example. | |||||||||||||||||||
| Comment by Sergei Golubchik [ 2018-09-19 ] | |||||||||||||||||||
|
Right. But in a way it's common to all stored routines — functions, procedures, triggers, anything. The kind of error you've got is only possible in stored aggregate functions. But even in a stored routine, if one would need to create a temporary table, one can never know whether it'll conflict with some existing table of the same name. | |||||||||||||||||||
| Comment by Chris Wilson [ 2018-09-19 ] | |||||||||||||||||||
|
... but with those other stored routines the routine causing side effects is much more expected, isn't it? Indeed with triggers, often very much the intended use. Also with those it's always possible to work around the problem with a table naming convention. For the stored aggregate functions it doesn't appear to be possible to work around the problem - here's an example only using the function once, but with a having clause that triggers the issue (again using the medi_int example from the documentation):
[as an aside, interesting that if you switch x & y such that the count(*)s are all 0 then it doesn't trigger the problem]. | |||||||||||||||||||
| Comment by Chris Wilson [ 2018-09-19 ] | |||||||||||||||||||
|
In fact:
| |||||||||||||||||||
| Comment by Elena Stepanova [ 2018-10-03 ] | |||||||||||||||||||
|
Assigning to serg to decide what to do about it, if anything. |