1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +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

@ -2688,6 +2688,7 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
{
/* This is a base table. */
DBUG_ASSERT(nj_col->view_field == NULL);
DBUG_ASSERT(nj_col->table_ref->table == nj_col->table_field->table);
found_field= nj_col->table_field;
update_field_dependencies(thd, found_field, nj_col->table_ref->table);
}
@ -3366,9 +3367,7 @@ static bool
set_new_item_local_context(THD *thd, Item_ident *item, TABLE_LIST *table_ref)
{
Name_resolution_context *context;
if (!(context= (Name_resolution_context*)
thd->calloc(sizeof(Name_resolution_context))))
if (!(context= new Name_resolution_context))
return TRUE;
context->init();
context->first_name_resolution_table=
@ -3509,7 +3508,6 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
Field *field_1= nj_col_1->field();
Field *field_2= nj_col_2->field();
Item_ident *item_ident_1, *item_ident_2;
Name_resolution_context *context_1, *context_2;
Item_func_eq *eq_cond;
DBUG_PRINT("info", ("new equi-join condition: %s.%s = %s.%s",
@ -3545,8 +3543,8 @@ mark_common_columns(THD *thd, TABLE_LIST *table_ref_1, TABLE_LIST *table_ref_2,
resolution of these items, and to enable proper name resolution of
the items during the execute phase of PS.
*/
if (set_new_item_local_context(thd, item_ident_1, table_ref_1) ||
set_new_item_local_context(thd, item_ident_2, table_ref_2))
if (set_new_item_local_context(thd, item_ident_1, nj_col_1->table_ref) ||
set_new_item_local_context(thd, item_ident_2, nj_col_2->table_ref))
goto err;
if (!(eq_cond= new Item_func_eq(item_ident_1, item_ident_2)))
@ -4336,7 +4334,6 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name,
continue;
}
bool view;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/* Ensure that we have access rights to all fields to be inserted. */
if (!((table && (table->grant.privilege & SELECT_ACL) ||