Commit bc1775ff authored by unknown's avatar unknown

Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0

into igor-inspiron.creware.com:/home/igor/mysql-5.0

parents 8115f6df f36db354
...@@ -1940,3 +1940,17 @@ s1 s2 ...@@ -1940,3 +1940,17 @@ s1 s2
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (f1 char) ENGINE = innodb;
INSERT INTO t1 VALUES ('A');
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES('B');
SELECT * FROM v1;
f1
A
B
SELECT * FROM t1;
f1
A
B
DROP VIEW v1;
DROP TABLE t1;
...@@ -1778,3 +1778,18 @@ CALL p1(); ...@@ -1778,3 +1778,18 @@ CALL p1();
DROP PROCEDURE p1; DROP PROCEDURE p1;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
#
# Test for bug #11771: wrong query_id in SELECT * FROM <view>
#
CREATE TABLE t1 (f1 char) ENGINE = innodb;
INSERT INTO t1 VALUES ('A');
CREATE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES('B');
SELECT * FROM v1;
SELECT * FROM t1;
DROP VIEW v1;
DROP TABLE t1;
...@@ -641,6 +641,7 @@ class Item { ...@@ -641,6 +641,7 @@ class Item {
virtual bool cleanup_processor(byte *arg); virtual bool cleanup_processor(byte *arg);
virtual bool collect_item_field_processor(byte * arg) { return 0; } virtual bool collect_item_field_processor(byte * arg) { return 0; }
virtual bool change_context_processor(byte *context) { return 0; } virtual bool change_context_processor(byte *context) { return 0; }
virtual bool reset_query_id_processor(byte *query_id) { return 0; }
virtual Item *equal_fields_propagator(byte * arg) { return this; } virtual Item *equal_fields_propagator(byte * arg) { return this; }
virtual Item *set_no_const_sub(byte *arg) { return this; } virtual Item *set_no_const_sub(byte *arg) { return this; }
...@@ -895,6 +896,13 @@ class Item_field :public Item_ident ...@@ -895,6 +896,13 @@ class Item_field :public Item_ident
bool is_null() { return field->is_null(); } bool is_null() { return field->is_null(); }
Item *get_tmp_table_item(THD *thd); Item *get_tmp_table_item(THD *thd);
bool collect_item_field_processor(byte * arg); bool collect_item_field_processor(byte * arg);
bool reset_query_id_processor(byte *arg)
{
field->query_id= *((query_id_t *) arg);
if (result_field)
result_field->query_id= field->query_id;
return 0;
}
void cleanup(); void cleanup();
Item_equal *find_item_equal(COND_EQUAL *cond_equal); Item_equal *find_item_equal(COND_EQUAL *cond_equal);
Item *equal_fields_propagator(byte *arg); Item *equal_fields_propagator(byte *arg);
......
...@@ -3495,6 +3495,12 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, ...@@ -3495,6 +3495,12 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
field->query_id=thd->query_id; field->query_id=thd->query_id;
table->used_keys.intersect(field->part_of_key); table->used_keys.intersect(field->part_of_key);
} }
else
{
Item *item= ((Field_iterator_view *) iterator)->item();
item->walk(&Item::reset_query_id_processor,
(byte *)(&thd->query_id));
}
} }
/* /*
All fields are used in case if usual tables (in case of view used All fields are used in case if usual tables (in case of view used
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment