44
44
#include <drizzled/check_stack_overrun.h>
45
45
#include <drizzled/lock.h>
46
46
#include <drizzled/plugin/listen.h>
47
#include <drizzled/cached_directory.h>
47
#include "drizzled/cached_directory.h"
48
48
#include <drizzled/field/epoch.h>
49
49
#include <drizzled/field/null.h>
50
#include <drizzled/sql_table.h>
51
#include <drizzled/charset.h>
52
#include <drizzled/pthread_globals.h>
53
#include <drizzled/internal/iocache.h>
54
#include <drizzled/drizzled.h>
55
#include <drizzled/plugin/authorization.h>
56
#include <drizzled/table/temporary.h>
57
#include <drizzled/table/placeholder.h>
58
#include <drizzled/table/unused.h>
59
#include <drizzled/plugin/storage_engine.h>
60
#include <drizzled/session.h>
61
#include <drizzled/item/subselect.h>
62
#include <drizzled/sql_lex.h>
63
#include <drizzled/catalog/local.h>
64
#include <drizzled/open_tables_state.h>
65
#include <drizzled/table/cache.h>
50
#include "drizzled/sql_table.h"
51
#include "drizzled/global_charset_info.h"
52
#include "drizzled/pthread_globals.h"
53
#include "drizzled/internal/iocache.h"
54
#include "drizzled/drizzled.h"
55
#include "drizzled/plugin/authorization.h"
56
#include "drizzled/table/temporary.h"
57
#include "drizzled/table/placeholder.h"
58
#include "drizzled/table/unused.h"
67
60
using namespace std;
71
65
extern bool volatile shutdown_in_progress;
161
156
@param session Thread context (may be NULL)
162
157
@param tables List of tables to remove from the cache
163
@param have_lock If table::Cache::mutex() is locked
158
@param have_lock If table::Cache::singleton().mutex() is locked
164
159
@param wait_for_refresh Wait for a impending flush
165
160
@param wait_for_placeholders Wait for tables being reopened so that the GRL
166
161
won't proceed while write-locked tables are being reopened by other
176
171
Session *session= this;
179
boost::mutex::scoped_lock scopedLock(table::Cache::mutex()); /* Optionally lock for remove tables from open_cahe if not in use */
174
boost::mutex::scoped_lock scopedLock(table::Cache::singleton().mutex()); /* Optionally lock for remove tables from open_cahe if not in use */
182
g_refresh_version++; // Force close of open tables
178
refresh_version++; // Force close of open tables
183
180
table::getUnused().clear();
182
if (wait_for_refresh)
185
Other threads could wait in a loop in open_and_lock_tables(),
186
trying to lock one or more of our tables.
188
If they wait for the locks in thr_multi_lock(), their lock
189
request is aborted. They loop in open_and_lock_tables() and
190
enter open_table(). Here they notice the table is refreshed and
191
wait for COND_refresh. Then they loop again in
192
openTablesLock() and this time open_table() succeeds. At
193
this moment, if we (the FLUSH TABLES thread) are scheduled and
194
on another FLUSH TABLES enter close_cached_tables(), they could
195
awake while we sleep below, waiting for others threads (us) to
196
close their open tables. If this happens, the other threads
197
would find the tables unlocked. They would get the locks, one
198
after the other, and could do their destructive work. This is an
199
issue if we have LOCK TABLES in effect.
201
The problem is that the other threads passed all checks in
202
open_table() before we refresh the table.
204
The fix for this problem is to set some_tables_deleted for all
205
threads with open tables. These threads can still get their
206
locks, but will immediately release them again after checking
207
this variable. They will then loop in openTablesLock()
208
again. There they will wait until we update all tables version
211
Setting some_tables_deleted is done by table::Cache::singleton().removeTable()
214
In other words (reviewer suggestion): You need this setting of
215
some_tables_deleted for the case when table was opened and all
216
related checks were passed before incrementing refresh_version
217
(which you already have) but attempt to lock the table happened
218
after the call to Session::close_old_data_files() i.e. after removal of
219
current thread locks.
221
for (table::CacheMap::const_iterator iter= table::getCache().begin();
222
iter != table::getCache().end();
225
Table *table= (*iter).second;
227
table->in_use->some_tables_deleted= false;
187
233
bool found= false;
188
234
for (TableList *table= tables; table; table= table->next_local)
190
if (table::Cache::removeTable(*session, identifier::Table(table->getSchemaName(), table->getTableName()), RTFC_OWNED_BY_Session_FLAG))
236
identifier::Table identifier(table->getSchemaName(), table->getTableName());
237
if (table::Cache::singleton().removeTable(session, identifier,
238
RTFC_OWNED_BY_Session_FLAG))
280
move one table to free list
328
move one table to free list
283
bool Open_tables_state::free_cached_table()
331
bool Session::free_cached_table(boost::mutex::scoped_lock &scopedLock)
285
table::Concurrent *table= static_cast<table::Concurrent *>(open_tables_);
287
safe_mutex_assert_owner(table::Cache::mutex().native_handle());
333
bool found_old_table= false;
337
table::Concurrent *table= static_cast<table::Concurrent *>(open_tables);
339
safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
288
340
assert(table->key_read == 0);
289
assert(not table->cursor || table->cursor->inited == Cursor::NONE);
341
assert(!table->cursor || table->cursor->inited == Cursor::NONE);
291
open_tables_= table->getNext();
343
open_tables= table->getNext();
293
345
if (table->needs_reopen_or_name_lock() ||
294
version != g_refresh_version || !table->db_stat)
346
version != refresh_version || !table->db_stat)
296
348
table::remove_table(table);
300
Open placeholders have Table::db_stat set to 0, so they should be
301
handled by the first alternative.
303
assert(not table->open_placeholder);
305
/* Free memory and reset for next loop */
306
table->cursor->ha_reset();
309
table::getUnused().link(table);
349
found_old_table= true;
354
Open placeholders have Table::db_stat set to 0, so they should be
355
handled by the first alternative.
357
assert(not table->open_placeholder);
359
/* Free memory and reset for next loop */
360
table->cursor->ha_reset();
363
table::getUnused().link(table);
366
return found_old_table;
319
375
@remark It should not ordinarily be called directly.
322
void Open_tables_state::close_open_tables()
378
void Session::close_open_tables()
324
380
bool found_old_table= false;
326
safe_mutex_assert_not_owner(table::Cache::mutex().native_handle());
328
boost::mutex::scoped_lock scoped_lock(table::Cache::mutex()); /* Close all open tables on Session */
382
safe_mutex_assert_not_owner(table::Cache::singleton().mutex().native_handle());
384
boost_unique_lock_t scoped_lock(table::Cache::singleton().mutex()); /* Close all open tables on Session */
332
found_old_table|= free_cached_table();
388
found_old_table|= free_cached_table(scoped_lock);
390
some_tables_deleted= false;
334
392
if (found_old_table)
336
394
/* Tell threads waiting for refresh that something has happened */
576
634
int Open_tables_state::drop_temporary_table(const drizzled::identifier::Table &identifier)
578
Table* table= find_temporary_table(identifier);
638
if (not (table= find_temporary_table(identifier)))
582
641
/* Table might be in use by some outer statement. */
583
if (table->query_id && table->query_id != session_.getQueryId())
642
if (table->query_id && table->query_id != getQueryId())
585
644
my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->getAlias());
588
648
close_temporary_table(table);
605
666
const identifier::Table::Key find_key(find->getShare()->getCacheKey());
607
safe_mutex_assert_owner(table::Cache::mutex().native_handle());
668
safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
610
Note that we need to hold table::Cache::mutex() while changing the
671
Note that we need to hold table::Cache::singleton().mutex() while changing the
611
672
open_tables list. Another thread may work on it.
612
(See: table::Cache::removeTable(), wait_completed_table())
673
(See: table::Cache::singleton().removeTable(), wait_completed_table())
613
674
Closing a MERGE child before the parent would be fatal if the
614
675
other thread tries to abort the MERGE lock in between.
616
for (prev= &open_tables.open_tables_; *prev; )
677
for (prev= &open_tables; *prev; )
618
679
Table *list= *prev;
661
722
if (table->getShare()->getType())
663
open_tables.close_temporary_table(table);
724
close_temporary_table(table);
667
boost::mutex::scoped_lock scoped_lock(table::Cache::mutex()); /* Close and drop a table (AUX routine) */
728
boost_unique_lock_t scoped_lock(table::Cache::singleton().mutex()); /* Close and drop a table (AUX routine) */
669
730
unlink_open_table() also tells threads waiting for refresh or close
670
731
that something has happened.
705
766
condition variables that are guranteed to not disapper (freed) even if this
706
767
mutex is unlocked
708
boost::mutex::scoped_lock scopedLock(mutex, boost::adopt_lock_t());
769
boost_unique_lock_t scopedLock(mutex, boost::adopt_lock_t());
709
770
if (not getKilled())
711
772
cond.wait(scopedLock);
714
boost::mutex::scoped_lock mysys_scopedLock(mysys_var->mutex);
775
boost_unique_lock_t mysys_scopedLock(mysys_var->mutex);
715
776
mysys_var->current_mutex= 0;
716
777
mysys_var->current_cond= 0;
717
778
set_proc_info(saved_proc_info);
734
table::Placeholder& Session::table_cache_insert_placeholder(const drizzled::identifier::Table &arg)
795
table::Placeholder *Session::table_cache_insert_placeholder(const drizzled::identifier::Table &arg)
736
safe_mutex_assert_owner(table::Cache::mutex().native_handle());
797
safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle());
739
800
Create a table entry with the right key and with an old refresh version
741
802
identifier::Table identifier(arg.getSchemaName(), arg.getTableName(), message::Table::INTERNAL);
742
table::Placeholder* table= new table::Placeholder(this, identifier);
743
table::Cache::insert(table);
803
table::Placeholder *table= new table::Placeholder(this, identifier);
805
if (not table::Cache::singleton().insert(table))
766
834
@retval true Error occured (OOM)
767
835
@retval false Success. 'table' parameter set according to above rules.
769
Table* Session::lock_table_name_if_not_cached(const identifier::Table &identifier)
837
bool Session::lock_table_name_if_not_cached(const identifier::Table &identifier, Table **table)
771
839
const identifier::Table::Key &key(identifier.getKey());
772
boost::mutex::scoped_lock scope_lock(table::Cache::mutex()); /* Obtain a name lock even though table is not in cache (like for create table) */
773
if (find_ptr(table::getCache(), key))
775
Table& table= table_cache_insert_placeholder(identifier);
776
table.open_placeholder= true;
777
table.setNext(open_tables.open_tables_);
778
open_tables.open_tables_= &table;
841
boost_unique_lock_t scope_lock(table::Cache::singleton().mutex()); /* Obtain a name lock even though table is not in cache (like for create table) */
843
table::CacheMap::iterator iter;
845
iter= table::getCache().find(key);
847
if (iter != table::getCache().end())
853
if (not (*table= table_cache_insert_placeholder(identifier)))
857
(*table)->open_placeholder= true;
858
(*table)->setNext(open_tables);
882
964
Note-> refresh_version is currently changed only during FLUSH TABLES.
884
if (!open_tables.open_tables_)
886
open_tables.version= g_refresh_version;
968
version= refresh_version;
888
else if ((open_tables.version != g_refresh_version) &&
970
else if ((version != refresh_version) &&
889
971
! (flags & DRIZZLE_LOCK_IGNORE_FLUSH))
891
973
/* Someone did a refresh while thread was opening tables */
905
995
until no one holds a name lock on the table.
906
996
- if there is no such Table in the name cache, read the table definition
907
997
and insert it into the cache.
908
We perform all of the above under table::Cache::mutex() which currently protects
998
We perform all of the above under table::Cache::singleton().mutex() which currently protects
909
999
the open cache (also known as table cache) and table definitions stored
914
boost::mutex::scoped_lock scopedLock(table::Cache::mutex());
1004
table::Cache::singleton().mutex().lock(); /* Lock for FLUSH TABLES for open table */
917
1007
Actually try to find the table in the open_cache.
955
1046
if (flags & DRIZZLE_LOCK_IGNORE_FLUSH)
957
1048
/* Force close at once after usage */
958
open_tables.version= table->getShare()->getVersion();
1049
version= table->getShare()->getVersion();
962
1053
/* Avoid self-deadlocks by detecting self-dependencies. */
963
1054
if (table->open_placeholder && table->in_use == this)
1056
table::Cache::singleton().mutex().unlock();
965
1057
my_error(ER_UPDATE_TABLE_USED, MYF(0), table->getShare()->getTableName());
995
1087
if (table->in_use != this)
997
/* wait_for_conditionwill unlock table::Cache::mutex() for us */
998
wait_for_condition(table::Cache::mutex(), COND_refresh);
999
scopedLock.release();
1089
/* wait_for_conditionwill unlock table::Cache::singleton().mutex() for us */
1090
wait_for_condition(table::Cache::singleton().mutex(), COND_refresh);
1003
scopedLock.unlock();
1094
table::Cache::singleton().mutex().unlock();
1007
1097
There is a refresh in progress for this table.
1008
1098
Signal the caller that it has to try again.
1011
1101
*refresh= true;
1019
1107
table::getUnused().unlink(static_cast<table::Concurrent *>(table));
1035
1124
Table to be created, so we need to create placeholder in table-cache.
1037
table= &table_cache_insert_placeholder(lock_table_identifier);
1126
if (!(table= table_cache_insert_placeholder(lock_table_identifier)))
1128
table::Cache::singleton().mutex().unlock();
1039
1132
Link placeholder to the open tables list so it will be automatically
1040
1133
removed once tables are closed. Also mark it so it won't be ignored
1041
1134
by other trying to take name-lock.
1043
1136
table->open_placeholder= true;
1044
table->setNext(open_tables.open_tables_);
1045
open_tables.open_tables_= table;
1137
table->setNext(open_tables);
1139
table::Cache::singleton().mutex().unlock();
1054
1148
table::Concurrent *new_table= new table::Concurrent;
1055
1149
table= new_table;
1056
if (new_table->open_unireg_entry(this, alias, identifier))
1150
if (new_table == NULL)
1152
table::Cache::singleton().mutex().unlock();
1156
error= new_table->open_unireg_entry(this, alias, identifier);
1058
1159
delete new_table;
1160
table::Cache::singleton().mutex().unlock();
1061
(void)table::Cache::insert(new_table);
1163
(void)table::Cache::singleton().insert(new_table);
1167
table::Cache::singleton().mutex().unlock();
1068
table->setNext(open_tables.open_tables_); /* Link into simple list */
1069
open_tables.open_tables_= table;
1171
table->setNext(open_tables); /* Link into simple list */
1071
1174
table->reginfo.lock_type= TL_READ; /* Assume read */
1123
1226
void Session::close_data_files_and_morph_locks(const identifier::Table &identifier)
1125
safe_mutex_assert_owner(table::Cache::mutex().native_handle()); /* Adjust locks at the end of ALTER TABLEL */
1228
safe_mutex_assert_owner(table::Cache::singleton().mutex().native_handle()); /* Adjust locks at the end of ALTER TABLEL */
1127
if (open_tables.lock)
1130
1233
If we are not under LOCK TABLES we should have only one table
1131
1234
open and locked so it makes sense to remove the lock at once.
1133
unlockTables(open_tables.lock);
1134
open_tables.lock= 0;
1214
1317
if (tables != tables_ptr) // Should we get back old locks
1319
DrizzleLock *local_lock;
1217
1321
We should always get these locks. Anyway, we must not go into
1218
wait_for_tables() as it tries to acquire table::Cache::mutex(), which is
1322
wait_for_tables() as it tries to acquire table::Cache::singleton().mutex(), which is
1219
1323
already locked.
1325
some_tables_deleted= false;
1222
if (not lockTables(tables, (uint32_t) (tables_ptr - tables), flags))
1327
if ((local_lock= lockTables(tables, (uint32_t) (tables_ptr - tables), flags)))
1225
1334
This case should only happen if there is a bug in the reopen logic.
1352
1461
Table *drop_locked_tables(Session *session, const drizzled::identifier::Table &identifier)
1354
1463
Table *table,*next,**prev, *found= 0;
1355
prev= &session->open_tables.open_tables_;
1464
prev= &session->open_tables;
1358
Note that we need to hold table::Cache::mutex() while changing the
1467
Note that we need to hold table::Cache::singleton().mutex() while changing the
1359
1468
open_tables list. Another thread may work on it.
1360
(See: table::Cache::removeTable(), wait_completed_table())
1469
(See: table::Cache::singleton().removeTable(), wait_completed_table())
1361
1470
Closing a MERGE child before the parent would be fatal if the
1362
1471
other thread tries to abort the MERGE lock in between.
1364
for (table= session->open_tables.open_tables_; table ; table=next)
1473
for (table= session->open_tables; table ; table=next)
1366
1475
next=table->getNext();
1367
1476
if (table->getShare()->getCacheKey() == identifier.getKey())
1592
1701
table_list->lock_type= lock_type;
1593
1702
table_list->table= table;
1595
assert(open_tables.lock == 0); // You must lock everything at once
1704
assert(lock == 0); // You must lock everything at once
1596
1705
if ((table->reginfo.lock_type= lock_type) != TL_UNLOCK)
1598
if (not (open_tables.lock= lockTables(&table_list->table, 1, 0)))
1707
if (not (lock= lockTables(&table_list->table, 1, 0)))
1723
1833
if (link_in_list)
1725
1835
/* growing temp list at the head */
1726
new_tmp_table->setNext(open_tables.temporary_tables);
1836
new_tmp_table->setNext(this->temporary_tables);
1727
1837
if (new_tmp_table->getNext())
1729
1839
new_tmp_table->getNext()->setPrev(new_tmp_table);
1731
open_tables.temporary_tables= new_tmp_table;
1732
open_tables.temporary_tables->setPrev(0);
1841
this->temporary_tables= new_tmp_table;
1842
this->temporary_tables->setPrev(0);
1734
1844
new_tmp_table->pos_in_table_list= 0;
1818
1928
const char *name, uint32_t , Item **,
1819
1929
bool, TableList **actual_table)
1821
List<Natural_join_column>::iterator
1822
field_it(table_ref->join_columns->begin());
1931
List_iterator_fast<Natural_join_column>
1932
field_it(*(table_ref->join_columns));
1823
1933
Natural_join_column *nj_col, *curr_nj_col;
1824
1934
Field *found_field;
2276
2386
strcat(buff, table_name);
2277
2387
table_name=buff;
2279
my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, session->where());
2389
my_error(ER_UNKNOWN_TABLE, MYF(0), table_name, session->where);
2283
2393
if (report_error == REPORT_ALL_ERRORS ||
2284
2394
report_error == REPORT_EXCEPT_NON_UNIQUE)
2285
my_error(ER_BAD_FIELD_ERROR, MYF(0), item->full_name(), session->where());
2395
my_error(ER_BAD_FIELD_ERROR, MYF(0), item->full_name(), session->where);
2287
2397
found= not_found_field;
2333
2443
find_item_error_report_type report_error,
2334
2444
enum_resolution_type *resolution)
2336
List<Item>::iterator li(items.begin());
2446
List_iterator<Item> li(items);
2337
2447
Item **found=0, **found_unaliased= 0, *item;
2338
2448
const char *db_name=0;
2339
2449
const char *field_name=0;
2867
2977
columns. If this is not the case, report the first one that was
2868
2978
not found in an error.
2870
if (using_fields && found_using_fields < using_fields->size())
2980
if (using_fields && found_using_fields < using_fields->elements)
2872
2982
String *using_field_name;
2873
List<String>::iterator using_fields_it(using_fields->begin());
2983
List_iterator_fast<String> using_fields_it(*using_fields);
2874
2984
while ((using_field_name= using_fields_it++))
2876
2986
const char *using_field_name_ptr= using_field_name->c_ptr();
2877
List<Natural_join_column>::iterator
2878
it(natural_using_join->join_columns->begin());
2987
List_iterator_fast<Natural_join_column>
2988
it(*(natural_using_join->join_columns));
2879
2989
Natural_join_column *common_field;
2957
3067
/* Call the procedure recursively for each nested table reference. */
2958
3068
if (table_ref->getNestedJoin())
2960
List<TableList>::iterator nested_it(table_ref->getNestedJoin()->join_list.begin());
3070
List_iterator_fast<TableList> nested_it(table_ref->getNestedJoin()->join_list);
2961
3071
TableList *same_level_left_neighbor= nested_it++;
2962
3072
TableList *same_level_right_neighbor= NULL;
2963
3073
/* Left/right-most neighbors, possibly at higher levels in the join tree. */
3010
3120
if (table_ref->is_natural_join)
3012
3122
assert(table_ref->getNestedJoin() &&
3013
table_ref->getNestedJoin()->join_list.size() == 2);
3014
List<TableList>::iterator operand_it(table_ref->getNestedJoin()->join_list.begin());
3123
table_ref->getNestedJoin()->join_list.elements == 2);
3124
List_iterator_fast<TableList> operand_it(table_ref->getNestedJoin()->join_list);
3016
3126
Notice that the order of join operands depends on whether table_ref
3017
3127
represents a LEFT or a RIGHT join. In a RIGHT join, the operands are
3107
3217
List<TableList> *from_clause,
3108
3218
Name_resolution_context *context)
3110
session->setWhere("from clause");
3111
if (from_clause->size() == 0)
3220
session->where= "from clause";
3221
if (from_clause->elements == 0)
3112
3222
return false; /* We come here in the case of UNIONs. */
3114
List<TableList>::iterator table_ref_it(from_clause->begin());
3224
List_iterator_fast<TableList> table_ref_it(*from_clause);
3115
3225
TableList *table_ref; /* Current table reference. */
3116
3226
/* Table reference to the left of the current. */
3117
3227
TableList *left_neighbor;
3171
3281
((Item_field*) item)->field_name[0] == '*' &&
3172
3282
!((Item_field*) item)->field)
3174
uint32_t elem= fields.size();
3284
uint32_t elem= fields.elements;
3175
3285
bool any_privileges= ((Item_field *) item)->any_privileges;
3176
Item_subselect *subsel= session->lex().current_select->master_unit()->item;
3286
Item_subselect *subsel= session->lex->current_select->master_unit()->item;
3178
3288
subsel->substype() == Item_subselect::EXISTS_SUBS)
3199
3309
Because of this we have to update the element count also for this
3200
3310
list after expanding the '*' entry.
3202
sum_func_list->set_size(sum_func_list->size() + fields.size() - elem);
3312
sum_func_list->elements+= fields.elements - elem;
3207
session->lex().current_select->cur_pos_in_select_list++;
3317
session->lex->current_select->cur_pos_in_select_list++;
3209
session->lex().current_select->cur_pos_in_select_list= UNDEF_POS;
3319
session->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
3222
3332
register Item *item;
3223
3333
enum_mark_columns save_mark_used_columns= session->mark_used_columns;
3224
nesting_map save_allow_sum_func= session->lex().allow_sum_func;
3225
List<Item>::iterator it(fields.begin());
3334
nesting_map save_allow_sum_func= session->lex->allow_sum_func;
3335
List_iterator<Item> it(fields);
3226
3336
bool save_is_item_list_lookup;
3228
3338
session->mark_used_columns= mark_used_columns;
3229
3339
if (allow_sum_func)
3230
session->lex().allow_sum_func|= 1 << session->lex().current_select->nest_level;
3231
session->setWhere(Session::DEFAULT_WHERE);
3232
save_is_item_list_lookup= session->lex().current_select->is_item_list_lookup;
3233
session->lex().current_select->is_item_list_lookup= 0;
3340
session->lex->allow_sum_func|= 1 << session->lex->current_select->nest_level;
3341
session->where= Session::DEFAULT_WHERE;
3342
save_is_item_list_lookup= session->lex->current_select->is_item_list_lookup;
3343
session->lex->current_select->is_item_list_lookup= 0;
3236
3346
To prevent fail on forward lookup we fill it with zerows,
3240
3350
There is other way to solve problem: fill array with pointers to list,
3241
3351
but it will be slower.
3243
TODO-> remove it when (if) we made one list for allfields and ref_pointer_array
3353
TODO: remove it when (if) we made one list for allfields and
3245
3356
if (ref_pointer_array)
3247
memset(ref_pointer_array, 0, sizeof(Item *) * fields.size());
3357
memset(ref_pointer_array, 0, sizeof(Item *) * fields.elements);
3250
3359
Item **ref= ref_pointer_array;
3251
session->lex().current_select->cur_pos_in_select_list= 0;
3360
session->lex->current_select->cur_pos_in_select_list= 0;
3252
3361
while ((item= it++))
3254
3363
if ((!item->fixed && item->fix_fields(session, it.ref())) || (item= *(it.ref()))->check_cols(1))
3256
session->lex().current_select->is_item_list_lookup= save_is_item_list_lookup;
3257
session->lex().allow_sum_func= save_allow_sum_func;
3365
session->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
3366
session->lex->allow_sum_func= save_allow_sum_func;
3258
3367
session->mark_used_columns= save_mark_used_columns;
3265
3374
item->split_sum_func(session, ref_pointer_array, *sum_func_list);
3266
3375
session->used_tables|= item->used_tables();
3267
session->lex().current_select->cur_pos_in_select_list++;
3376
session->lex->current_select->cur_pos_in_select_list++;
3269
session->lex().current_select->is_item_list_lookup= save_is_item_list_lookup;
3270
session->lex().current_select->cur_pos_in_select_list= UNDEF_POS;
3378
session->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
3379
session->lex->current_select->cur_pos_in_select_list= UNDEF_POS;
3272
session->lex().allow_sum_func= save_allow_sum_func;
3381
session->lex->allow_sum_func= save_allow_sum_func;
3273
3382
session->mark_used_columns= save_mark_used_columns;
3274
3383
return(test(session->is_error()));
3440
3549
insert_fields(Session *session, Name_resolution_context *context, const char *db_name,
3441
const char *table_name, List<Item>::iterator *it,
3550
const char *table_name, List_iterator<Item> *it,
3444
3553
Field_iterator_table_ref field_iterator;
3651
3760
embedding= embedded->getEmbedding();
3653
3762
while (embedding &&
3654
&embedding->getNestedJoin()->join_list.front() == embedded);
3763
embedding->getNestedJoin()->join_list.head() == embedded);
3657
3766
session->session_marker= save_session_marker;
3659
session->lex().current_select->is_item_list_lookup= save_is_item_list_lookup;
3768
session->lex->current_select->is_item_list_lookup= save_is_item_list_lookup;
3660
3769
return(test(session->is_error()));
3803
void drizzle_rm_tmp_tables()
3911
bool drizzle_rm_tmp_tables()
3805
3914
assert(drizzle_tmpdir.size());
3806
3915
Session::shared_ptr session= Session::make_shared(plugin::Listen::getNullClient(), catalog::local());
3807
3919
session->thread_stack= (char*) session.get();
3808
3920
session->storeGlobals();
3809
3922
plugin::StorageEngine::removeLostTemporaryTables(*session, drizzle_tmpdir.c_str());