264
264
(hash_get_key) get_var_key,
265
265
(hash_free_key) free_user_var, 0);
268
267
protocol= protocol_arg;
269
268
protocol->setSession(this);
271
const Query_id& local_query_id= Query_id::get_query_id();
273
protocol->setRandom(tmp + (uint64_t) &protocol,
274
tmp + (uint64_t)local_query_id.value());
275
270
substitute_null_with_insert_id = false;
276
271
thr_lock_info_init(&lock_info); /* safety: will be reset after start */
277
272
thr_lock_owner_init(&main_lock_id, &lock_info);
359
Init Session for query processing.
360
This has to be called once before we call mysql_parse.
361
See also comments in session.h.
364
void Session::init_for_queries()
367
ha_enable_transaction(this,true);
369
reset_root_defaults(mem_root, variables.query_alloc_block_size,
370
variables.query_prealloc_size);
371
reset_root_defaults(&transaction.mem_root,
372
variables.trans_alloc_block_size,
373
variables.trans_prealloc_size);
374
transaction.xid_state.xid.null();
375
transaction.xid_state.in_session=1;
379
353
/* Do operations that may take a long time */
381
355
void Session::cleanup(void)
566
540
created in another thread
568
542
thr_lock_info_init(&lock_info);
547
Init Session for query processing.
548
This has to be called once before we call mysql_parse.
549
See also comments in session.h.
572
552
void Session::prepareForQueries()
574
554
if (variables.max_join_size == HA_POS_ERROR)
575
555
options |= OPTION_BIG_SELECTS;
576
if (client_capabilities & CLIENT_COMPRESS)
578
protocol->enableCompression();
581
557
version= refresh_version;
582
558
set_proc_info(NULL);
583
559
command= COM_SLEEP;
561
ha_enable_transaction(this,true);
563
reset_root_defaults(mem_root, variables.query_alloc_block_size,
564
variables.query_prealloc_size);
565
reset_root_defaults(&transaction.mem_root,
566
variables.trans_alloc_block_size,
567
variables.trans_prealloc_size);
568
transaction.xid_state.xid.null();
569
transaction.xid_state.in_session=1;
588
572
bool Session::initGlobals()
592
576
disconnect(ER_OUT_OF_RESOURCES, true);
593
577
statistic_increment(aborted_connects, &LOCK_status);
594
Scheduler &thread_scheduler= get_thread_scheduler();
595
thread_scheduler.end_thread(this, 0);
585
if (initGlobals() || authenticate())
593
while (!protocol->haveError() && killed != KILL_CONNECTION)
595
if (!executeStatement())
602
bool Session::schedule()
604
scheduler= get_thread_scheduler();
608
if (connection_count > max_used_connections)
609
max_used_connections= connection_count;
611
thread_id= variables.pseudo_thread_id= global_thread_id++;
613
pthread_mutex_lock(&LOCK_thread_count);
614
session_list.push_back(this);
615
pthread_mutex_unlock(&LOCK_thread_count);
617
if (scheduler->addSession(this))
619
char error_message_buff[DRIZZLE_ERRMSG_SIZE];
621
killed= Session::KILL_CONNECTION;
623
statistic_increment(aborted_connects, &LOCK_status);
625
/* Can't use my_error() since store_globals has not been called. */
626
/* TODO replace will better error message */
627
snprintf(error_message_buff, sizeof(error_message_buff),
628
ER(ER_CANT_CREATE_THREAD), 1);
629
protocol->sendError(ER_CANT_CREATE_THREAD, error_message_buff);
601
636
bool Session::authenticate()
604
639
if (protocol->authenticate())
607
642
statistic_increment(aborted_connects, &LOCK_status);
611
646
bool Session::checkUser(const char *passwd, uint32_t passwd_len, const char *in_db)