426
390
the Session of that thread); that thread is (and must remain, for now) the
427
391
only responsible for freeing this member.
399
/* This constructor is called for backup statements */
402
Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg, ulong id_arg);
406
struct st_savepoint {
407
struct st_savepoint *prev;
410
Ha_trx_info *ha_list;
413
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
414
extern const char *xa_state_names[];
416
typedef struct st_xid_state {
417
/* For now, this is only used to catch duplicated external xids */
418
XID xid; // transaction identifier
419
enum xa_states xa_state; // used by external XA only
423
extern pthread_mutex_t LOCK_xid_cache;
424
extern HASH xid_cache;
425
bool xid_cache_init(void);
426
void xid_cache_free(void);
427
XID_STATE *xid_cache_search(XID *xid);
428
bool xid_cache_insert(XID *xid, enum xa_states xa_state);
429
bool xid_cache_insert(XID_STATE *xid_state);
430
void xid_cache_delete(XID_STATE *xid_state);
433
@class Security_context
434
@brief A set of Session members describing the current authenticated user.
437
class Security_context {
439
Security_context() {}
441
host - host of the client
442
user - user of the client, set to NULL until the user has been read from
444
priv_user - The user privilege we are using. May be "" for anonymous user.
451
inline const char *priv_host_name()
453
return (ip.c_str() ? ip.c_str() : (char *)"%");
459
A registry for item tree transformations performed during
460
query optimization. We register only those changes which require
461
a rollback to re-execute a prepared statement or stored procedure
465
struct Item_change_record;
466
typedef I_List<Item_change_record> Item_change_list;
470
Class that holds information about tables which were opened and locked
471
by the thread. It is also used to save/restore this information in
472
push_open_tables_state()/pop_open_tables_state().
475
class Open_tables_state
479
List of regular tables in use by this thread. Contains temporary and
480
base tables that were opened with @see open_tables().
484
List of temporary tables used by this thread. Contains user-level
485
temporary tables, created with CREATE TEMPORARY TABLE, and
486
internal temporary tables, created, e.g., to resolve a SELECT,
487
or for an intermediate table used in ALTER.
488
XXX Why are internal temporary tables added to this list?
490
Table *temporary_tables;
492
List of tables that were opened with HANDLER OPEN and are
493
still in use by this thread.
495
Table *handler_tables;
496
Table *derived_tables;
498
During a MySQL session, one can lock tables in two modes: automatic
499
or manual. In automatic mode all necessary tables are locked just before
500
statement execution, and all acquired locks are stored in 'lock'
501
member. Unlocking takes place automatically as well, when the
503
Manual mode comes into play when a user issues a 'LOCK TABLES'
504
statement. In this mode the user can only use the locked tables.
505
Trying to use any other tables will give an error. The locked tables are
506
stored in 'locked_tables' member. Manual locking is described in
507
the 'LOCK_TABLES' chapter of the MySQL manual.
508
See also lock_tables() for details.
512
Tables that were locked with explicit or implicit LOCK TABLES.
513
(Implicit LOCK TABLES happens when we are prelocking tables for
514
execution of statement which uses stored routines. See description
515
Session::prelocked_mode for more info.)
517
DRIZZLE_LOCK *locked_tables;
520
CREATE-SELECT keeps an extra lock for the table being
521
created. This field is used to keep the extra lock available for
522
lower level routines, which would otherwise miss that lock.
524
DRIZZLE_LOCK *extra_lock;
527
uint32_t current_tablenr;
530
BACKUPS_AVAIL = (1U << 0) /* There are backups available */
534
Flags with information about the open tables state.
536
uint32_t state_flags;
539
This constructor serves for creation of Open_tables_state instances
540
which are used as backup storage.
542
Open_tables_state() : state_flags(0U) { }
544
Open_tables_state(ulong version_arg);
546
void set_open_tables_state(Open_tables_state *state)
551
void reset_open_tables_state()
553
open_tables= temporary_tables= handler_tables= derived_tables= 0;
554
extra_lock= lock= locked_tables= 0;
560
/* Flags for the Session::system_thread variable */
561
enum enum_thread_type
564
SYSTEM_THREAD_SLAVE_IO,
565
SYSTEM_THREAD_SLAVE_SQL
570
This class represents the interface for internal error handlers.
571
Internal error handlers are exception handlers used by the server
574
class Internal_error_handler
577
Internal_error_handler() {}
578
virtual ~Internal_error_handler() {}
582
Handle an error condition.
583
This method can be implemented by a subclass to achieve any of the
585
- mask an error internally, prevent exposing it to the user,
586
- mask an error and throw another one instead.
587
When this method returns true, the error condition is considered
588
'handled', and will not be propagated to upper layers.
589
It is the responsability of the code installing an internal handler
590
to then check for trapped conditions, and implement logic to recover
591
from the anticipated conditions trapped during runtime.
593
This mechanism is similar to C++ try/throw/catch:
594
- 'try' correspond to <code>Session::push_internal_handler()</code>,
595
- 'throw' correspond to <code>my_error()</code>,
596
which invokes <code>my_message_sql()</code>,
597
- 'catch' correspond to checking how/if an internal handler was invoked,
598
before removing it from the exception stack with
599
<code>Session::pop_internal_handler()</code>.
601
@param sql_errno the error number
602
@param level the error level
603
@param session the calling thread
604
@return true if the error is handled
606
virtual bool handle_error(uint32_t sql_errno,
608
DRIZZLE_ERROR::enum_warning_level level,
609
Session *session) = 0;
614
Stores status of the currently executed statement.
615
Cleared at the beginning of the statement, and then
616
can hold either OK, ERROR, or EOF status.
617
Can not be assigned twice per statement.
620
class Diagnostics_area
623
enum enum_diagnostics_status
625
/** The area is cleared at start of a statement. */
627
/** Set whenever one calls my_ok(). */
629
/** Set whenever one calls my_eof(). */
631
/** Set whenever one calls my_error() or my_message(). */
633
/** Set in case of a custom response, such as one from COM_STMT_PREPARE. */
636
/** True if status information is sent to the client. */
638
/** Set to make set_error_status after set_{ok,eof}_status possible. */
639
bool can_overwrite_status;
641
void set_ok_status(Session *session, ha_rows affected_rows_arg,
642
uint64_t last_insert_id_arg,
643
const char *message);
644
void set_eof_status(Session *session);
645
void set_error_status(Session *session, uint32_t sql_errno_arg, const char *message_arg);
647
void disable_status();
649
void reset_diagnostics_area();
651
bool is_set() const { return m_status != DA_EMPTY; }
652
bool is_error() const { return m_status == DA_ERROR; }
653
bool is_eof() const { return m_status == DA_EOF; }
654
bool is_ok() const { return m_status == DA_OK; }
655
bool is_disabled() const { return m_status == DA_DISABLED; }
656
enum_diagnostics_status status() const { return m_status; }
658
const char *message() const
659
{ assert(m_status == DA_ERROR || m_status == DA_OK); return m_message; }
661
uint32_t sql_errno() const
662
{ assert(m_status == DA_ERROR); return m_sql_errno; }
664
uint32_t server_status() const
666
assert(m_status == DA_OK || m_status == DA_EOF);
667
return m_server_status;
670
ha_rows affected_rows() const
671
{ assert(m_status == DA_OK); return m_affected_rows; }
673
uint64_t last_insert_id() const
674
{ assert(m_status == DA_OK); return m_last_insert_id; }
676
uint32_t total_warn_count() const
678
assert(m_status == DA_OK || m_status == DA_EOF);
679
return m_total_warn_count;
682
Diagnostics_area() { reset_diagnostics_area(); }
685
/** Message buffer. Can be used by OK or ERROR status. */
686
char m_message[DRIZZLE_ERRMSG_SIZE];
688
SQL error number. One of ER_ codes from share/errmsg.txt.
689
Set by set_error_status.
691
uint32_t m_sql_errno;
694
Copied from session->server_status when the diagnostics area is assigned.
695
We need this member as some places in the code use the following pattern:
696
session->server_status|= ...
698
session->server_status&= ~...
699
Assigned by OK, EOF or ERROR.
701
uint32_t m_server_status;
703
The number of rows affected by the last statement. This is
704
semantically close to session->row_count_func, but has a different
705
life cycle. session->row_count_func stores the value returned by
706
function ROW_COUNT() and is cleared only by statements that
707
update its value, such as INSERT, UPDATE, DELETE and few others.
708
This member is cleared at the beginning of the next statement.
710
We could possibly merge the two, but life cycle of session->row_count_func
713
ha_rows m_affected_rows;
715
Similarly to the previous member, this is a replacement of
716
session->first_successful_insert_id_in_prev_stmt, which is used
717
to implement LAST_INSERT_ID().
719
uint64_t m_last_insert_id;
720
/** The total number of warnings. */
721
uint m_total_warn_count;
722
enum_diagnostics_status m_status;
724
@todo: the following Session members belong here:
725
- warn_list, warn_count,
731
Storage engine specific thread local data.
737
Storage engine specific thread local data.
738
Lifetime: one user connection.
742
0: Life time: one statement within a transaction. If @@autocommit is
743
on, also represents the entire transaction.
744
@sa trans_register_ha()
746
1: Life time: one transaction within a connection.
747
If the storage engine does not participate in a transaction,
748
this should not be used.
749
@sa trans_register_ha()
751
Ha_trx_info ha_info[2];
753
Ha_data() :ha_ptr(NULL) {}
759
For each client connection we create a separate thread with Session serving as
760
a thread/connection descriptor
763
class Session :public Statement,
764
public Open_tables_state
432
768
Constant for Session::where initialization in the beginning of every query.
434
770
It's needed because we do not save/restore Session::where normally during
611
966
in the binlog is still needed; the list's minimum will contain 3.
613
968
Discrete_intervals_list auto_inc_intervals_in_cur_stmt_for_binlog;
614
/** Used by replication and SET INSERT_ID */
969
/* Used by replication and SET INSERT_ID */
615
970
Discrete_intervals_list auto_inc_intervals_forced;
617
uint64_t limit_found_rows;
618
uint64_t options; /**< Bitmap of options */
619
int64_t row_count_func; /**< For the ROW_COUNT() function */
620
ha_rows cuted_fields; /**< Count of "cut" or truncated fields. @todo Kill this friggin thing. */
623
* Number of rows we actually sent to the client, including "synthetic"
624
* rows in ROLLUP etc.
626
ha_rows sent_row_count;
629
* Number of rows we read, sent or not, including in create_sort_index()
631
ha_rows examined_row_count;
634
* The set of those tables whose fields are referenced in all subqueries
639
* Possibly this it is incorrect to have used tables in Session because
640
* with more than one subquery, it is not clear what does the field mean.
642
table_map used_tables;
647
This, and some other variables like 'count_cuted_fields'
648
maybe should be statement/cursor local, that is, moved to Statement
649
class. With current implementation warnings produced in each prepared
650
statement/cursor settle here.
652
List<DRIZZLE_ERROR> warn_list;
653
uint32_t warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_END];
654
uint32_t total_warn_count;
655
Diagnostics_area main_da;
659
/* Statement id is thread-wide. This counter is used to generate ids */
660
uint32_t statement_id_counter;
661
uint32_t rand_saved_seed1;
662
uint32_t rand_saved_seed2;
664
Row counter, mainly for errors and warnings. Not increased in
665
create_sort_index(); may differ from examined_row_count.
668
pthread_t real_id; /**< For debugging */
671
uint32_t global_read_lock;
672
uint32_t server_status;
673
uint32_t open_options;
674
uint32_t select_number; /**< number of select (used for EXPLAIN) */
675
/* variables.transaction_isolation is reset to this after each commit */
676
enum_tx_isolation session_tx_isolation;
677
enum_check_fields count_cuted_fields;
685
KILLED_NO_VALUE /* means none of the above states apply */
687
killed_state volatile killed;
689
bool some_tables_deleted;
693
Set to true if execution of the current compound statement
694
can not continue. In particular, disables activation of
695
CONTINUE or EXIT handlers of stored routines.
696
Reset in the end of processing of the current user request, in
697
@see mysql_reset_session_for_next_command().
701
Set by a storage engine to request the entire
702
transaction (that possibly spans multiple engines) to
703
rollback. Reset in ha_rollback.
705
bool transaction_rollback_request;
707
true if we are in a sub-statement and the current error can
708
not be safely recovered until we left the sub-statement mode.
709
In particular, disables activation of CONTINUE and EXIT
710
handlers inside sub-statements. E.g. if it is a deadlock
711
error and requires a transaction-wide rollback, this flag is
712
raised (traditionally, MySQL first has to close all the reads
713
via @see handler::ha_index_or_rnd_end() and only then perform
715
Reset to false when we leave the sub-statement mode.
717
bool is_fatal_sub_stmt_error;
718
/** for IS NULL => = last_insert_id() fix in remove_eq_conds() */
719
bool substitute_null_with_insert_id;
722
bool abort_on_warning;
723
bool got_warning; /**< Set on call to push_warning() */
724
bool no_warnings_for_error; /**< no warnings on call to my_error() */
725
/** set during loop of derived table processing */
726
bool derived_tables_processing;
727
bool tablespace_op; /**< This is true in DISCARD/IMPORT TABLESPACE */
729
/** Used by the sys_var class to store temporary values */
733
uint32_t uint32_t_value;
734
int32_t int32_t_value;
735
uint64_t uint64_t_value;
739
Character input stream consumed by the lexical analyser,
741
Note that since the parser is not re-entrant, we keep only one input
742
stream here. This member is valid only when executing code during parsing,
743
and may point to invalid memory after that.
745
Lex_input_stream *m_lip;
747
/** Place to store various things */
748
void *session_marker;
750
/** Keeps a copy of the previous table around in case we are just slamming on particular table */
754
Points to info-string that we show in SHOW PROCESSLIST
755
You are supposed to call Session_SET_PROC_INFO only if you have coded
756
a time-consuming piece that MySQL can get stuck in for a long time.
758
Set it using the session_proc_info(Session *thread, const char *message)
761
inline void set_proc_info(const char *info)
765
inline const char* get_proc_info() const
770
/** Sets this Session's current query ID */
771
inline void setQueryId(query_id_t in_query_id)
773
query_id= in_query_id;
776
/** Returns the current query ID */
777
inline query_id_t getQueryId() const
783
/** Sets this Session's warning query ID */
784
inline void setWarningQueryId(query_id_t in_query_id)
786
warn_query_id= in_query_id;
789
/** Returns the Session's warning query ID */
790
inline query_id_t getWarningQueryId() const
792
return warn_query_id;
795
/** Returns the current query text */
796
inline const std::string &getQueryString() const
801
/** Returns the length of the current query text */
802
inline size_t getQueryLength() const
805
return query.length();
810
/** Accessor method returning the session's ID. */
811
inline uint64_t getSessionId() const
816
/** Accessor method returning the server's ID. */
817
inline uint32_t getServerId() const
819
/* We return the global server ID. */
823
/** Returns the current transaction ID for the session's current statement */
824
inline my_xid getTransactionId()
826
return transaction.xid_state.xid.quick_get_my_xid();
829
972
There is BUG#19630 where statement-based replication of stored
830
973
functions/triggers with two auto_increment columns breaks.
831
974
We however ensure that it works when there is 0 or 1 auto_increment
881
1024
auto_inc_intervals_forced.append(next_id, UINT64_MAX, 0);
884
Session(plugin::Client *client_arg);
1027
uint64_t limit_found_rows;
1028
uint64_t options; /* Bitmap of states */
1029
int64_t row_count_func; /* For the ROW_COUNT() function */
1030
ha_rows cuted_fields;
1033
number of rows we actually sent to the client, including "synthetic"
1036
ha_rows sent_row_count;
1039
number of rows we read, sent or not, including in create_sort_index()
1041
ha_rows examined_row_count;
1044
The set of those tables whose fields are referenced in all subqueries
1046
TODO: possibly this it is incorrect to have used tables in Session because
1047
with more than one subquery, it is not clear what does the field mean.
1049
table_map used_tables;
1050
USER_CONN *user_connect;
1051
const CHARSET_INFO *db_charset;
1053
FIXME: this, and some other variables like 'count_cuted_fields'
1054
maybe should be statement/cursor local, that is, moved to Statement
1055
class. With current implementation warnings produced in each prepared
1056
statement/cursor settle here.
1058
List <DRIZZLE_ERROR> warn_list;
1059
uint warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_END];
1060
uint total_warn_count;
1061
Diagnostics_area main_da;
1064
Id of current query. Statement can be reused to execute several queries
1065
query_id is global in context of the whole MySQL server.
1066
ID is automatically generated from mutex-protected counter.
1067
It's used in handler code for various purposes: to check which columns
1068
from table are necessary for this select, to check if it's necessary to
1069
update auto-updatable fields (like auto_increment and timestamp).
1071
query_id_t query_id, warn_id;
1074
#ifdef ERROR_INJECT_SUPPORT
1075
ulong error_inject_value;
1077
/* Statement id is thread-wide. This counter is used to generate ids */
1078
ulong statement_id_counter;
1079
ulong rand_saved_seed1, rand_saved_seed2;
1081
Row counter, mainly for errors and warnings. Not increased in
1082
create_sort_index(); may differ from examined_row_count.
1085
pthread_t real_id; /* For debugging */
1086
my_thread_id thread_id;
1087
uint tmp_table, global_read_lock;
1088
uint server_status,open_options;
1089
enum enum_thread_type system_thread;
1090
uint32_t select_number; //number of select (used for EXPLAIN)
1091
/* variables.transaction_isolation is reset to this after each commit */
1092
enum_tx_isolation session_tx_isolation;
1093
enum_check_fields count_cuted_fields;
1095
DYNAMIC_ARRAY user_var_events; /* For user variables replication */
1096
MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
1104
KILLED_NO_VALUE /* means neither of the states */
1106
killed_state volatile killed;
1108
/* scramble - random string sent to client on handshake */
1109
char scramble[SCRAMBLE_LENGTH+1];
1112
bool some_tables_deleted;
1113
bool last_cuted_field;
1114
bool no_errors, password;
1116
Set to true if execution of the current compound statement
1117
can not continue. In particular, disables activation of
1118
CONTINUE or EXIT handlers of stored routines.
1119
Reset in the end of processing of the current user request, in
1120
@see mysql_reset_session_for_next_command().
1122
bool is_fatal_error;
1124
Set by a storage engine to request the entire
1125
transaction (that possibly spans multiple engines) to
1126
rollback. Reset in ha_rollback.
1128
bool transaction_rollback_request;
1130
true if we are in a sub-statement and the current error can
1131
not be safely recovered until we left the sub-statement mode.
1132
In particular, disables activation of CONTINUE and EXIT
1133
handlers inside sub-statements. E.g. if it is a deadlock
1134
error and requires a transaction-wide rollback, this flag is
1135
raised (traditionally, MySQL first has to close all the reads
1136
via @see handler::ha_index_or_rnd_end() and only then perform
1138
Reset to false when we leave the sub-statement mode.
1140
bool is_fatal_sub_stmt_error;
1141
/* for IS NULL => = last_insert_id() fix in remove_eq_conds() */
1142
bool substitute_null_with_insert_id;
1143
bool in_lock_tables;
1145
True if a slave error. Causes the slave to stop. Not the same
1146
as the statement execution error (is_error()), since
1147
a statement may be expected to return an error, e.g. because
1148
it returned an error on master, and this is OK on the slave.
1150
bool is_slave_error;
1153
/** is set if some thread specific value(s) used in a statement. */
1154
bool thread_specific_used;
1155
bool charset_is_system_charset, charset_is_collation_connection;
1156
bool charset_is_character_set_filesystem;
1157
bool abort_on_warning;
1158
bool got_warning; /* Set on call to push_warning() */
1159
bool no_warnings_for_error; /* no warnings on call to my_error() */
1160
/* set during loop of derived table processing */
1161
bool derived_tables_processing;
1162
bool tablespace_op; /* This is true in DISCARD/IMPORT TABLESPACE */
1164
/* Used by the sys_var class to store temporary values */
1170
uint64_t uint64_t_value;
1175
If true, drizzle_bin_log::write(Log_event) call will not write events to
1176
binlog, and maintain 2 below variables instead (use
1177
drizzle_bin_log.start_union_events to turn this on)
1181
If true, at least one drizzle_bin_log::write(Log_event) call has been
1182
made after last drizzle_bin_log.start_union_events() call.
1184
bool unioned_events;
1186
If true, at least one drizzle_bin_log::write(Log_event e), where
1187
e.cache_stmt == true call has been made after last
1188
drizzle_bin_log.start_union_events() call.
1190
bool unioned_events_trans;
1193
'queries' (actually SP statements) that run under inside this binlog
1194
union have session->query_id >= first_query_id.
1196
query_id_t first_query_id;
1200
Character input stream consumed by the lexical analyser,
1201
used during parsing.
1202
Note that since the parser is not re-entrant, we keep only one input
1203
stream here. This member is valid only when executing code during parsing,
1204
and may point to invalid memory after that.
1206
Lex_input_stream *m_lip;
1213
Initialize memory roots necessary for query processing and (!)
1214
pre-allocate memory for it. We can't do that in Session constructor because
1215
there are use cases (acl_init, watcher threads,
1216
killing mysqld) where it's vital to not allocate excessive and not used
1217
memory. Note, that we still don't return error from init_for_queries():
1218
if preallocation fails, we should notice that at the first call to
1221
void init_for_queries();
887
1222
void cleanup(void);
889
* Cleans up after query.
893
* This function is used to reset thread data to its default state.
895
* This function is not suitable for setting thread data to some
896
* non-default values, as there is only one replication thread, so
897
* different master threads may overwrite data of each other on
900
1223
void cleanup_after_query();
1224
bool store_globals();
902
1225
void awake(Session::killed_state state_to_set);
904
* Pulls thread-specific variables into Session state.
906
* Returns true most times, or false if there was a problem
907
* allocating resources for thread-specific storage.
909
* @TODO Kill this. It's not necessary once my_thr_init() is bye bye.
915
Initialize memory roots necessary for query processing and (!)
916
pre-allocate memory for it. We can't do that in Session constructor because
917
there are use cases where it's vital to not allocate excessive and not used
920
void prepareForQueries();
923
* Executes a single statement received from the
926
* Returns true if the statement was successful, or false
931
* For profiling to work, it must never be called recursively.
933
* In MySQL, this used to be the do_command() C function whic
934
* accepted a single parameter of the THD pointer.
936
bool executeStatement();
939
* Reads a query from packet and stores it.
941
* Returns true if query is read and allocated successfully,
942
* false otherwise. On a return of false, Session::fatal_error
945
* @note Used in COM_QUERY and COM_STMT_PREPARE.
947
* Sets the following Session variables:
951
* @param The packet pointer to read from
952
* @param The length of the query to read
954
bool readAndStoreQuery(const char *in_packet, uint32_t in_packet_length);
957
* Ends the current transaction and (maybe) begins the next.
959
* Returns true if the transaction completed successfully,
962
* @param Completion type
964
bool endTransaction(enum enum_mysql_completiontype completion);
965
bool endActiveTransaction();
966
bool startTransaction(start_transaction_option_t opt= START_TRANS_NO_OPTIONS);
969
* Authenticates users, with error reporting.
971
* Returns true on success, or false on failure.
978
* This will initialize the session and begin the command loop.
983
* Schedule a session to be run on the default scheduler.
988
1228
For enter_cond() / exit_cond() to work the mutex must be got before
989
1229
enter_cond(); this mutex is then released by exit_cond().
990
1230
Usage must be: lock mutex; enter_cond(); your code; exit_cond().
992
const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex, const char* msg);
993
void exit_cond(const char* old_msg);
1232
inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex,
1235
const char* old_msg = get_proc_info();
1236
safe_mutex_assert_owner(mutex);
1237
mysys_var->current_mutex = mutex;
1238
mysys_var->current_cond = cond;
1239
this->set_proc_info(msg);
1242
inline void exit_cond(const char* old_msg)
1245
Putting the mutex unlock in exit_cond() ensures that
1246
mysys_var->current_mutex is always unlocked _before_ mysys_var->mutex is
1247
locked (if that would not be the case, you'll get a deadlock if someone
1248
does a Session::awake() on you).
1250
pthread_mutex_unlock(mysys_var->current_mutex);
1251
pthread_mutex_lock(&mysys_var->mutex);
1252
mysys_var->current_mutex = 0;
1253
mysys_var->current_cond = 0;
1254
this->set_proc_info(old_msg);
1255
pthread_mutex_unlock(&mysys_var->mutex);
995
1257
inline time_t query_start() { return start_time; }
996
1258
inline void set_time()
1000
1262
start_time= user_time;
1001
connect_microseconds= start_utime= utime_after_lock= my_micro_time();
1263
start_utime= utime_after_lock= my_micro_time();
1004
1266
start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
1273
1475
- for prepared queries, only to allocate runtime data. The parsed
1274
1476
tree itself is reused between executions and thus is stored elsewhere.
1276
memory::Root main_mem_root;
1279
* Marks all tables in the list which were used by current substatement
1280
* as free for reuse.
1282
* @param Head of the list of tables
1286
* The reason we reset query_id is that it's not enough to just test
1287
* if table->query_id != session->query_id to know if a table is in use.
1291
* SELECT f1_that_uses_t1() FROM t1;
1293
* In f1_that_uses_t1() we will see one instance of t1 where query_id is
1294
* set to query_id of original query.
1296
void mark_used_tables_as_free_for_reuse(Table *table);
1298
Mark all temporary tables which were used by the current statement or
1299
substatement as free for reuse, but only if the query_id can be cleared.
1301
@param session thread context
1303
@remark For temp tables associated with a open SQL HANDLER the query_id
1304
is not reset until the HANDLER is closed.
1306
void mark_temp_tables_as_free_for_reuse();
1310
/** A short cut for session->main_da.set_ok_status(). */
1311
inline void my_ok(ha_rows affected_rows= 0, ha_rows found_rows_arg= 0,
1312
uint64_t passed_id= 0, const char *message= NULL)
1314
main_da.set_ok_status(this, affected_rows, found_rows_arg, passed_id, message);
1318
/** A short cut for session->main_da.set_eof_status(). */
1320
inline void my_eof()
1322
main_da.set_eof_status(this);
1325
/* Some inline functions for more speed */
1327
inline bool add_item_to_list(Item *item)
1329
return lex->current_select->add_item_to_list(this, item);
1332
inline bool add_value_to_list(Item *value)
1334
return lex->value_list.push_back(value);
1337
inline bool add_order_to_list(Item *item, bool asc)
1339
return lex->current_select->add_order_to_list(this, item, asc);
1342
inline bool add_group_to_list(Item *item, bool asc)
1344
return lex->current_select->add_group_to_list(this, item, asc);
1346
void refresh_status();
1347
user_var_entry *getVariable(LEX_STRING &name, bool create_if_not_exists);
1350
* Closes all tables used by the current substatement, or all tables
1351
* used by this thread if we are on the upper level.
1353
void close_thread_tables();
1354
void close_old_data_files(bool morph_locks= false,
1355
bool send_refresh= false);
1356
void close_open_tables();
1357
void close_data_files_and_morph_locks(TableIdentifier &identifier);
1358
void close_data_files_and_morph_locks(const char *db, const char *table_name);
1361
bool free_cached_table();
1365
* Prepares statement for reopening of tables and recalculation of set of
1368
* @param Pointer to a pointer to a list of tables which we were trying to open and lock
1370
void close_tables_for_reopen(TableList **tables);
1374
* Open all tables in list, locks them (all, including derived)
1376
* @param Pointer to a list of tables for open & locking
1385
* The lock will automaticaly be freed by close_thread_tables()
1387
bool openTablesLock(TableList *tables);
1390
* Open all tables in list and process derived tables
1392
* @param Pointer to a list of tables for open
1393
* @param Bitmap of flags to modify how the tables will be open:
1394
* DRIZZLE_LOCK_IGNORE_FLUSH - open table even if someone has
1395
* done a flush or namelock on it.
1404
* This is to be used on prepare stage when you don't read any
1405
* data from the tables.
1407
bool openTables(TableList *tables, uint32_t flags= 0);
1409
int open_tables_from_list(TableList **start, uint32_t *counter, uint32_t flags= 0);
1411
Table *openTableLock(TableList *table_list, thr_lock_type lock_type);
1412
Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1414
void unlink_open_table(Table *find);
1415
void drop_open_table(Table *table, TableIdentifier &identifier);
1416
void close_cached_table(Table *table);
1418
/* Create a lock in the cache */
1419
Table *table_cache_insert_placeholder(const char *key, uint32_t key_length);
1420
bool lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table);
1421
bool lock_table_name_if_not_cached(const char *db,
1422
const char *table_name, Table **table);
1424
typedef drizzled::hash_map<std::string, message::Table> TableMessageCache;
1425
TableMessageCache table_message_cache;
1427
bool storeTableMessage(TableIdentifier &identifier, message::Table &table_message);
1428
bool removeTableMessage(TableIdentifier &identifier);
1429
bool getTableMessage(TableIdentifier &identifier, message::Table &table_message);
1430
bool doesTableMessageExist(TableIdentifier &identifier);
1431
bool renameTableMessage(TableIdentifier &from, TableIdentifier &to);
1433
/* Work with temporary tables */
1434
Table *find_temporary_table(TableList *table_list);
1435
Table *find_temporary_table(const char *db, const char *table_name);
1436
Table *find_temporary_table(TableIdentifier &identifier);
1438
void doGetTableNames(CachedDirectory &directory,
1439
SchemaIdentifier &schema_identifier,
1440
std::set<std::string>& set_of_names);
1441
void doGetTableNames(SchemaIdentifier &schema_identifier,
1442
std::set<std::string>& set_of_names);
1444
void doGetTableIdentifiers(CachedDirectory &directory,
1445
SchemaIdentifier &schema_identifier,
1446
TableIdentifiers &set_of_identifiers);
1447
void doGetTableIdentifiers(SchemaIdentifier &schema_identifier,
1448
TableIdentifiers &set_of_identifiers);
1450
int doGetTableDefinition(drizzled::TableIdentifier &identifier,
1451
message::Table &table_proto);
1452
bool doDoesTableExist(TableIdentifier &identifier);
1454
void close_temporary_tables();
1455
void close_temporary_table(Table *table);
1456
// The method below just handles the de-allocation of the table. In
1457
// a better memory type world, this would not be needed.
1459
void nukeTable(Table *table);
1462
void dumpTemporaryTableNames(const char *id);
1463
int drop_temporary_table(TableList *table_list);
1464
bool rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier);
1465
bool rm_temporary_table(TableIdentifier &identifier);
1466
Table *open_temporary_table(TableIdentifier &identifier,
1467
bool link_in_list= true);
1469
/* Reopen operations */
1470
bool reopen_tables(bool get_locks, bool mark_share_as_old);
1471
bool reopen_name_locked_table(TableList* table_list, bool link_in);
1472
bool close_cached_tables(TableList *tables, bool wait_for_refresh, bool wait_for_placeholders);
1474
void wait_for_condition(pthread_mutex_t *mutex, pthread_cond_t *cond);
1475
int setup_conds(TableList *leaves, COND **conds);
1476
int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1480
Return the default storage engine
1482
@param getDefaultStorageEngine()
1485
pointer to plugin::StorageEngine
1487
plugin::StorageEngine *getDefaultStorageEngine()
1489
if (variables.storage_engine)
1490
return variables.storage_engine;
1491
return global_system_variables.storage_engine;
1494
static void unlink(Session *session);
1478
MEM_ROOT main_mem_root;
1483
/** A short cut for session->main_da.set_ok_status(). */
1486
my_ok(Session *session, ha_rows affected_rows= 0, uint64_t id= 0,
1487
const char *message= NULL)
1489
session->main_da.set_ok_status(session, affected_rows, id, message);
1493
/** A short cut for session->main_da.set_eof_status(). */
1496
my_eof(Session *session)
1498
session->main_da.set_eof_status(session);
1501
#define tmp_disable_binlog(A) \
1502
{uint64_t tmp_disable_binlog__save_options= (A)->options; \
1503
(A)->options&= ~OPTION_BIN_LOG
1505
#define reenable_binlog(A) (A)->options= tmp_disable_binlog__save_options;}
1509
Used to hold information about file and file structure in exchange
1510
via non-DB file (...INTO OUTFILE..., ...LOAD DATA...)
1511
XXX: We never call destructor for objects of this class.
1514
class sql_exchange :public Sql_alloc
1517
enum enum_filetype filetype; /* load XML, Added by Arnold & Erik */
1519
String *field_term,*enclosed,*line_term,*line_start,*escaped;
1523
const CHARSET_INFO *cs;
1524
sql_exchange(char *name, bool dumpfile_flag,
1525
enum_filetype filetype_arg= FILETYPE_CSV);
1529
This is used to get result from a select
1534
class select_result :public Sql_alloc {
1537
SELECT_LEX_UNIT *unit;
1540
virtual ~select_result() {};
1541
virtual int prepare(List<Item> &,
1547
virtual int prepare2(void) { return 0; }
1549
Because of peculiarities of prepared statements protocol
1550
we need to know number of columns in the result set (if
1551
there is a result set) apart from sending columns metadata.
1553
virtual uint32_t field_count(List<Item> &fields) const
1554
{ return fields.elements; }
1555
virtual bool send_fields(List<Item> &list, uint32_t flags)=0;
1556
virtual bool send_data(List<Item> &items)=0;
1557
virtual bool initialize_tables (JOIN *)
1559
virtual void send_error(uint32_t errcode,const char *err);
1560
virtual bool send_eof()=0;
1561
virtual void abort() {}
1563
Cleanup instance of this class for next execution of a prepared
1564
statement/stored procedure.
1566
virtual void cleanup();
1567
void set_session(Session *session_arg) { session= session_arg; }
1568
void begin_dataset() {}
1573
Base class for select_result descendands which intercept and
1574
transform result set rows. As the rows are not sent to the client,
1575
sending of result set metadata should be suppressed as well.
1578
class select_result_interceptor: public select_result
1581
select_result_interceptor() {} /* Remove gcc warning */
1582
uint32_t field_count(List<Item> &) const
1584
bool send_fields(List<Item> &,
1590
class select_send :public select_result {
1592
True if we have sent result set metadata to the client.
1593
In this case the client always expects us to end the result
1594
set with an eof or error packet
1596
bool is_result_set_started;
1598
select_send() :is_result_set_started(false) {}
1599
bool send_fields(List<Item> &list, uint32_t flags);
1600
bool send_data(List<Item> &items);
1603
virtual void cleanup();
1607
class select_to_file :public select_result_interceptor {
1609
sql_exchange *exchange;
1613
char path[FN_REFLEN];
1616
select_to_file(sql_exchange *ex) :exchange(ex), file(-1),row_count(0L)
1619
void send_error(uint32_t errcode,const char *err);
1500
1625
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
1502
} /* namespace drizzled */
1504
/** @TODO why is this in the middle of the file */
1505
#include <drizzled/select_to_file.h>
1506
#include <drizzled/select_export.h>
1507
#include <drizzled/select_dump.h>
1508
#include <drizzled/select_insert.h>
1509
#include <drizzled/select_create.h>
1510
#include <drizzled/tmp_table_param.h>
1511
#include <drizzled/select_union.h>
1512
#include <drizzled/select_subselect.h>
1513
#include <drizzled/select_singlerow_subselect.h>
1514
#include <drizzled/select_max_min_finder_subselect.h>
1515
#include <drizzled/select_exists_subselect.h>
1521
* A structure used to describe sort information
1522
* for a field or item used in ORDER BY.
1524
typedef struct st_sort_field
1526
Field *field; /**< Field to sort */
1527
Item *item; /**< Item if not sorting fields */
1528
size_t length; /**< Length of sort field */
1529
uint32_t suffix_length; /**< Length suffix (0-4) */
1530
Item_result result_type; /**< Type of item */
1531
bool reverse; /**< if descending sort */
1532
bool need_strxnfrm; /**< If we have to use strxnfrm() */
1629
List of all possible characters of a numeric value text representation.
1631
#define NUMERIC_CHARS ".0123456789e+-"
1634
class select_export :public select_to_file {
1635
uint32_t field_term_length;
1636
int field_sep_char,escape_char,line_sep_char;
1637
int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT
1639
The is_ambiguous_field_sep field is true if a value of the field_sep_char
1640
field is one of the 'n', 't', 'r' etc characters
1641
(see the READ_INFO::unescape method and the ESCAPE_CHARS constant value).
1643
bool is_ambiguous_field_sep;
1645
The is_ambiguous_field_term is true if field_sep_char contains the first
1646
char of the FIELDS TERMINATED BY (ENCLOSED BY is empty), and items can
1647
contain this character.
1649
bool is_ambiguous_field_term;
1651
The is_unsafe_field_sep field is true if a value of the field_sep_char
1652
field is one of the '0'..'9', '+', '-', '.' and 'e' characters
1653
(see the NUMERIC_CHARS constant value).
1655
bool is_unsafe_field_sep;
1656
bool fixed_row_size;
1658
select_export(sql_exchange *ex) :select_to_file(ex) {}
1660
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1661
bool send_data(List<Item> &items);
1665
class select_dump :public select_to_file {
1667
select_dump(sql_exchange *ex) :select_to_file(ex) {}
1668
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1669
bool send_data(List<Item> &items);
1673
class select_insert :public select_result_interceptor {
1675
TableList *table_list;
1678
uint64_t autoinc_value_of_last_inserted_row; // autogenerated or not
1680
bool insert_into_view;
1681
select_insert(TableList *table_list_par,
1682
Table *table_par, List<Item> *fields_par,
1683
List<Item> *update_fields, List<Item> *update_values,
1684
enum_duplicates duplic, bool ignore);
1686
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1687
virtual int prepare2(void);
1688
bool send_data(List<Item> &items);
1689
virtual void store_values(List<Item> &values);
1690
virtual bool can_rollback_data() { return 0; }
1691
void send_error(uint32_t errcode,const char *err);
1694
/* not implemented: select_insert is never re-used in prepared statements */
1699
class select_create: public select_insert {
1701
TableList *create_table;
1702
HA_CREATE_INFO *create_info;
1703
TableList *select_tables;
1704
Alter_info *alter_info;
1706
/* lock data for tmp table */
1707
DRIZZLE_LOCK *m_lock;
1708
/* m_lock or session->extra_lock */
1709
DRIZZLE_LOCK **m_plock;
1711
select_create (TableList *table_arg,
1712
HA_CREATE_INFO *create_info_par,
1713
Alter_info *alter_info_arg,
1714
List<Item> &select_fields,enum_duplicates duplic, bool ignore,
1715
TableList *select_tables_arg)
1716
:select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore),
1717
create_table(table_arg),
1718
create_info(create_info_par),
1719
select_tables(select_tables_arg),
1720
alter_info(alter_info_arg),
1723
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1725
void store_values(List<Item> &values);
1726
void send_error(uint32_t errcode,const char *err);
1729
virtual bool can_rollback_data() { return 1; }
1731
// Needed for access from local class MY_HOOKS in prepare(), since session is proteted.
1732
const Session *get_session(void) { return session; }
1733
const HA_CREATE_INFO *get_create_info() { return create_info; };
1734
int prepare2(void) { return 0; }
1737
#include <storage/myisam/myisam.h>
1740
Param to create temporary tables when doing SELECT:s
1742
This structure is copied using memcpy as a part of JOIN.
1745
class TMP_TABLE_PARAM :public Sql_alloc
1748
/* Prevent use of these (not safe because of lists and copy_field) */
1749
TMP_TABLE_PARAM(const TMP_TABLE_PARAM &);
1750
void operator=(TMP_TABLE_PARAM &);
1753
List<Item> copy_funcs;
1754
List<Item> save_copy_funcs;
1755
Copy_field *copy_field, *copy_field_end;
1756
Copy_field *save_copy_field, *save_copy_field_end;
1757
unsigned char *group_buff;
1758
Item **items_to_copy; /* Fields in tmp table */
1759
MI_COLUMNDEF *recinfo,*start_recinfo;
1761
ha_rows end_write_records;
1762
uint field_count,sum_func_count,func_count;
1763
uint32_t hidden_field_count;
1764
uint group_parts,group_length,group_null_parts;
1766
bool using_indirect_summary_function;
1767
/* If >0 convert all blob fields to varchar(convert_blob_length) */
1768
uint32_t convert_blob_length;
1769
const CHARSET_INFO *table_charset;
1772
True if GROUP BY and its aggregate functions are already computed
1773
by a table access method (e.g. by loose index scan). In this case
1774
query execution should not perform aggregation and should treat
1775
aggregate functions as normal functions.
1777
bool precomputed_group_by;
1778
bool force_copy_fields;
1780
If true, create_tmp_field called from create_tmp_table will convert
1781
all BIT fields to 64-bit longs. This is a workaround the limitation
1782
that MEMORY tables cannot index BIT columns.
1784
bool bit_fields_as_long;
1787
:copy_field(0), group_parts(0),
1788
group_length(0), group_null_parts(0), convert_blob_length(0),
1789
schema_table(0), precomputed_group_by(0), force_copy_fields(0),
1790
bit_fields_as_long(0)
1800
class select_union :public select_result_interceptor
1802
TMP_TABLE_PARAM tmp_table_param;
1806
select_union() :table(0) {}
1807
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1808
bool send_data(List<Item> &items);
1812
bool create_result_table(Session *session, List<Item> *column_types,
1813
bool is_distinct, uint64_t options,
1814
const char *alias, bool bit_fields_as_long);
1817
/* Base subselect interface class */
1818
class select_subselect :public select_result_interceptor
1821
Item_subselect *item;
1823
select_subselect(Item_subselect *item);
1824
bool send_data(List<Item> &items)=0;
1825
bool send_eof() { return 0; };
1828
/* Single value subselect interface class */
1829
class select_singlerow_subselect :public select_subselect
1832
select_singlerow_subselect(Item_subselect *item_arg)
1833
:select_subselect(item_arg)
1835
bool send_data(List<Item> &items);
1838
/* used in independent ALL/ANY optimisation */
1839
class select_max_min_finder_subselect :public select_subselect
1842
bool (select_max_min_finder_subselect::*op)();
1845
select_max_min_finder_subselect(Item_subselect *item_arg, bool mx)
1846
:select_subselect(item_arg), cache(0), fmax(mx)
1849
bool send_data(List<Item> &items);
1856
/* EXISTS subselect interface class */
1857
class select_exists_subselect :public select_subselect
1860
select_exists_subselect(Item_subselect *item_arg)
1861
:select_subselect(item_arg){}
1862
bool send_data(List<Item> &items);
1865
/* Structs used when sorting */
1867
typedef struct st_sort_field {
1868
Field *field; /* Field to sort */
1869
Item *item; /* Item if not sorting fields */
1870
uint length; /* Length of sort field */
1871
uint32_t suffix_length; /* Length suffix (0-4) */
1872
Item_result result_type; /* Type of item */
1873
bool reverse; /* if descending sort */
1874
bool need_strxnfrm; /* If we have to use strxnfrm() */
1535
typedef struct st_sort_buffer
1537
uint32_t index; /* 0 or 1 */
1878
typedef struct st_sort_buffer {
1879
uint32_t index; /* 0 or 1 */
1538
1880
uint32_t sort_orders;
1539
uint32_t change_pos; /* If sort-fields changed */
1881
uint32_t change_pos; /* If sort-fields changed */
1541
1883
SORT_FIELD *sortorder;
1544
} /* namespace drizzled */
1546
/** @TODO why is this in the middle of the file */
1548
#include <drizzled/table_ident.h>
1549
#include <drizzled/user_var_entry.h>
1550
#include <drizzled/unique.h>
1551
#include <drizzled/var.h>
1552
#include <drizzled/select_dumpvar.h>
1886
/* Structure for db & table in sql_yacc */
1888
class Table_ident :public Sql_alloc
1893
SELECT_LEX_UNIT *sel;
1894
inline Table_ident(Session *session, LEX_STRING db_arg, LEX_STRING table_arg,
1896
:table(table_arg), sel((SELECT_LEX_UNIT *)0)
1898
if (!force && (session->client_capabilities & CLIENT_NO_SCHEMA))
1903
inline Table_ident(LEX_STRING table_arg)
1904
:table(table_arg), sel((SELECT_LEX_UNIT *)0)
1909
This constructor is used only for the case when we create a derived
1910
table. A derived table has no name and doesn't belong to any database.
1911
Later, if there was an alias specified for the table, it will be set
1912
by add_table_to_list.
1914
inline Table_ident(SELECT_LEX_UNIT *s) : sel(s)
1916
/* We must have a table name here as this is used with add_table_to_list */
1917
db.str= empty_c_string; /* a subject to casedn_str */
1919
table.str= internal_table_name;
1922
bool is_derived_table() const { return test(sel); }
1923
inline void change_db(char *db_name)
1925
db.str= db_name; db.length= (uint) strlen(db_name);
1929
// this is needed for user_vars hash
1930
class user_var_entry
1933
user_var_entry() {} /* Remove gcc warning */
1937
query_id_t update_query_id, used_query_id;
1941
double val_real(bool *null_value);
1942
int64_t val_int(bool *null_value) const;
1943
String *val_str(bool *null_value, String *str, uint32_t decimals);
1944
my_decimal *val_decimal(bool *null_value, my_decimal *result);
1945
DTCollation collation;
1949
Unique -- class for unique (removing of duplicates).
1950
Puts all values to the TREE. If the tree becomes too big,
1951
it's dumped to the file. User can request sorted values, or
1952
just iterate through them. In the last case tree merging is performed in
1953
memory simultaneously with iteration, so it should be ~2-3x faster.
1956
class Unique :public Sql_alloc
1958
DYNAMIC_ARRAY file_ptrs;
1960
size_t max_in_memory_size;
1963
unsigned char *record_pointers;
1969
Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
1970
uint32_t size_arg, size_t max_in_memory_size_arg);
1972
ulong elements_in_tree() { return tree.elements_in_tree; }
1973
inline bool unique_add(void *ptr)
1975
if (tree.elements_in_tree > max_elements && flush())
1977
return(!tree_insert(&tree, ptr, 0, tree.custom_arg));
1980
bool get(Table *table);
1981
static double get_use_cost(uint32_t *buffer, uint32_t nkeys, uint32_t key_size,
1982
size_t max_in_memory_size);
1983
inline static int get_cost_calc_buff_size(ulong nkeys, uint32_t key_size,
1984
size_t max_in_memory_size)
1986
register size_t max_elems_in_tree=
1987
(1 + max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size));
1988
return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree));
1992
bool walk(tree_walk_action action, void *walk_action_arg);
1994
friend int unique_write_to_file(unsigned char* key, element_count count, Unique *unique);
1995
friend int unique_write_to_ptrs(unsigned char* key, element_count count, Unique *unique);
1999
class multi_delete :public select_result_interceptor
2001
TableList *delete_tables, *table_being_deleted;
2003
ha_rows deleted, found;
2004
uint32_t num_of_tables;
2007
/* True if at least one table we delete from is transactional */
2008
bool transactional_tables;
2009
/* True if at least one table we delete from is not transactional */
2011
bool delete_while_scanning;
2013
error handling (rollback and binlogging) can happen in send_eof()
2014
so that afterward send_error() needs to find out that.
2019
multi_delete(TableList *dt, uint32_t num_of_tables);
2021
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2022
bool send_data(List<Item> &items);
2023
bool initialize_tables (JOIN *join);
2024
void send_error(uint32_t errcode,const char *err);
2027
virtual void abort();
2031
class multi_update :public select_result_interceptor
2033
TableList *all_tables; /* query/update command tables */
2034
TableList *leaves; /* list of leves of join table tree */
2035
TableList *update_tables, *table_being_updated;
2036
Table **tmp_tables, *main_table, *table_to_update;
2037
TMP_TABLE_PARAM *tmp_table_param;
2038
ha_rows updated, found;
2039
List <Item> *fields, *values;
2040
List <Item> **fields_for_table, **values_for_table;
2041
uint32_t table_count;
2043
List of tables referenced in the CHECK OPTION condition of
2044
the updated view excluding the updated table.
2046
List <Table> unupdated_check_opt_tables;
2047
Copy_field *copy_field;
2048
enum enum_duplicates handle_duplicates;
2049
bool do_update, trans_safe;
2050
/* True if the update operation has made a change in a transactional table */
2051
bool transactional_tables;
2054
error handling (rollback and binlogging) can happen in send_eof()
2055
so that afterward send_error() needs to find out that.
2060
multi_update(TableList *ut, TableList *leaves_list,
2061
List<Item> *fields, List<Item> *values,
2062
enum_duplicates handle_duplicates, bool ignore);
2064
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2065
bool send_data(List<Item> &items);
2066
bool initialize_tables (JOIN *join);
2067
void send_error(uint32_t errcode,const char *err);
2070
virtual void abort();
2073
class my_var : public Sql_alloc {
2078
enum_field_types type;
2079
my_var (LEX_STRING& j, bool i, uint32_t o, enum_field_types t)
2080
:s(j), local(i), offset(o), type(t)
2085
class select_dumpvar :public select_result_interceptor {
2088
List<my_var> var_list;
2089
select_dumpvar() { var_list.empty(); row_count= 0;}
2090
~select_dumpvar() {}
2091
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2092
bool send_data(List<Item> &items);
1557
2097
/* Bits in sql_command_flags */
1559
enum sql_command_flag_bits
2099
enum sql_command_flag_bits {
1561
2100
CF_BIT_CHANGES_DATA,
1562
2101
CF_BIT_HAS_ROW_COUNT,
1563
2102
CF_BIT_STATUS_COMMAND,