mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bug#27990: Wrong info in MYSQL_FIELD struct members when a tmp table was used.
The change_to_use_tmp_fields function leaves the orig_table member of an expression's tmp table field filled for the new Item_field being created. Later orig_table is used by the Field::make_field function to provide some info about original table and field name to a user. This is ok for a field but for an expression it should be empty. The change_to_use_tmp_fields function now resets orig_table member of an expression's tmp table field to prevent providing a wrong info to a user. The Field::make_field function now resets the table_name and the org_col_name variables when the orig_table is set to 0.
This commit is contained in:
35
mysql-test/r/bdb_notembedded.result
Normal file
35
mysql-test/r/bdb_notembedded.result
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
set autocommit=1;
|
||||||
|
reset master;
|
||||||
|
create table bug16206 (a int);
|
||||||
|
insert into bug16206 values(1);
|
||||||
|
start transaction;
|
||||||
|
insert into bug16206 values(2);
|
||||||
|
commit;
|
||||||
|
show binlog events;
|
||||||
|
Log_name Pos Event_type Server_id End_log_pos Info
|
||||||
|
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
|
||||||
|
f n Query 1 n use `test`; create table bug16206 (a int)
|
||||||
|
f n Query 1 n use `test`; insert into bug16206 values(1)
|
||||||
|
f n Query 1 n use `test`; insert into bug16206 values(2)
|
||||||
|
drop table bug16206;
|
||||||
|
reset master;
|
||||||
|
create table bug16206 (a int) engine= bdb;
|
||||||
|
insert into bug16206 values(0);
|
||||||
|
insert into bug16206 values(1);
|
||||||
|
start transaction;
|
||||||
|
insert into bug16206 values(2);
|
||||||
|
commit;
|
||||||
|
insert into bug16206 values(3);
|
||||||
|
show binlog events;
|
||||||
|
Log_name Pos Event_type Server_id End_log_pos Info
|
||||||
|
f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4
|
||||||
|
f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb
|
||||||
|
f n Query 1 n use `test`; insert into bug16206 values(0)
|
||||||
|
f n Query 1 n use `test`; insert into bug16206 values(1)
|
||||||
|
f n Query 1 n use `test`; BEGIN
|
||||||
|
f n Query 1 n use `test`; insert into bug16206 values(2)
|
||||||
|
f n Query 1 n use `test`; COMMIT
|
||||||
|
f n Query 1 n use `test`; insert into bug16206 values(3)
|
||||||
|
drop table bug16206;
|
||||||
|
set autocommit=0;
|
||||||
|
End of 5.0 tests
|
38
mysql-test/t/bdb_notembedded.test
Normal file
38
mysql-test/t/bdb_notembedded.test
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
-- source include/not_embedded.inc
|
||||||
|
-- source include/have_bdb.inc
|
||||||
|
|
||||||
|
#
|
||||||
|
# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode
|
||||||
|
#
|
||||||
|
set autocommit=1;
|
||||||
|
|
||||||
|
let $VERSION=`select version()`;
|
||||||
|
|
||||||
|
reset master;
|
||||||
|
create table bug16206 (a int);
|
||||||
|
insert into bug16206 values(1);
|
||||||
|
start transaction;
|
||||||
|
insert into bug16206 values(2);
|
||||||
|
commit;
|
||||||
|
--replace_result $VERSION VERSION
|
||||||
|
--replace_column 1 f 2 n 5 n
|
||||||
|
show binlog events;
|
||||||
|
drop table bug16206;
|
||||||
|
|
||||||
|
reset master;
|
||||||
|
create table bug16206 (a int) engine= bdb;
|
||||||
|
insert into bug16206 values(0);
|
||||||
|
insert into bug16206 values(1);
|
||||||
|
start transaction;
|
||||||
|
insert into bug16206 values(2);
|
||||||
|
commit;
|
||||||
|
insert into bug16206 values(3);
|
||||||
|
--replace_result $VERSION VERSION
|
||||||
|
--replace_column 1 f 2 n 5 n
|
||||||
|
show binlog events;
|
||||||
|
drop table bug16206;
|
||||||
|
|
||||||
|
set autocommit=0;
|
||||||
|
|
||||||
|
|
||||||
|
--echo End of 5.0 tests
|
14
sql/field.cc
14
sql/field.cc
@ -1282,15 +1282,25 @@ void Field_num::add_zerofill_and_unsigned(String &res) const
|
|||||||
|
|
||||||
void Field::make_field(Send_field *field)
|
void Field::make_field(Send_field *field)
|
||||||
{
|
{
|
||||||
if (orig_table->s->table_cache_key && *(orig_table->s->table_cache_key))
|
if (orig_table && orig_table->s->table_cache_key &&
|
||||||
|
*(orig_table->s->table_cache_key))
|
||||||
{
|
{
|
||||||
field->org_table_name= orig_table->s->table_name;
|
field->org_table_name= orig_table->s->table_name;
|
||||||
field->db_name= orig_table->s->table_cache_key;
|
field->db_name= orig_table->s->table_cache_key;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
field->org_table_name= field->db_name= "";
|
field->org_table_name= field->db_name= "";
|
||||||
|
if (orig_table)
|
||||||
|
{
|
||||||
field->table_name= orig_table->alias;
|
field->table_name= orig_table->alias;
|
||||||
field->col_name= field->org_col_name= field_name;
|
field->org_col_name= field_name;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
field->table_name= "";
|
||||||
|
field->org_col_name= "";
|
||||||
|
}
|
||||||
|
field->col_name= field_name;
|
||||||
field->charsetnr= charset()->number;
|
field->charsetnr= charset()->number;
|
||||||
field->length=field_length;
|
field->length=field_length;
|
||||||
field->type=type();
|
field->type=type();
|
||||||
|
@ -14119,6 +14119,9 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array,
|
|||||||
item_field= (Item*) new Item_field(field);
|
item_field= (Item*) new Item_field(field);
|
||||||
if (!item_field)
|
if (!item_field)
|
||||||
DBUG_RETURN(TRUE); // Fatal error
|
DBUG_RETURN(TRUE); // Fatal error
|
||||||
|
|
||||||
|
if (item->real_item()->type() != Item::FIELD_ITEM)
|
||||||
|
field->orig_table= 0;
|
||||||
item_field->name= item->name;
|
item_field->name= item->name;
|
||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
if (_db_on_ && !item_field->name)
|
if (_db_on_ && !item_field->name)
|
||||||
|
@ -15486,7 +15486,7 @@ static void test_bug21635()
|
|||||||
char *query_end;
|
char *query_end;
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
MYSQL_FIELD *field;
|
MYSQL_FIELD *field;
|
||||||
unsigned int field_count, i;
|
unsigned int field_count, i, j;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
DBUG_ENTER("test_bug21635");
|
DBUG_ENTER("test_bug21635");
|
||||||
@ -15502,6 +15502,12 @@ static void test_bug21635()
|
|||||||
myquery(rc);
|
myquery(rc);
|
||||||
rc= mysql_query(mysql, "CREATE TABLE t1 (i INT)");
|
rc= mysql_query(mysql, "CREATE TABLE t1 (i INT)");
|
||||||
myquery(rc);
|
myquery(rc);
|
||||||
|
/*
|
||||||
|
We need this loop to ensure correct behavior with both constant and
|
||||||
|
non-constant tables.
|
||||||
|
*/
|
||||||
|
for (j= 0; j < 2 ; j++)
|
||||||
|
{
|
||||||
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
|
rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
|
||||||
myquery(rc);
|
myquery(rc);
|
||||||
|
|
||||||
@ -15524,6 +15530,7 @@ static void test_bug21635()
|
|||||||
}
|
}
|
||||||
|
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
|
}
|
||||||
rc= mysql_query(mysql, "DROP TABLE t1");
|
rc= mysql_query(mysql, "DROP TABLE t1");
|
||||||
myquery(rc);
|
myquery(rc);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user