mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
VIEW
two TABLE_LIST copy eliminated include/mysqld_error.h: errors of view libmysqld/Makefile.am: new view file mysql-test/r/connect.result: SHOW TABLE show type of table mysql-test/r/ctype_recoding.result: SHOW TABLE show type of table mysql-test/r/drop.result: SHOW TABLE show type of table mysql-test/r/grant.result: new two privileges (CRETEA|SHOW VIEW) mysql-test/r/lowercase_table.result: SHOW TABLE show type of table mysql-test/r/ps_1general.result: SHOW TABLE show type of table mysql-test/r/rename.result: SHOW TABLE show type of table mysql-test/r/rpl000009.result: SHOW TABLE show type of table mysql-test/r/rpl_error_ignored_table.result: SHOW TABLE show type of table mysql-test/r/select.result: SHOW TABLE show type of table mysql-test/r/system_mysql_db.result: SHOW TABLE show type of table new two privileges (CRETEA|SHOW VIEW) mysql-test/t/system_mysql_db_fix.test: removing all system tables scripts/mysql_fix_privilege_tables.sql: new two privileges (CRETEA|SHOW VIEW) sql/Makefile.am: new VIEW related file sql/ha_myisammrg.cc: two TABLE_LIST copy eliminated sql/item.cc: VIEW sql/item.h: VIEW sql/item_subselect.cc: VIEW sql/item_subselect.h: VIEW sql/lex.h: VIEW sql/lock.cc: VIEW sql/mysql_priv.h: VIEW sql/mysqld.cc: VIEW new parameter - sql_updatable_view_key sql/opt_sum.cc: two TABLE_LIST copy eliminated sql/set_var.cc: new parameter - sql_updatable_view_key sql/share/czech/errmsg.txt: errors messages of views sql/share/danish/errmsg.txt: errors messages of views sql/share/dutch/errmsg.txt: errors messages of views sql/share/english/errmsg.txt: errors messages of views sql/share/estonian/errmsg.txt: errors messages of views sql/share/french/errmsg.txt: errors messages of views sql/share/german/errmsg.txt: errors messages of views sql/share/greek/errmsg.txt: errors messages of views sql/share/hungarian/errmsg.txt: errors messages of views sql/share/italian/errmsg.txt: errors messages of views sql/share/japanese/errmsg.txt: errors messages of views sql/share/korean/errmsg.txt: errors messages of views sql/share/norwegian-ny/errmsg.txt: errors messages of views sql/share/norwegian/errmsg.txt: errors messages of views sql/share/polish/errmsg.txt: errors messages of views sql/share/portuguese/errmsg.txt: errors messages of views sql/share/romanian/errmsg.txt: errors messages of views sql/share/russian/errmsg.txt: errors messages of views sql/share/serbian/errmsg.txt: errors messages of views sql/share/slovak/errmsg.txt: errors messages of views sql/share/spanish/errmsg.txt: errors messages of views sql/share/swedish/errmsg.txt: errors messages of views sql/share/ukrainian/errmsg.txt: errors messages of views sql/slave.cc: two TABLE_LIST copy eliminated sql/sp.cc: VIEW sql/sql_acl.cc: VIEW sql/sql_acl.h: VIEW sql/sql_base.cc: VIEW sql/sql_cache.cc: two TABLE_LIST copy eliminated sql/sql_class.h: VIEW sql/sql_db.cc: two TABLE_LIST copy eliminated sql/sql_delete.cc: VIEW sql/sql_derived.cc: VIEW sql/sql_handler.cc: two TABLE_LIST copy eliminated sql/sql_help.cc: two TABLE_LIST copy eliminated sql/sql_insert.cc: VIEW sql/sql_lex.cc: VIEW sql/sql_lex.h: VIEW sql/sql_load.cc: VIEW sql/sql_olap.cc: VIEW sql/sql_parse.cc: two TABLE_LIST copy eliminated VIEW sql/sql_prepare.cc: VIEW sql/sql_rename.cc: two TABLE_LIST copy eliminated sql/sql_select.cc: VIEW sql/sql_show.cc: VIEW sql/sql_table.cc: VIEW sql/sql_union.cc: VIEW sql/sql_update.cc: VIEW sql/sql_yacc.yy: VIEW sql/table.cc: VIEW sql/table.h: VIEW sql/tztime.cc: two TABLE_LIST copy eliminated sql/unireg.h: VIEW tests/client_test.c: VIEW
This commit is contained in:
@ -225,7 +225,7 @@ int handle_select(THD *thd, LEX *lex, select_result *result)
|
||||
thd->net.report_error));
|
||||
if (thd->net.report_error)
|
||||
res= 1;
|
||||
if (res)
|
||||
if (res > 0)
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
@ -236,45 +236,20 @@ int handle_select(THD *thd, LEX *lex, select_result *result)
|
||||
send_error(thd, 0, NullS);
|
||||
res= 1; // Error sent to client
|
||||
}
|
||||
if (res < 0)
|
||||
{
|
||||
if (result)
|
||||
{
|
||||
result->abort();
|
||||
}
|
||||
res= 1;
|
||||
}
|
||||
if (result != lex->result)
|
||||
delete result;
|
||||
DBUG_RETURN(res);
|
||||
}
|
||||
|
||||
|
||||
void relink_tables(SELECT_LEX *select_lex)
|
||||
{
|
||||
for (TABLE_LIST *cursor= (TABLE_LIST *) select_lex->table_list.first;
|
||||
cursor;
|
||||
cursor=cursor->next)
|
||||
if (cursor->table_list)
|
||||
cursor->table= cursor->table_list->table;
|
||||
}
|
||||
|
||||
|
||||
void fix_tables_pointers(SELECT_LEX *select_lex)
|
||||
{
|
||||
if (select_lex->next_select_in_list())
|
||||
{
|
||||
/* Fix tables 'to-be-unioned-from' list to point at opened tables */
|
||||
for (SELECT_LEX *sl= select_lex;
|
||||
sl;
|
||||
sl= sl->next_select_in_list())
|
||||
relink_tables(sl);
|
||||
}
|
||||
}
|
||||
|
||||
void fix_tables_pointers(SELECT_LEX_UNIT *unit)
|
||||
{
|
||||
for (SELECT_LEX *sl= unit->first_select(); sl; sl= sl->next_select())
|
||||
{
|
||||
relink_tables(sl);
|
||||
for (SELECT_LEX_UNIT *un= sl->first_inner_unit(); un; un= un->next_unit())
|
||||
fix_tables_pointers(un);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Function to setup clauses without sum functions
|
||||
*/
|
||||
@ -339,7 +314,7 @@ JOIN::prepare(Item ***rref_pointer_array,
|
||||
|
||||
/* Check that all tables, fields, conds and order are ok */
|
||||
|
||||
if (setup_tables(tables_list) ||
|
||||
if (setup_tables(thd, tables_list, &conds) ||
|
||||
setup_wild(thd, tables_list, fields_list, &all_fields, wild_num) ||
|
||||
select_lex->setup_ref_array(thd, og_num) ||
|
||||
setup_fields(thd, (*rref_pointer_array), tables_list, fields_list, 1,
|
||||
@ -366,20 +341,19 @@ JOIN::prepare(Item ***rref_pointer_array,
|
||||
having->split_sum_func(ref_pointer_array, all_fields);
|
||||
}
|
||||
|
||||
// Is it subselect
|
||||
if (!thd->lex->view_prepare_mode)
|
||||
{
|
||||
Item_subselect *subselect;
|
||||
/* Is it subselect? */
|
||||
if ((subselect= select_lex->master_unit()->item))
|
||||
{
|
||||
Item_subselect::trans_res res;
|
||||
if ((res= subselect->select_transformer(this)) !=
|
||||
if ((res= ((!thd->lex->view_prepare_mode) ?
|
||||
subselect->select_transformer(this) :
|
||||
subselect->no_select_transform())) !=
|
||||
Item_subselect::RES_OK)
|
||||
{
|
||||
if (thd->current_arena && select_lex->first_execution)
|
||||
{
|
||||
select_lex->prep_where= select_lex->where;
|
||||
select_lex->first_execution= 0;
|
||||
}
|
||||
select_lex->fix_prepare_information(thd, &conds);
|
||||
DBUG_RETURN((res == Item_subselect::RES_ERROR));
|
||||
}
|
||||
}
|
||||
@ -415,7 +389,7 @@ JOIN::prepare(Item ***rref_pointer_array,
|
||||
}
|
||||
}
|
||||
TABLE_LIST *table_ptr;
|
||||
for (table_ptr= tables_list ; table_ptr ; table_ptr= table_ptr->next)
|
||||
for (table_ptr= tables_list; table_ptr; table_ptr= table_ptr->next_local)
|
||||
tables++;
|
||||
}
|
||||
{
|
||||
@ -484,11 +458,7 @@ JOIN::prepare(Item ***rref_pointer_array,
|
||||
if (alloc_func_list())
|
||||
goto err;
|
||||
|
||||
if (thd->current_arena && select_lex->first_execution)
|
||||
{
|
||||
select_lex->prep_where= select_lex->where;
|
||||
select_lex->first_execution= 0;
|
||||
}
|
||||
select_lex->fix_prepare_information(thd, &conds);
|
||||
DBUG_RETURN(0); // All OK
|
||||
|
||||
err:
|
||||
@ -1049,10 +1019,15 @@ JOIN::reinit()
|
||||
DBUG_ENTER("JOIN::reinit");
|
||||
/* TODO move to unit reinit */
|
||||
unit->set_limit(select_lex, select_lex);
|
||||
|
||||
if (setup_tables(tables_list))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
|
||||
/* conds should not be used here, it is added just for safety */
|
||||
if (tables_list)
|
||||
{
|
||||
tables_list->setup_is_done= 0;
|
||||
if (setup_tables(thd, tables_list, &conds))
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
/* Reset of sum functions */
|
||||
first_record= 0;
|
||||
|
||||
@ -1747,7 +1722,9 @@ make_join_statistics(JOIN *join,TABLE_LIST *tables,COND *conds,
|
||||
found_const_table_map= all_table_map=0;
|
||||
const_count=0;
|
||||
|
||||
for (s=stat,i=0 ; tables ; s++,tables=tables->next,i++)
|
||||
for (s= stat, i= 0;
|
||||
tables;
|
||||
s++, tables= tables->next_local, i++)
|
||||
{
|
||||
table_map dep_tables;
|
||||
TABLE_LIST *embedding= tables->embedding;
|
||||
@ -5329,7 +5306,7 @@ return_zero_rows(JOIN *join, select_result *result,TABLE_LIST *tables,
|
||||
|
||||
if (send_row)
|
||||
{
|
||||
for (TABLE_LIST *table=tables; table ; table=table->next)
|
||||
for (TABLE_LIST *table= tables; table; table= table->next_local)
|
||||
mark_as_null_row(table->table); // All fields are NULL
|
||||
if (having && having->val_int() == 0)
|
||||
send_row=0;
|
||||
@ -10019,7 +9996,7 @@ get_sort_by_table(ORDER *a,ORDER *b,TABLE_LIST *tables)
|
||||
if (!map || (map & (RAND_TABLE_BIT | OUTER_REF_TABLE_BIT)))
|
||||
DBUG_RETURN(0);
|
||||
|
||||
for (; !(map & tables->table->map) ; tables=tables->next) ;
|
||||
for (; !(map & tables->table->map); tables= tables->next_local);
|
||||
if (map != tables->table->map)
|
||||
DBUG_RETURN(0); // More than one table
|
||||
DBUG_PRINT("exit",("sort by table: %d",tables->table->tablenr));
|
||||
@ -11271,6 +11248,17 @@ void st_table_list::print(THD *thd, String *str)
|
||||
print_join(thd, str, &nested_join->join_list);
|
||||
str->append(')');
|
||||
}
|
||||
else if (view_name.str)
|
||||
{
|
||||
str->append(view_db.str, view_db.length);
|
||||
str->append('.');
|
||||
str->append(view_name.str, view_name.length);
|
||||
if (my_strcasecmp(table_alias_charset, view_name.str, alias))
|
||||
{
|
||||
str->append(' ');
|
||||
str->append(alias);
|
||||
}
|
||||
}
|
||||
else if (derived)
|
||||
{
|
||||
str->append('(');
|
||||
|
Reference in New Issue
Block a user