mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Fixed LP bug #793386.
Auto-generated names for view field items must be allocated in the statement memory, not in the execution memory of the statement.
This commit is contained in:
@@ -4277,3 +4277,21 @@ Warnings:
|
|||||||
Note 1003 select `v2`.`b` AS `b` from `test`.`v2` where 0
|
Note 1003 select `v2`.`b` AS `b` from `test`.`v2` where 0
|
||||||
DROP VIEW v1,v2;
|
DROP VIEW v1,v2;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# LP bug #793386: unexpected 'Duplicate column name ''' error
|
||||||
|
# at the second execution of a PS using a view
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (f1 int, f2 int, f3 int, f4 int);
|
||||||
|
CREATE VIEW v1 AS
|
||||||
|
SELECT t.f1, t.f2, s.f3, s.f4 FROM t1 t, t1 s
|
||||||
|
WHERE t.f4 >= s.f2 AND s.f3 < 0;
|
||||||
|
PREPARE stmt1 FROM
|
||||||
|
"SELECT s.f1 AS f1, s.f2 AS f2, s.f3 AS f3, t.f4 AS f4
|
||||||
|
FROM v1 AS t LEFT JOIN v1 AS s ON t.f4=s.f4 WHERE t.f2 <> 1225";
|
||||||
|
EXECUTE stmt1;
|
||||||
|
f1 f2 f3 f4
|
||||||
|
EXECUTE stmt1;
|
||||||
|
f1 f2 f3 f4
|
||||||
|
DEALLOCATE PREPARE stmt1;
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
@@ -4213,3 +4213,25 @@ SELECT * FROM (SELECT b FROM v2 WHERE b = 0) t WHERE b;
|
|||||||
|
|
||||||
DROP VIEW v1,v2;
|
DROP VIEW v1,v2;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # LP bug #793386: unexpected 'Duplicate column name ''' error
|
||||||
|
--echo # at the second execution of a PS using a view
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (f1 int, f2 int, f3 int, f4 int);
|
||||||
|
|
||||||
|
CREATE VIEW v1 AS
|
||||||
|
SELECT t.f1, t.f2, s.f3, s.f4 FROM t1 t, t1 s
|
||||||
|
WHERE t.f4 >= s.f2 AND s.f3 < 0;
|
||||||
|
|
||||||
|
PREPARE stmt1 FROM
|
||||||
|
"SELECT s.f1 AS f1, s.f2 AS f2, s.f3 AS f3, t.f4 AS f4
|
||||||
|
FROM v1 AS t LEFT JOIN v1 AS s ON t.f4=s.f4 WHERE t.f2 <> 1225";
|
||||||
|
EXECUTE stmt1;
|
||||||
|
EXECUTE stmt1;
|
||||||
|
|
||||||
|
DEALLOCATE PREPARE stmt1;
|
||||||
|
|
||||||
|
DROP VIEW v1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
@@ -5861,10 +5861,15 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
|
|||||||
*/
|
*/
|
||||||
if (*ref && !(*ref)->is_autogenerated_name)
|
if (*ref && !(*ref)->is_autogenerated_name)
|
||||||
{
|
{
|
||||||
|
if (register_tree_change &&
|
||||||
|
thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())
|
||||||
|
arena= thd->activate_stmt_arena_if_needed(&backup);
|
||||||
item->set_name((*ref)->name, (*ref)->name_length,
|
item->set_name((*ref)->name, (*ref)->name_length,
|
||||||
system_charset_info);
|
system_charset_info);
|
||||||
item->real_item()->set_name((*ref)->name, (*ref)->name_length,
|
item->real_item()->set_name((*ref)->name, (*ref)->name_length,
|
||||||
system_charset_info);
|
system_charset_info);
|
||||||
|
if (arena)
|
||||||
|
thd->restore_active_arena(arena, &backup);
|
||||||
}
|
}
|
||||||
if (register_tree_change)
|
if (register_tree_change)
|
||||||
thd->change_item_tree(ref, item);
|
thd->change_item_tree(ref, item);
|
||||||
|
Reference in New Issue
Block a user