Loading sql/field.cc +13 −3 Original line number Diff line number Diff line Loading @@ -1356,15 +1356,25 @@ void Field_num::add_zerofill_and_unsigned(String &res) const 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->db_name= orig_table->s->table_cache_key; } else field->org_table_name= field->db_name= ""; if (orig_table) { 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->length=field_length; field->type=type(); Loading sql/sql_select.cc +3 −0 Original line number Diff line number Diff line Loading @@ -14330,6 +14330,9 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, item_field= (Item*) new Item_field(field); if (!item_field) DBUG_RETURN(TRUE); // Fatal error if (item->real_item()->type() != Item::FIELD_ITEM) field->orig_table= 0; item_field->name= item->name; if (item->type() == Item::REF_ITEM) { Loading tests/mysql_client_test.c +26 −19 Original line number Diff line number Diff line Loading @@ -15490,7 +15490,7 @@ static void test_bug21635() char *query_end; MYSQL_RES *result; MYSQL_FIELD *field; unsigned int field_count, i; unsigned int field_count, i, j; int rc; DBUG_ENTER("test_bug21635"); Loading @@ -15506,6 +15506,12 @@ static void test_bug21635() myquery(rc); rc= mysql_query(mysql, "CREATE TABLE t1 (i INT)"); 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)"); myquery(rc); Loading @@ -15528,6 +15534,7 @@ static void test_bug21635() } mysql_free_result(result); } rc= mysql_query(mysql, "DROP TABLE t1"); myquery(rc); Loading Loading
sql/field.cc +13 −3 Original line number Diff line number Diff line Loading @@ -1356,15 +1356,25 @@ void Field_num::add_zerofill_and_unsigned(String &res) const 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->db_name= orig_table->s->table_cache_key; } else field->org_table_name= field->db_name= ""; if (orig_table) { 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->length=field_length; field->type=type(); Loading
sql/sql_select.cc +3 −0 Original line number Diff line number Diff line Loading @@ -14330,6 +14330,9 @@ change_to_use_tmp_fields(THD *thd, Item **ref_pointer_array, item_field= (Item*) new Item_field(field); if (!item_field) DBUG_RETURN(TRUE); // Fatal error if (item->real_item()->type() != Item::FIELD_ITEM) field->orig_table= 0; item_field->name= item->name; if (item->type() == Item::REF_ITEM) { Loading
tests/mysql_client_test.c +26 −19 Original line number Diff line number Diff line Loading @@ -15490,7 +15490,7 @@ static void test_bug21635() char *query_end; MYSQL_RES *result; MYSQL_FIELD *field; unsigned int field_count, i; unsigned int field_count, i, j; int rc; DBUG_ENTER("test_bug21635"); Loading @@ -15506,6 +15506,12 @@ static void test_bug21635() myquery(rc); rc= mysql_query(mysql, "CREATE TABLE t1 (i INT)"); 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)"); myquery(rc); Loading @@ -15528,6 +15534,7 @@ static void test_bug21635() } mysql_free_result(result); } rc= mysql_query(mysql, "DROP TABLE t1"); myquery(rc); Loading