1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
21
/*****************************************************************************
19
** This file implements classes defined in sql_class.h
23
** This file implements classes defined in session.h
20
24
** Especially the classes to handle a result from a select
22
26
*****************************************************************************/
23
27
#include <drizzled/server_includes.h>
25
#include "rpl_record.h"
26
#include "log_event.h"
28
#include <drizzled/session.h>
27
29
#include <sys/stat.h>
28
30
#include <mysys/thr_alarm.h>
29
31
#include <mysys/mysys_err.h>
30
#include <drizzled/drizzled_error_messages.h>
32
#include <drizzled/error.h>
33
#include <drizzled/query_id.h>
34
#include <drizzled/data_home.h>
35
#include <drizzled/sql_base.h>
36
#include <drizzled/lock.h>
37
#include <drizzled/item/cache.h>
38
#include <drizzled/item/float.h>
39
#include <drizzled/item/return_int.h>
40
#include <drizzled/item/empty_string.h>
41
#include <drizzled/show.h>
42
#include <drizzled/plugin_scheduling.h>
44
extern scheduling_st thread_scheduler;
33
46
The following is used to initialise Table_ident with a internal
220
int thd_in_lock_tables(const THD *thd)
222
return test(thd->in_lock_tables);
227
int thd_tablespace_op(const THD *thd)
229
return test(thd->tablespace_op);
234
const char *set_thd_proc_info(THD *thd, const char *info,
235
const char *calling_function __attribute__((unused)),
236
const char *calling_file __attribute__((unused)),
237
const unsigned int calling_line __attribute__((unused)))
239
const char *old_info= thd->get_proc_info();
240
thd->set_proc_info(info);
245
void **thd_ha_data(const THD *thd, const struct handlerton *hton)
247
return (void **) &thd->ha_data[hton->slot].ha_ptr;
251
int64_t thd_test_options(const THD *thd, int64_t test_options)
253
return thd->options & test_options;
257
int thd_sql_command(const THD *thd)
259
return (int) thd->lex->sql_command;
263
int thd_tx_isolation(const THD *thd)
265
return (int) thd->variables.tx_isolation;
269
void thd_inc_row_count(THD *thd)
275
Clear this diagnostics area.
283
int session_in_lock_tables(const Session *session)
285
return test(session->in_lock_tables);
290
int session_tablespace_op(const Session *session)
292
return test(session->tablespace_op);
297
Set the process info field of the Session structure.
299
This function is used by plug-ins. Internally, the
300
Session::set_proc_info() function should be used.
302
@see Session::set_proc_info
305
set_session_proc_info(Session *session, const char *info)
307
session->set_proc_info(info);
311
const char *get_session_proc_info(Session *session)
313
return session->get_proc_info();
317
void **session_ha_data(const Session *session, const struct handlerton *hton)
319
return (void **) &session->ha_data[hton->slot].ha_ptr;
323
int64_t session_test_options(const Session *session, int64_t test_options)
325
return session->options & test_options;
329
int session_sql_command(const Session *session)
331
return (int) session->lex->sql_command;
335
int session_tx_isolation(const Session *session)
337
return (int) session->variables.tx_isolation;
341
void session_inc_row_count(Session *session)
343
session->row_count++;
347
Clear this diagnostics area.
277
349
Normally called at the end of a statement.
537
void THD::pop_internal_handler()
590
void Session::pop_internal_handler()
539
592
assert(m_internal_handler != NULL);
540
593
m_internal_handler= NULL;
544
void *thd_alloc(DRIZZLE_THD thd, unsigned int size)
546
return thd->alloc(size);
550
void *thd_calloc(DRIZZLE_THD thd, unsigned int size)
552
return thd->calloc(size);
556
char *thd_strdup(DRIZZLE_THD thd, const char *str)
558
return thd->strdup(str);
562
char *thd_strmake(DRIZZLE_THD thd, const char *str, unsigned int size)
564
return thd->strmake(str, size);
568
LEX_STRING *thd_make_lex_string(THD *thd, LEX_STRING *lex_str,
569
const char *str, unsigned int size,
570
int allocate_lex_string)
572
return thd->make_lex_string(lex_str, str, size,
573
(bool) allocate_lex_string);
577
void *thd_memdup(DRIZZLE_THD thd, const void* str, unsigned int size)
579
return thd->memdup(str, size);
583
void thd_get_xid(const DRIZZLE_THD thd, DRIZZLE_XID *xid)
585
*xid = *(DRIZZLE_XID *) &thd->transaction.xid_state.xid;
596
#if defined(__cplusplus)
600
void *session_alloc(Session *session, unsigned int size)
602
return session->alloc(size);
605
void *session_calloc(Session *session, unsigned int size)
607
return session->calloc(size);
610
char *session_strdup(Session *session, const char *str)
612
return session->strdup(str);
615
char *session_strmake(Session *session, const char *str, unsigned int size)
617
return session->strmake(str, size);
620
void *session_memdup(Session *session, const void* str, unsigned int size)
622
return session->memdup(str, size);
625
void session_get_xid(const Session *session, DRIZZLE_XID *xid)
627
*xid = *(DRIZZLE_XID *) &session->transaction.xid_state.xid;
630
#if defined(__cplusplus)
589
635
Init common variables that has to be reset on start and on change_user
638
void Session::init(void)
594
640
pthread_mutex_lock(&LOCK_global_system_variables);
595
plugin_thdvar_init(this);
596
variables.time_format= date_time_format_copy((THD*) 0,
641
plugin_sessionvar_init(this);
642
variables.time_format= date_time_format_copy((Session*) 0,
597
643
variables.time_format);
598
variables.date_format= date_time_format_copy((THD*) 0,
644
variables.date_format= date_time_format_copy((Session*) 0,
599
645
variables.date_format);
600
variables.datetime_format= date_time_format_copy((THD*) 0,
646
variables.datetime_format= date_time_format_copy((Session*) 0,
601
647
variables.datetime_format);
603
649
variables= global_system_variables above has reset
1206
/*****************************************************************************
1207
** Functions to provide a interface to select results
1208
*****************************************************************************/
1210
select_result::select_result()
1215
void select_result::send_error(uint32_t errcode,const char *err)
1217
my_message(errcode, err, MYF(0));
1221
void select_result::cleanup()
1226
bool select_result::check_simple_select() const
1228
my_error(ER_SP_BAD_CURSOR_QUERY, MYF(0));
1233
static String default_line_term("\n",default_charset_info);
1234
static String default_escaped("\\",default_charset_info);
1235
static String default_field_term("\t",default_charset_info);
1237
sql_exchange::sql_exchange(char *name, bool flag,
1238
enum enum_filetype filetype_arg)
1239
:file_name(name), opt_enclosed(0), dumpfile(flag), skip_lines(0)
1241
filetype= filetype_arg;
1242
field_term= &default_field_term;
1243
enclosed= line_start= &my_empty_string;
1244
line_term= &default_line_term;
1245
escaped= &default_escaped;
1249
bool select_send::send_fields(List<Item> &list, uint32_t flags)
1252
if (!(res= thd->protocol->send_fields(&list, flags)))
1253
is_result_set_started= 1;
1257
void select_send::abort()
1264
Cleanup an instance of this class for re-use
1265
at next execution of a prepared statement/
1266
stored procedure statement.
1269
void select_send::cleanup()
1271
is_result_set_started= false;
1274
/* Send data to client. Returns 0 if ok */
1276
bool select_send::send_data(List<Item> &items)
1278
if (unit->offset_limit_cnt)
1279
{ // using limit offset,count
1280
unit->offset_limit_cnt--;
1285
We may be passing the control from mysqld to the client: release the
1286
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
1289
ha_release_temporary_latches(thd);
1291
List_iterator_fast<Item> li(items);
1292
Protocol *protocol= thd->protocol;
1293
char buff[MAX_FIELD_WIDTH];
1294
String buffer(buff, sizeof(buff), &my_charset_bin);
1296
protocol->prepare_for_resend();
1300
if (item->send(protocol, &buffer))
1302
protocol->free(); // Free used buffer
1303
my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0));
1307
thd->sent_row_count++;
1308
if (thd->is_error())
1310
protocol->remove_last_row();
1314
return(protocol->write());
1318
bool select_send::send_eof()
1321
We may be passing the control from mysqld to the client: release the
1322
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
1325
ha_release_temporary_latches(thd);
1327
/* Unlock tables before sending packet to gain some speed */
1330
mysql_unlock_tables(thd, thd->lock);
1334
is_result_set_started= 0;
1339
1233
/************************************************************************
1340
1234
Handling writing to file
1341
1235
************************************************************************/
2082
void thd_increment_bytes_sent(ulong length)
2084
THD *thd=current_thd;
2085
if (likely(thd != 0))
2086
{ /* current_thd==0 when close_connection() calls net_send_error() */
2087
thd->status_var.bytes_sent+= length;
2092
void thd_increment_bytes_received(ulong length)
2094
current_thd->status_var.bytes_received+= length;
2098
void thd_increment_net_big_packet_count(ulong length)
2100
current_thd->status_var.net_big_packet_count+= length;
2103
void THD::send_kill_message() const
1967
void TMP_TABLE_PARAM::cleanup(void)
1969
/* Fix for Intel compiler */
1972
delete [] copy_field;
1973
save_copy_field= copy_field= 0;
1978
void session_increment_bytes_sent(ulong length)
1980
Session *session=current_session;
1981
if (likely(session != 0))
1982
{ /* current_session==0 when close_connection() calls net_send_error() */
1983
session->status_var.bytes_sent+= length;
1988
void session_increment_bytes_received(ulong length)
1990
current_session->status_var.bytes_received+= length;
1994
void session_increment_net_big_packet_count(ulong length)
1996
current_session->status_var.net_big_packet_count+= length;
1999
void Session::send_kill_message() const
2105
2001
int err= killed_errno();
2107
2003
my_message(err, ER(err), MYF(0));
2110
void THD::set_status_var_init()
2006
void Session::set_status_var_init()
2112
2008
memset(&status_var, 0, sizeof(status_var));
2116
void Security_context::init()
2122
void Security_context::destroy()
2124
// If not pointer to constant
2138
2011
void Security_context::skip_grants()
2140
2013
/* privileges for the user are unknown everything is allowed */
2048
bool Session::set_db(const char *new_db, size_t new_db_len)
2050
/* Do not reallocate memory if current chunk is big enough. */
2051
if (db && new_db && db_length >= new_db_len)
2052
memcpy(db, new_db, new_db_len+1);
2059
db= (char *)malloc(new_db_len + 1);
2062
memcpy(db, new_db, new_db_len);
2069
db_length= db ? new_db_len : 0;
2070
return new_db && !db;
2175
2075
Check the killed state of a user thread
2176
@param thd user thread
2076
@param session user thread
2177
2077
@retval 0 the user thread is active
2178
2078
@retval 1 the user thread has been killed
2180
extern "C" int thd_killed(const DRIZZLE_THD thd)
2080
extern "C" int session_killed(const Session *session)
2182
return(thd->killed);
2082
return(session->killed);
2186
2086
Return the thread id of a user thread
2187
@param thd user thread
2087
@param session user thread
2188
2088
@return thread id
2190
extern "C" unsigned long thd_get_thread_id(const DRIZZLE_THD thd)
2192
return((unsigned long)thd->thread_id);
2196
#ifdef INNODB_COMPATIBILITY_HOOKS
2197
extern "C" const struct charset_info_st *thd_charset(DRIZZLE_THD thd)
2199
return(thd->charset());
2202
extern "C" char **thd_query(DRIZZLE_THD thd)
2204
return(&thd->query);
2207
extern "C" int thd_slave_thread(const DRIZZLE_THD thd)
2209
return(thd->slave_thread);
2212
extern "C" int thd_non_transactional_update(const DRIZZLE_THD thd)
2214
return(thd->transaction.all.modified_non_trans_table);
2217
extern "C" int thd_binlog_format(const DRIZZLE_THD thd)
2219
return (int) thd->variables.binlog_format;
2222
extern "C" void thd_mark_transaction_to_rollback(DRIZZLE_THD thd, bool all)
2224
mark_transaction_to_rollback(thd, all);
2226
#endif // INNODB_COMPATIBILITY_HOOKS */
2090
extern "C" unsigned long session_get_thread_id(const Session *session)
2092
return((unsigned long)session->thread_id);
2097
LEX_STRING *session_make_lex_string(Session *session, LEX_STRING *lex_str,
2098
const char *str, unsigned int size,
2099
int allocate_lex_string)
2101
return session->make_lex_string(lex_str, str, size,
2102
(bool) allocate_lex_string);
2105
extern "C" const struct charset_info_st *session_charset(Session *session)
2107
return(session->charset());
2110
extern "C" char **session_query(Session *session)
2112
return(&session->query);
2115
extern "C" int session_non_transactional_update(const Session *session)
2117
return(session->transaction.all.modified_non_trans_table);
2120
extern "C" void session_mark_transaction_to_rollback(Session *session, bool all)
2122
mark_transaction_to_rollback(session, all);
2230
2127
Mark transaction to rollback and mark error as fatal to a sub-statement.
2232
@param thd Thread handle
2129
@param session Thread handle
2233
2130
@param all true <=> rollback main transaction.
2236
void mark_transaction_to_rollback(THD *thd, bool all)
2133
void mark_transaction_to_rollback(Session *session, bool all)
2240
thd->is_fatal_sub_stmt_error= true;
2241
thd->transaction_rollback_request= all;
2137
session->is_fatal_sub_stmt_error= true;
2138
session->transaction_rollback_request= all;
2244
2141
/***************************************************************************
2328
2225
pthread_mutex_unlock(&LOCK_xid_cache);
2332
Implementation of interface to write rows to the binary log through the
2333
thread. The thread is responsible for writing the rows it has
2334
inserted/updated/deleted.
2339
Template member function for ensuring that there is an rows log
2340
event of the apropriate type before proceeding.
2343
- Events of type 'RowEventT' have the type code 'type_code'.
2346
If a non-NULL pointer is returned, the pending event for thread 'thd' will
2347
be an event of type 'RowEventT' (which have the type code 'type_code')
2348
will either empty or have enough space to hold 'needed' bytes. In
2349
addition, the columns bitmap will be correct for the row, meaning that
2350
the pending event will be flushed if the columns in the event differ from
2351
the columns suppled to the function.
2354
If no error, a non-NULL pending event (either one which already existed or
2355
the newly created one).
2359
template <class RowsEventT> Rows_log_event*
2360
THD::binlog_prepare_pending_rows_event(Table* table, uint32_t serv_id,
2362
bool is_transactional,
2363
RowsEventT *hint __attribute__((unused)))
2365
/* Pre-conditions */
2366
assert(table->s->table_map_id != UINT32_MAX);
2368
/* Fetch the type code for the RowsEventT template parameter */
2369
int const type_code= RowsEventT::TYPE_CODE;
2372
There is no good place to set up the transactional data, so we
2375
if (binlog_setup_trx_data())
2378
Rows_log_event* pending= binlog_get_pending_rows_event();
2380
if (unlikely(pending && !pending->is_valid()))
2384
Check if the current event is non-NULL and a write-rows
2385
event. Also check if the table provided is mapped: if it is not,
2386
then we have switched to writing to a new table.
2387
If there is no pending event, we need to create one. If there is a pending
2388
event, but it's not about the same table id, or not of the same type
2389
(between Write, Update and Delete), or not the same affected columns, or
2390
going to be too big, flush this event to disk and create a new pending
2393
The last test is necessary for the Cluster injector to work
2394
correctly. The reason is that the Cluster can inject two write
2395
rows with different column bitmaps if there is an insert followed
2396
by an update in the same transaction, and these are grouped into a
2397
single epoch/transaction when fed to the injector.
2399
TODO: Fix the code so that the last test can be removed.
2402
pending->server_id != serv_id ||
2403
pending->get_table_id() != table->s->table_map_id ||
2404
pending->get_type_code() != type_code ||
2405
pending->get_data_size() + needed > opt_binlog_rows_event_max_size ||
2406
!bitmap_cmp(pending->get_cols(), table->write_set))
2408
/* Create a new RowsEventT... */
2409
Rows_log_event* const
2410
ev= new RowsEventT(this, table, table->s->table_map_id,
2414
ev->server_id= serv_id; // I don't like this, it's too easy to forget.
2416
flush the pending event and replace it with the newly created
2419
if (unlikely(mysql_bin_log.flush_and_set_pending_rows_event(this, ev)))
2425
return(ev); /* This is the new pending event */
2427
return(pending); /* This is the current pending event */
2430
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
2432
Instantiate the versions we need, we have -fno-implicit-template as
2435
template Rows_log_event*
2436
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2437
Write_rows_log_event*);
2439
template Rows_log_event*
2440
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2441
Delete_rows_log_event *);
2443
template Rows_log_event*
2444
THD::binlog_prepare_pending_rows_event(Table*, uint32_t, size_t, bool,
2445
Update_rows_log_event *);
2450
2230
Class to handle temporary allocation of memory for row data.
2562
int THD::binlog_write_row(Table* table, bool is_trans,
2563
unsigned char const *record)
2565
assert(current_stmt_binlog_row_based && mysql_bin_log.is_open());
2568
Pack records into format for transfer. We are allocating more
2569
memory than needed, but that doesn't matter.
2571
Row_data_memory memory(table, table->max_row_length(record));
2572
if (!memory.has_memory())
2573
return HA_ERR_OUT_OF_MEM;
2575
unsigned char *row_data= memory.slot(0);
2577
size_t const len= pack_row(table, table->write_set, row_data, record);
2579
Rows_log_event* const ev=
2580
binlog_prepare_pending_rows_event(table, server_id, len, is_trans,
2581
static_cast<Write_rows_log_event*>(0));
2583
if (unlikely(ev == 0))
2584
return HA_ERR_OUT_OF_MEM;
2586
return ev->add_row_data(row_data, len);
2589
int THD::binlog_update_row(Table* table, bool is_trans,
2590
const unsigned char *before_record,
2591
const unsigned char *after_record)
2593
assert(current_stmt_binlog_row_based && mysql_bin_log.is_open());
2595
size_t const before_maxlen = table->max_row_length(before_record);
2596
size_t const after_maxlen = table->max_row_length(after_record);
2598
Row_data_memory row_data(table, before_maxlen, after_maxlen);
2599
if (!row_data.has_memory())
2600
return HA_ERR_OUT_OF_MEM;
2602
unsigned char *before_row= row_data.slot(0);
2603
unsigned char *after_row= row_data.slot(1);
2605
size_t const before_size= pack_row(table, table->read_set, before_row,
2607
size_t const after_size= pack_row(table, table->write_set, after_row,
2610
Rows_log_event* const ev=
2611
binlog_prepare_pending_rows_event(table, server_id,
2612
before_size + after_size, is_trans,
2613
static_cast<Update_rows_log_event*>(0));
2615
if (unlikely(ev == 0))
2616
return HA_ERR_OUT_OF_MEM;
2619
ev->add_row_data(before_row, before_size) ||
2620
ev->add_row_data(after_row, after_size);
2623
int THD::binlog_delete_row(Table* table, bool is_trans,
2624
unsigned char const *record)
2626
assert(current_stmt_binlog_row_based && mysql_bin_log.is_open());
2629
Pack records into format for transfer. We are allocating more
2630
memory than needed, but that doesn't matter.
2632
Row_data_memory memory(table, table->max_row_length(record));
2633
if (unlikely(!memory.has_memory()))
2634
return HA_ERR_OUT_OF_MEM;
2636
unsigned char *row_data= memory.slot(0);
2638
size_t const len= pack_row(table, table->read_set, row_data, record);
2640
Rows_log_event* const ev=
2641
binlog_prepare_pending_rows_event(table, server_id, len, is_trans,
2642
static_cast<Delete_rows_log_event*>(0));
2644
if (unlikely(ev == 0))
2645
return HA_ERR_OUT_OF_MEM;
2647
return ev->add_row_data(row_data, len);
2651
int THD::binlog_flush_pending_rows_event(bool stmt_end)
2654
We shall flush the pending event even if we are not in row-based
2655
mode: it might be the case that we left row-based mode before
2656
flushing anything (e.g., if we have explicitly locked tables).
2658
if (!mysql_bin_log.is_open())
2662
Mark the event as the last event of a statement if the stmt_end
2666
if (Rows_log_event *pending= binlog_get_pending_rows_event())
2670
pending->set_flags(Rows_log_event::STMT_END_F);
2671
pending->flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
2672
binlog_table_maps= 0;
2675
error= mysql_bin_log.flush_and_set_pending_rows_event(this, 0);
2683
Member function that will log query, either row-based or
2684
statement-based depending on the value of the 'current_stmt_binlog_row_based'
2685
the value of the 'qtype' flag.
2687
This function should be called after the all calls to ha_*_row()
2688
functions have been issued, but before tables are unlocked and
2692
There shall be no writes to any system table after calling
2693
binlog_query(), so these writes has to be moved to before the call
2694
of binlog_query() for correct functioning.
2696
This is necessesary not only for RBR, but the master might crash
2697
after binlogging the query but before changing the system tables.
2698
This means that the slave and the master are not in the same state
2699
(after the master has restarted), so therefore we have to
2700
eliminate this problem.
2703
Error code, or 0 if no error.
2705
int THD::binlog_query(THD::enum_binlog_query_type qtype, char const *query_arg,
2706
ulong query_len, bool is_trans, bool suppress_use,
2707
THD::killed_state killed_status_arg)
2709
assert(query_arg && mysql_bin_log.is_open());
2711
if (int error= binlog_flush_pending_rows_event(true))
2715
If we are in statement mode and trying to log an unsafe statement,
2716
we should print a warning.
2718
if (lex->is_stmt_unsafe() &&
2719
variables.binlog_format == BINLOG_FORMAT_STMT)
2721
assert(this->query != NULL);
2722
push_warning(this, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2723
ER_BINLOG_UNSAFE_STATEMENT,
2724
ER(ER_BINLOG_UNSAFE_STATEMENT));
2725
if (!(binlog_flags & BINLOG_FLAG_UNSAFE_STMT_PRINTED))
2727
char warn_buf[DRIZZLE_ERRMSG_SIZE];
2728
snprintf(warn_buf, DRIZZLE_ERRMSG_SIZE, "%s Statement: %s",
2729
ER(ER_BINLOG_UNSAFE_STATEMENT), this->query);
2730
sql_print_warning(warn_buf);
2731
binlog_flags|= BINLOG_FLAG_UNSAFE_STMT_PRINTED;
2736
case THD::ROW_QUERY_TYPE:
2737
if (current_stmt_binlog_row_based)
2739
/* Otherwise, we fall through */
2740
case THD::DRIZZLE_QUERY_TYPE:
2742
Using this query type is a conveniece hack, since we have been
2743
moving back and forth between using RBR for replication of
2744
system tables and not using it.
2746
Make sure to change in check_table_binlog_row_based() according
2747
to how you treat this.
2749
case THD::STMT_QUERY_TYPE:
2751
The DRIZZLE_LOG::write() function will set the STMT_END_F flag and
2752
flush the pending rows event if necessary.
2755
Query_log_event qinfo(this, query_arg, query_len, is_trans, suppress_use,
2757
qinfo.flags|= LOG_EVENT_UPDATE_TABLE_MAP_VERSION_F;
2759
Binlog table maps will be irrelevant after a Query_log_event
2760
(they are just removed on the slave side) so after the query
2761
log event is written to the binary log, we pretend that no
2762
table maps were written.
2764
int error= mysql_bin_log.write(&qinfo);
2765
binlog_table_maps= 0;
2770
case THD::QUERY_TYPE_COUNT:
2772
assert(0 <= qtype && qtype < QUERY_TYPE_COUNT);
2777
2341
bool Discrete_intervals_list::append(uint64_t start, uint64_t val,
2370
@param session Thread handle
2371
@param errcode Error code to print to console
2372
@param should_lock 1 if we have have to lock LOCK_thread_count
2375
For the connection that is doing shutdown, this is called twice
2377
void Session::close_connection(uint32_t errcode, bool should_lock)
2381
(void) pthread_mutex_lock(&LOCK_thread_count);
2382
killed= Session::KILL_CONNECTION;
2383
if ((vio= net.vio) != 0)
2386
net_send_error(this, errcode, ER(errcode)); /* purecov: inspected */
2387
net_close(&net); /* vio is freed in delete session */
2390
(void) pthread_mutex_unlock(&LOCK_thread_count);
2396
Reset Session part responsible for command processing state.
2398
This needs to be called before execution of every statement
2399
(prepared or conventional).
2400
It is not called by substatements of routines.
2403
Make it a method of Session and align its name with the rest of
2404
reset/end/start/init methods.
2406
Call it after we use Session for queries, not before.
2409
void Session::reset_for_next_command()
2414
Those two lines below are theoretically unneeded as
2415
Session::cleanup_after_query() should take care of this already.
2417
auto_inc_intervals_in_cur_stmt_for_binlog.empty();
2420
server_status&= ~ (SERVER_MORE_RESULTS_EXISTS |
2421
SERVER_QUERY_NO_INDEX_USED |
2422
SERVER_QUERY_NO_GOOD_INDEX_USED);
2424
If in autocommit mode and not in a transaction, reset
2425
OPTION_STATUS_NO_TRANS_UPDATE | OPTION_KEEP_LOG to not get warnings
2426
in ha_rollback_trans() about some tables couldn't be rolled back.
2428
if (!(options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))
2430
options&= ~OPTION_KEEP_LOG;
2431
transaction.all.modified_non_trans_table= false;
2433
thread_specific_used= false;
2436
main_da.reset_diagnostics_area();
2437
total_warn_count=0; // Warnings for this query
2438
sent_row_count= examined_row_count= 0;
2445
return true if the table was created explicitly.
2447
inline bool is_user_table(Table * table)
2449
const char *name= table->s->table_name.str;
2450
return strncmp(name, TMP_FILE_PREFIX, TMP_FILE_PREFIX_LENGTH);
2454
Close all temporary tables created by 'CREATE TEMPORARY TABLE' for thread
2455
creates one DROP TEMPORARY Table binlog event for each pseudo-thread
2458
void Session::close_temporary_tables()
2463
if (!temporary_tables)
2466
for (table= temporary_tables; table; table= tmp_next)
2468
tmp_next= table->next;
2469
close_temporary(table, 1, 1);
2471
temporary_tables= 0;