1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

WL#2486 - natural and using join according to SQL:2003

- Corrected problem with N-way nested natural joins in PS mode.
- Code cleanup
- More asserts to check consistency of name resolution contexts
- Fixed potential memory leak of name resolution contexts


mysql-test/r/join.result:
  - Corrected problem with N-way nested natural joins in PS mode.
mysql-test/t/join.test:
  - Corrected problem with N-way nested natural joins in PS mode.
sql/item.h:
  - Fixed potential memory leak.
sql/sql_base.cc:
  - the local context of Item_fields that participate in TABLE_LIST::on_cond for
    natural joins is correctly set to the tables where the corresponding fields
    originate from.
  - removed unused variables
  - correct allocation of contexts
sql/sql_parse.cc:
  - correct allocation of contexts for JOIN ON conditions.
sql/table.cc:
  - added asserts to check the consistency of name resolution contexts
sql/table.h:
  - added asserts to check the consistency of name resolution contexts
This commit is contained in:
unknown
2005-08-19 15:22:30 +03:00
parent bbf391cb54
commit 1cb72d7eb9
7 changed files with 50 additions and 26 deletions

View File

@ -2296,6 +2296,7 @@ Natural_join_column::Natural_join_column(Field_translator *field_param,
Natural_join_column::Natural_join_column(Field *field_param,
TABLE_LIST *tab)
{
DBUG_ASSERT(tab->table == field_param->table);
table_field= field_param;
view_field= NULL;
table_ref= tab;
@ -2514,6 +2515,18 @@ void Field_iterator_natural_join::set(TABLE_LIST *table_ref)
}
void Field_iterator_natural_join::next()
{
cur_column_ref= (*column_ref_it)++;
DBUG_ASSERT(cur_column_ref ?
(cur_column_ref->table_field ?
cur_column_ref->table_ref->table ==
cur_column_ref->table_field->table :
TRUE) :
TRUE);
}
void Field_iterator_table_ref::set_field_iterator()
{
DBUG_ENTER("Field_iterator_table_ref::set_field_iterator");
@ -2660,18 +2673,31 @@ Field_iterator_table_ref::get_or_create_column_ref(THD *thd, bool *is_created)
*is_created= TRUE;
if (field_it == &table_field_it)
return new Natural_join_column(table_field_it.field(), table_ref);
if (field_it == &view_field_it)
return new Natural_join_column(view_field_it.field_translator(),
table_ref);
/*
This is NATURAL join, we already have created a column reference,
so just return it.
*/
*is_created= FALSE;
nj_col= natural_join_it.column_ref();
DBUG_ASSERT(nj_col);
{
/* The field belongs to a stored table. */
Field *field= table_field_it.field();
nj_col= new Natural_join_column(field, table_ref);
}
else if (field_it == &view_field_it)
{
/* The field belongs to a merge view or information schema table. */
Field_translator *translated_field= view_field_it.field_translator();
nj_col= new Natural_join_column(translated_field, table_ref);
}
else
{
/*
The field belongs to a NATURAL join, therefore the column reference was
already created via one of the two constructor calls above. In this case
we just return the already created column reference.
*/
*is_created= FALSE;
nj_col= natural_join_it.column_ref();
DBUG_ASSERT(nj_col);
}
DBUG_ASSERT(nj_col->table_field ?
nj_col->table_ref->table == nj_col->table_field->table :
TRUE);
return nj_col;
}