mirror of
https://github.com/MariaDB/server.git
synced 2025-08-09 22:24:09 +03:00
MDEV-35276 Assertion failure in find_producing_item upon a query from a view
Two problem solved: 1) Item_default_value makes a shallow copy so the copy should not delete field belong to the Item 2) Item_default_value should not inherit derived_field_transformer_for_having and derived_field_transformer_for_where (in this variant pushing DEFAULT(f) is prohibited (return NULL) but if return "this" it will be allowed (should go with a lot of tests))
This commit is contained in:
@@ -19051,4 +19051,31 @@ EXPLAIN
|
||||
}
|
||||
}
|
||||
drop table t1, t2;
|
||||
#
|
||||
# MDEV-35276: Assertion failure in find_producing_item upon a query
|
||||
# from a view
|
||||
#
|
||||
# Note: for all followng queries with DEFAULT(f) hishdown is
|
||||
# prohibited
|
||||
CREATE VIEW v AS select 0 AS f;
|
||||
SELECT * FROM v WHERE f = DEFAULT(f);
|
||||
f
|
||||
0
|
||||
CREATE TABLE t1 (c int DEFAULT 0);
|
||||
insert into t1 values (0), (1);
|
||||
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
|
||||
f c
|
||||
0 0
|
||||
0 1
|
||||
ALTER TABLE t1 ALTER c SET DEFAULT 1;
|
||||
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
|
||||
f c
|
||||
drop table t1;
|
||||
create table t1 (a int, c int DEFAULT a);
|
||||
insert into t1 values (0, -1), (1, -2);
|
||||
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
|
||||
f a c
|
||||
0 0 -1
|
||||
DROP VIEW v;
|
||||
DROP TABLE t1;
|
||||
# End of 10.5 tests
|
||||
|
@@ -4188,4 +4188,34 @@ execute stmt;
|
||||
|
||||
drop table t1, t2;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-35276: Assertion failure in find_producing_item upon a query
|
||||
--echo # from a view
|
||||
--echo #
|
||||
--echo # Note: for all followng queries with DEFAULT(f) hishdown is
|
||||
--echo # prohibited
|
||||
|
||||
CREATE VIEW v AS select 0 AS f;
|
||||
|
||||
SELECT * FROM v WHERE f = DEFAULT(f);
|
||||
|
||||
CREATE TABLE t1 (c int DEFAULT 0);
|
||||
insert into t1 values (0), (1);
|
||||
|
||||
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
|
||||
|
||||
ALTER TABLE t1 ALTER c SET DEFAULT 1;
|
||||
|
||||
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
|
||||
|
||||
drop table t1;
|
||||
create table t1 (a int, c int DEFAULT a);
|
||||
insert into t1 values (0, -1), (1, -2);
|
||||
|
||||
SELECT * FROM v,t1 WHERE f = DEFAULT(c);
|
||||
|
||||
DROP VIEW v;
|
||||
DROP TABLE t1;
|
||||
|
||||
|
||||
--echo # End of 10.5 tests
|
||||
|
@@ -9659,7 +9659,8 @@ bool Item_default_value::fix_fields(THD *thd, Item **items)
|
||||
|
||||
void Item_default_value::cleanup()
|
||||
{
|
||||
delete field; // Free cached blob data
|
||||
if (!m_share_field)
|
||||
delete field; // Free cached blob data
|
||||
Item_field::cleanup();
|
||||
}
|
||||
|
||||
|
23
sql/item.h
23
sql/item.h
@@ -6646,8 +6646,9 @@ public:
|
||||
|
||||
class Item_default_value : public Item_field
|
||||
{
|
||||
bool vcol_assignment_ok;
|
||||
bool m_associated= false;
|
||||
bool vcol_assignment_ok:1;
|
||||
bool m_associated:1;
|
||||
bool m_share_field:1;
|
||||
|
||||
void calculate();
|
||||
public:
|
||||
@@ -6655,7 +6656,11 @@ public:
|
||||
Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a,
|
||||
bool vcol_assignment_arg)
|
||||
: Item_field(thd, context_arg),
|
||||
vcol_assignment_ok(vcol_assignment_arg), arg(a) {}
|
||||
vcol_assignment_ok(vcol_assignment_arg), arg(a)
|
||||
{
|
||||
m_associated= false;
|
||||
m_share_field= false;
|
||||
}
|
||||
Type type() const override { return DEFAULT_VALUE_ITEM; }
|
||||
bool eq(const Item *item, bool binary_cmp) const override;
|
||||
bool fix_fields(THD *, Item **) override;
|
||||
@@ -6717,6 +6722,10 @@ public:
|
||||
|
||||
Item *transform(THD *thd, Item_transformer transformer, uchar *args)
|
||||
override;
|
||||
Item *derived_field_transformer_for_having(THD *thd, uchar *arg) override
|
||||
{ return NULL; }
|
||||
Item *derived_field_transformer_for_where(THD *thd, uchar *arg) override
|
||||
{ return NULL; }
|
||||
Field *create_tmp_field_ex(MEM_ROOT *root, TABLE *table, Tmp_field_src *src,
|
||||
const Tmp_field_param *param) override;
|
||||
|
||||
@@ -6726,7 +6735,13 @@ public:
|
||||
*/
|
||||
bool associate_with_target_field(THD *thd, Item_field *field) override;
|
||||
Item *do_get_copy(THD *thd) const override
|
||||
{ return get_item_copy<Item_default_value>(thd, this); }
|
||||
{
|
||||
Item_default_value *new_item=
|
||||
(Item_default_value *) get_item_copy<Item_default_value>(thd, this);
|
||||
// This is a copy so do not manage the field and should not delete it
|
||||
new_item->m_share_field= 1;
|
||||
return new_item;
|
||||
}
|
||||
Item* do_build_clone(THD *thd) const override { return get_copy(thd); }
|
||||
private:
|
||||
bool tie_field(THD *thd);
|
||||
|
Reference in New Issue
Block a user