mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-13242 Wrong results for queries with row constructors and information_schema
This commit is contained in:
@@ -2069,3 +2069,35 @@ Opened_tables 3
|
|||||||
drop database mysqltest;
|
drop database mysqltest;
|
||||||
drop database db1;
|
drop database db1;
|
||||||
set global sql_mode=default;
|
set global sql_mode=default;
|
||||||
|
USE test;
|
||||||
|
#
|
||||||
|
# End of 10.0 tests
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Start of 10.1 tests
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# MDEV-13242 Wrong results for queries with row constructors and information_schema
|
||||||
|
#
|
||||||
|
CREATE TABLE tt1(c1 INT);
|
||||||
|
CREATE TABLE tt2(c2 INT);
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name, column_name) IN (('tt1', 'c1'));
|
||||||
|
count(*)
|
||||||
|
1
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name, column_name) IN (('tt2', 'c2'));
|
||||||
|
count(*)
|
||||||
|
1
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name, column_name) IN (('tt1','c1'),('tt2', 'c2'));
|
||||||
|
count(*)
|
||||||
|
2
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name, column_name) IN (SELECT 'tt1','c1' FROM dual UNION SELECT 'tt2', 'c2' FROM dual);
|
||||||
|
count(*)
|
||||||
|
2
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name='tt1' AND column_name='c1') OR (table_name='tt2' AND column_name='c2');
|
||||||
|
count(*)
|
||||||
|
2
|
||||||
|
SELECT column_name FROM information_schema.columns WHERE (table_name, column_name) IN (('tt1','c1'),('tt2', 'c2')) ORDER BY column_name;
|
||||||
|
column_name
|
||||||
|
c1
|
||||||
|
c2
|
||||||
|
DROP TABLE tt1, tt2;
|
||||||
|
@@ -1910,3 +1910,29 @@ disconnect con1;
|
|||||||
--source include/wait_until_count_sessions.inc
|
--source include/wait_until_count_sessions.inc
|
||||||
|
|
||||||
set global sql_mode=default;
|
set global sql_mode=default;
|
||||||
|
|
||||||
|
USE test;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # End of 10.0 tests
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # Start of 10.1 tests
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-13242 Wrong results for queries with row constructors and information_schema
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE tt1(c1 INT);
|
||||||
|
CREATE TABLE tt2(c2 INT);
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name, column_name) IN (('tt1', 'c1'));
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name, column_name) IN (('tt2', 'c2'));
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name, column_name) IN (('tt1','c1'),('tt2', 'c2'));
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name, column_name) IN (SELECT 'tt1','c1' FROM dual UNION SELECT 'tt2', 'c2' FROM dual);
|
||||||
|
SELECT count(*) FROM information_schema.columns WHERE table_schema='test' AND (table_name='tt1' AND column_name='c1') OR (table_name='tt2' AND column_name='c2');
|
||||||
|
SELECT column_name FROM information_schema.columns WHERE (table_name, column_name) IN (('tt1','c1'),('tt2', 'c2')) ORDER BY column_name;
|
||||||
|
DROP TABLE tt1, tt2;
|
||||||
|
@@ -4131,6 +4131,8 @@ public:
|
|||||||
bool fix_fields(THD *thd, Item **it);
|
bool fix_fields(THD *thd, Item **it);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
|
Item *get_orig_item() const { return orig_item; }
|
||||||
|
|
||||||
/* Methods of getting value which should be cached in the cache */
|
/* Methods of getting value which should be cached in the cache */
|
||||||
void save_val(Field *to);
|
void save_val(Field *to);
|
||||||
double val_real();
|
double val_real();
|
||||||
|
@@ -3640,6 +3640,15 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (item->type() == Item::ROW_ITEM)
|
||||||
|
{
|
||||||
|
Item_row *item_row= static_cast<Item_row*>(item);
|
||||||
|
for (uint i= 0; i < item_row->cols(); i++)
|
||||||
|
{
|
||||||
|
if (!uses_only_table_name_fields(item_row->element_index(i), table))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (item->type() == Item::FIELD_ITEM)
|
else if (item->type() == Item::FIELD_ITEM)
|
||||||
{
|
{
|
||||||
Item_field *item_field= (Item_field*)item;
|
Item_field *item_field= (Item_field*)item;
|
||||||
@@ -3659,6 +3668,11 @@ bool uses_only_table_name_fields(Item *item, TABLE_LIST *table)
|
|||||||
strlen(item_field->field_name), 0)))
|
strlen(item_field->field_name), 0)))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
else if (item->type() == Item::EXPR_CACHE_ITEM)
|
||||||
|
{
|
||||||
|
Item_cache_wrapper *tmp= static_cast<Item_cache_wrapper*>(item);
|
||||||
|
return uses_only_table_name_fields(tmp->get_orig_item(), table);
|
||||||
|
}
|
||||||
else if (item->type() == Item::REF_ITEM)
|
else if (item->type() == Item::REF_ITEM)
|
||||||
return uses_only_table_name_fields(item->real_item(), table);
|
return uses_only_table_name_fields(item->real_item(), table);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user