diff options
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 50 |
1 files changed, 27 insertions, 23 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6962e759023..08509a0e2bf 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -49,6 +49,7 @@ #include "transaction.h" #include "sql_prepare.h" #include "sql_statistics.h" +#include "sql_cte.h" #include <m_ctype.h> #include <my_dir.h> #include <hash.h> @@ -348,7 +349,6 @@ void intern_close_table(TABLE *table) table->s ? table->s->table_name.str : "?", (long) table)); - free_io_cache(table); delete table->triggers; if (table->file) // Not true if placeholder (void) closefrm(table, 1); // close file @@ -358,21 +358,6 @@ void intern_close_table(TABLE *table) } -/* Free resources allocated by filesort() and read_record() */ - -void free_io_cache(TABLE *table) -{ - DBUG_ENTER("free_io_cache"); - if (table->sort.io_cache) - { - close_cached_file(table->sort.io_cache); - my_free(table->sort.io_cache); - table->sort.io_cache=0; - } - DBUG_VOID_RETURN; -} - - /** Auxiliary function which allows to kill delayed threads for particular table identified by its share. @@ -1811,7 +1796,6 @@ void close_temporary(TABLE *table, bool free_share, bool delete_table) DBUG_PRINT("tmptable", ("closing table: '%s'.'%s'", table->s->db.str, table->s->table_name.str)); - free_io_cache(table); closefrm(table, 0); if (delete_table) rm_temporary_table(table_type, table->s->path.str); @@ -3920,6 +3904,26 @@ open_and_process_table(THD *thd, LEX *lex, TABLE_LIST *tables, tables->table_name= tables->view_name.str; tables->table_name_length= tables->view_name.length; } + else if (tables->select_lex) + { + /* + Check whether 'tables' refers to a table defined in a with clause. + If so set the reference to the definition in tables->with. + */ + if (!tables->with) + tables->with= tables->select_lex->find_table_def_in_with_clauses(tables); + /* + If 'tables' is defined in a with clause set the pointer to the + specification from its definition in tables->derived. + */ + if (tables->with) + { + if (tables->set_as_with_table(thd, tables->with)) + DBUG_RETURN(1); + else + goto end; + } + } /* If this TABLE_LIST object is a placeholder for an information_schema table, create a temporary table to represent the information_schema @@ -8354,7 +8358,7 @@ insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, temporary table. Thus in this case we can be sure that 'item' is an Item_field. */ - if (any_privileges) + if (any_privileges && !tables->is_with_table() && !tables->is_derived()) { DBUG_ASSERT((tables->field_translation == NULL && table) || tables->is_natural_join); @@ -8553,7 +8557,7 @@ bool setup_on_expr(THD *thd, TABLE_LIST *table, bool is_update) TODO RETURN - TRUE if some error occured (e.g. out of memory) + TRUE if some error occurred (e.g. out of memory) FALSE if all is OK */ @@ -8663,7 +8667,7 @@ err_no_arena: function. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ @@ -8825,7 +8829,7 @@ static bool not_null_fields_have_null_values(TABLE *table) record[1] buffers correspond to new and old versions of row respectively. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ @@ -8885,7 +8889,7 @@ fill_record_n_invoke_before_triggers(THD *thd, TABLE *table, List<Item> &fields, function. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ @@ -8980,7 +8984,7 @@ err: record[1] buffers correspond to new and old versions of row respectively. @return Status - @retval true An error occured. + @retval true An error occurred. @retval false OK. */ |