193
193
Session::Session(plugin::Client *client_arg, catalog::Instance::shared_ptr catalog_arg) :
194
194
impl_(new impl_c(*this)),
195
mem(impl_->mem_root),
195
196
mem_root(&impl_->mem_root),
196
197
query(new std::string),
246
247
client->setSession(this);
249
Pass nominal parameters to init_alloc_root only to ensure that
250
Pass nominal parameters to init only to ensure that
250
251
the destructor works OK in case of an error. The main_mem_root
251
252
will be re-initialized in init_for_queries().
253
memory::init_sql_alloc(mem_root, memory::ROOT_MIN_BLOCK_SIZE, 0);
254
mem.init(memory::ROOT_MIN_BLOCK_SIZE);
254
255
cuted_fields= sent_row_count= row_count= 0L;
255
256
// Must be reset to handle error with Session's created for init of mysqld
256
257
lex().current_select= 0;
288
289
memset(&status_var, 0, sizeof(status_var));
290
291
/* Initialize sub structures */
291
memory::init_sql_alloc(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
292
warn_root.init(WARN_ALLOC_BLOCK_SIZE);
293
294
substitute_null_with_insert_id = false;
294
295
lock_info.init(); /* safety: will be reset after start */
337
338
return session().transaction;
340
bool Session::add_item_to_list(Item *item)
341
void Session::add_item_to_list(Item *item)
342
return lex().current_select->add_item_to_list(this, item);
343
lex().current_select->add_item_to_list(this, item);
345
bool Session::add_value_to_list(Item *value)
346
void Session::add_value_to_list(Item *value)
347
348
lex().value_list.push_back(value);
351
bool Session::add_order_to_list(Item *item, bool asc)
353
return lex().current_select->add_order_to_list(this, item, asc);
356
bool Session::add_group_to_list(Item *item, bool asc)
358
return lex().current_select->add_group_to_list(this, item, asc);
351
void Session::add_order_to_list(Item *item, bool asc)
353
lex().current_select->add_order_to_list(this, item, asc);
356
void Session::add_group_to_list(Item *item, bool asc)
358
lex().current_select->add_group_to_list(this, item, asc);
361
361
void Session::free_items()
364
363
/* This works because items are allocated with memory::sql_alloc() */
365
for (; free_list; free_list= next)
364
for (Item* next; free_list; free_list= next)
367
366
next= free_list->next;
368
367
free_list->delete_self();
458
457
mysys_var=0; // Safety (shouldn't be needed)
460
459
impl_->mem_root.free_root(MYF(0));
461
currentMemRoot().release();
462
currentSession().release();
460
setCurrentMemRoot(NULL);
461
setCurrentSession(NULL);
464
463
plugin::Logging::postEndDo(this);
465
464
plugin::EventObserver::deregisterSessionEvents(session_event_observers);
564
563
command= COM_SLEEP;
565
564
times.set_time();
567
mem_root->reset_root_defaults(variables.query_alloc_block_size,
568
variables.query_prealloc_size);
566
mem.reset_defaults(variables.query_alloc_block_size, variables.query_prealloc_size);
569
567
transaction.xid_state.xid.set_null();
570
568
transaction.xid_state.in_session=1;
889
887
bool allocate_lex_string)
891
889
if (allocate_lex_string)
892
lex_str= (LEX_STRING *)getMemRoot()->allocate(sizeof(LEX_STRING));
893
lex_str->str= mem_root->strmake_root(str, length);
890
lex_str= (LEX_STRING *)getMemRoot()->alloc(sizeof(LEX_STRING));
891
lex_str->str= mem_root->strmake(str, length);
894
892
lex_str->length= length;
1557
1555
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
1560
*p_db= strmake(impl_->schema->c_str(), impl_->schema->size());
1558
*p_db= mem.strmake(*impl_->schema);
1561
1559
*p_db_length= impl_->schema->size();