17
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
21
#ifndef DRIZZLED_SESSION_H
21
22
#define DRIZZLED_SESSION_H
23
#include "drizzled/cursor.h"
24
#include "drizzled/diagnostics_area.h"
25
#include "drizzled/file_exchange.h"
26
#include "drizzled/identifier.h"
27
#include "drizzled/internal_error_handler.h"
28
#include "drizzled/my_hash.h"
29
#include "drizzled/named_savepoint.h"
30
#include "drizzled/open_tables_state.h"
31
#include "drizzled/plugin.h"
32
#include "drizzled/plugin/authorization.h"
33
#include "drizzled/pthread_globals.h"
34
#include "drizzled/query_id.h"
35
#include "drizzled/resource_context.h"
36
#include "drizzled/select_result_interceptor.h"
37
#include "drizzled/sql_error.h"
38
#include "drizzled/sql_locale.h"
39
#include "drizzled/statistics_variables.h"
40
#include "drizzled/transaction_context.h"
41
#include "drizzled/util/storable.h"
42
#include "drizzled/xid.h"
47
#include <sys/resource.h>
24
/* Classes in mysql */
26
#include <drizzled/global.h>
27
#include <drizzled/log.h>
28
#include <drizzled/replication/tblmap.h>
29
#include <drizzled/protocol.h>
30
#include <libdrizzle/password.h> // rand_struct
31
#include <drizzled/sql_locale.h>
32
#include <drizzled/scheduler.h>
33
#include <drizzled/ha_trx_info.h>
34
#include <mysys/my_tree.h>
35
#include <drizzled/handler.h>
36
#include <drizzled/current_session.h>
37
#include <drizzled/sql_error.h>
38
#include <drizzled/query_arena.h>
54
#include "drizzled/catalog/instance.h"
55
#include "drizzled/catalog/local.h"
57
#include <drizzled/session/property_map.h>
58
#include <drizzled/session/state.h>
59
#include <drizzled/session/table_messages.h>
60
#include <drizzled/session/transactions.h>
61
#include <drizzled/system_variables.h>
62
#include <drizzled/copy_info.h>
63
#include <drizzled/system_variables.h>
64
#include <drizzled/ha_data.h>
66
#include <boost/thread/thread.hpp>
67
#include <boost/thread/mutex.hpp>
68
#include <boost/thread/shared_mutex.hpp>
69
#include <boost/thread/condition_variable.hpp>
70
#include <boost/make_shared.hpp>
72
#include <drizzled/lex_column.h>
73
#include "drizzled/sql_lex.h"
75
#include "drizzled/visibility.h"
77
#define MIN_HANDSHAKE_SIZE 6
86
class EventObserverList;
96
namespace internal { struct st_my_thread_var; }
98
namespace table { class Placeholder; }
44
class Query_log_event;
46
class Slave_log_event;
100
47
class Lex_input_stream;
101
49
class user_var_entry;
103
51
class Table_ident;
105
class TableShareInstance;
107
54
extern char internal_table_name[2];
108
55
extern char empty_c_string[1];
109
56
extern const char **errmesg;
58
#define TC_LOG_PAGE_SIZE 8192
59
#define TC_LOG_MIN_SIZE (3*TC_LOG_PAGE_SIZE)
111
61
#define TC_HEURISTIC_RECOVER_COMMIT 1
112
62
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
113
63
extern uint32_t tc_heuristic_recover;
65
typedef struct st_user_var_events
67
user_var_entry *user_var_event;
71
uint32_t charset_number;
72
} BINLOG_USER_VAR_EVENT;
74
#define RP_LOCK_LOG_IS_ALREADY_LOCKED 1
75
#define RP_FORCE_ROTATE 2
78
The COPY_INFO structure is used by INSERT/REPLACE code.
79
The schema of the row counting by the INSERT/INSERT ... ON DUPLICATE KEY
81
If a row is inserted then the copied variable is incremented.
82
If a row is updated by the INSERT ... ON DUPLICATE KEY UPDATE and the
83
new data differs from the old one then the copied and the updated
84
variables are incremented.
85
The touched variable is incremented if a row was touched by the update part
86
of the INSERT ... ON DUPLICATE KEY UPDATE no matter whether the row
87
was actually changed or not.
89
typedef struct st_copy_info {
90
ha_rows records; /**< Number of processed records */
91
ha_rows deleted; /**< Number of deleted records */
92
ha_rows updated; /**< Number of updated records */
93
ha_rows copied; /**< Number of copied records */
95
ha_rows touched; /* Number of touched records */
96
enum enum_duplicates handle_duplicates;
97
int escape_char, last_errno;
99
/* for INSERT ... UPDATE */
100
List<Item> *update_fields;
101
List<Item> *update_values;
102
/* for VIEW ... WITH CHECK OPTION */
109
typedef struct st_mysql_lock
112
uint32_t table_count,lock_count;
113
THR_LOCK_DATA **locks;
117
class LEX_COLUMN : public Sql_alloc
122
LEX_COLUMN (const String& x,const uint& y ): column (x),rights (y) {}
115
125
class select_result;
118
128
#define Session_SENTRY_MAGIC 0xfeedd1ff
119
129
#define Session_SENTRY_GONE 0xdeadbeef
121
extern DRIZZLED_API struct drizzle_system_variables global_system_variables;
131
#define Session_CHECK_SENTRY(session) assert(session->dbug_sentry == Session_SENTRY_MAGIC)
133
struct system_variables
136
How dynamically allocated system variables are handled:
138
The global_system_variables and max_system_variables are "authoritative"
139
They both should have the same 'version' and 'size'.
140
When attempting to access a dynamic variable, if the session version
141
is out of date, then the session version is updated and realloced if
142
neccessary and bytes copied from global to make up for missing data.
144
ulong dynamic_variables_version;
145
char* dynamic_variables_ptr;
146
uint32_t dynamic_variables_head; /* largest valid variable offset */
147
uint32_t dynamic_variables_size; /* how many bytes are in use */
149
uint64_t myisam_max_extra_sort_file_size;
150
uint64_t myisam_max_sort_file_size;
151
uint64_t max_heap_table_size;
152
uint64_t tmp_table_size;
153
ha_rows select_limit;
154
ha_rows max_join_size;
155
uint32_t auto_increment_increment;
156
uint32_t auto_increment_offset;
157
uint64_t bulk_insert_buff_size;
158
uint64_t join_buff_size;
159
uint32_t max_allowed_packet;
160
uint64_t max_error_count;
161
uint64_t max_length_for_sort_data;
162
uint64_t max_sort_length;
163
uint64_t max_tmp_tables;
164
uint64_t min_examined_row_limit;
165
size_t myisam_sort_buff_size;
166
uint32_t myisam_stats_method;
167
uint32_t net_buffer_length;
168
uint32_t net_interactive_timeout;
169
uint32_t net_read_timeout;
170
uint32_t net_retry_count;
171
uint32_t net_wait_timeout;
172
uint32_t net_write_timeout;
173
bool optimizer_prune_level;
174
uint32_t optimizer_search_depth;
176
Controls use of Engine-MRR:
177
0 - auto, based on cost
178
1 - force MRR when the storage engine is capable of doing it
181
uint32_t optimizer_use_mrr;
182
/* A bitmap for switching optimizations on/off */
183
uint32_t optimizer_switch;
184
uint64_t preload_buff_size;
185
uint32_t read_buff_size;
186
uint32_t read_rnd_buff_size;
187
uint32_t div_precincrement;
188
size_t sortbuff_size;
189
uint32_t thread_handling;
190
uint32_t tx_isolation;
191
uint32_t completion_type;
192
/* Determines which non-standard SQL behaviour should be enabled */
194
uint32_t default_week_format;
195
uint64_t max_seeks_for_key;
196
size_t range_alloc_block_size;
197
uint32_t query_alloc_block_size;
198
uint32_t query_prealloc_size;
199
uint32_t trans_alloc_block_size;
200
uint32_t trans_prealloc_size;
202
uint64_t group_concat_max_len;
204
In slave thread we need to know in behalf of which
205
thread the query is being run to replicate temp tables properly
207
/* TODO: change this to my_thread_id - but have to fix set_var first */
208
uint64_t pseudo_thread_id;
210
bool low_priority_updates;
213
compatibility option:
214
- index usage hints (USE INDEX without a FOR clause) behave as in 5.0
217
bool engine_condition_pushdown;
218
bool keep_files_on_create;
220
bool old_alter_table;
222
plugin_ref table_plugin;
224
/* Only charset part of these variables is sensible */
225
const CHARSET_INFO *character_set_filesystem;
227
/* Both charset and collation parts of these variables are important */
228
const CHARSET_INFO *collation_server;
229
const CHARSET_INFO *collation_database;
231
inline const CHARSET_INFO *getCollation(void)
233
return collation_database ? collation_database : collation_server;
237
MY_LOCALE *lc_time_names;
239
Time_zone *time_zone;
241
/* DATE, DATETIME and DRIZZLE_TIME formats */
242
DATE_TIME_FORMAT *date_format;
243
DATE_TIME_FORMAT *datetime_format;
244
DATE_TIME_FORMAT *time_format;
249
extern struct system_variables global_system_variables;
251
#include "sql_lex.h" /* only for SQLCOM_END */
253
/* per thread status variables */
255
typedef struct system_status_var
257
uint64_t bytes_received;
260
ulong com_stat[(uint) SQLCOM_END];
261
ulong created_tmp_disk_tables;
262
ulong created_tmp_tables;
263
ulong ha_commit_count;
264
ulong ha_delete_count;
265
ulong ha_read_first_count;
266
ulong ha_read_last_count;
267
ulong ha_read_key_count;
268
ulong ha_read_next_count;
269
ulong ha_read_prev_count;
270
ulong ha_read_rnd_count;
271
ulong ha_read_rnd_next_count;
272
ulong ha_rollback_count;
273
ulong ha_update_count;
274
ulong ha_write_count;
275
ulong ha_prepare_count;
276
ulong ha_savepoint_count;
277
ulong ha_savepoint_rollback_count;
279
/* KEY_CACHE parts. These are copies of the original */
280
ulong key_blocks_changed;
281
ulong key_blocks_used;
282
ulong key_cache_r_requests;
283
ulong key_cache_read;
284
ulong key_cache_w_requests;
285
ulong key_cache_write;
286
/* END OF KEY_CACHE parts */
288
ulong net_big_packet_count;
291
ulong select_full_join_count;
292
ulong select_full_range_join_count;
293
ulong select_range_count;
294
ulong select_range_check_count;
295
ulong select_scan_count;
296
ulong long_query_count;
297
ulong filesort_merge_passes;
298
ulong filesort_range_count;
300
ulong filesort_scan_count;
301
/* Prepared statements and binary protocol */
302
ulong com_stmt_prepare;
303
ulong com_stmt_execute;
304
ulong com_stmt_send_long_data;
305
ulong com_stmt_fetch;
306
ulong com_stmt_reset;
307
ulong com_stmt_close;
309
Number of statements sent from the client
315
SEE last_system_status_var DEFINITION BELOW.
317
Below 'last_system_status_var' are all variables which doesn't make any
318
sense to add to the /global/ status variable counter.
320
double last_query_cost;
326
This is used for 'SHOW STATUS'. It must be updated to the last ulong
327
variable in system_status_var which is makes sens to add to the global
331
#define last_system_status_var questions
333
void mark_transaction_to_rollback(Session *session, bool all);
335
#ifdef DRIZZLE_SERVER
124
* Represents a client connection to the database server.
126
* Contains the client/server protocol object, the current statement
127
* being executed, local-to-session variables and status counters, and
128
* a host of other information.
132
* The Session class should have a vector of Statement object pointers which
133
* comprise the statements executed on the Session. Until this architectural
134
* change is done, we can forget about parallel operations inside a session.
138
* Make member variables private and have inlined accessors and setters. Hide
139
* all member variables that are not critical to non-internal operations of the
143
class DRIZZLED_API Session : public Open_tables_state
339
@brief State of a single command executed against this connection.
341
One connection can contain a lot of simultaneously running statements,
342
some of which could be:
343
- prepared, that is, contain placeholders,
344
To perform some action with statement we reset Session part to the state of
345
that statement, do the action, and then save back modified state from Session
346
to the statement. It will be changed in near future, and Statement will
350
class Statement: public ilink, public Query_arena
352
Statement(const Statement &rhs); /* not implemented: */
353
Statement &operator=(const Statement &rhs); /* non-copyable */
146
// Plugin storage in Session.
147
typedef boost::shared_ptr<Session> shared_ptr;
148
typedef Session& reference;
149
typedef const Session& const_reference;
150
typedef const Session* const_pointer;
151
typedef Session* pointer;
153
static shared_ptr make_shared(plugin::Client *client, catalog::Instance::shared_ptr instance_arg)
155
assert(instance_arg);
156
return boost::make_shared<Session>(client, instance_arg);
356
Uniquely identifies each statement object in thread scope; change during
357
statement lifetime. FIXME: must be const
160
362
MARK_COLUMNS_NONE: Means mark_used_colums is not set and no indicator to
297
409
the Session of that thread); that thread is (and must remain, for now) the
298
410
only responsible for freeing this member.
418
/* This constructor is called for backup statements */
421
Statement(LEX *lex_arg, MEM_ROOT *mem_root_arg, ulong id_arg);
425
struct st_savepoint {
426
struct st_savepoint *prev;
429
Ha_trx_info *ha_list;
432
enum xa_states {XA_NOTR=0, XA_ACTIVE, XA_IDLE, XA_PREPARED};
433
extern const char *xa_state_names[];
435
typedef struct st_xid_state {
436
/* For now, this is only used to catch duplicated external xids */
437
XID xid; // transaction identifier
438
enum xa_states xa_state; // used by external XA only
442
extern pthread_mutex_t LOCK_xid_cache;
443
extern HASH xid_cache;
444
bool xid_cache_init(void);
445
void xid_cache_free(void);
446
XID_STATE *xid_cache_search(XID *xid);
447
bool xid_cache_insert(XID *xid, enum xa_states xa_state);
448
bool xid_cache_insert(XID_STATE *xid_state);
449
void xid_cache_delete(XID_STATE *xid_state);
452
@class Security_context
453
@brief A set of Session members describing the current authenticated user.
456
class Security_context {
458
Security_context() {}
460
host - host of the client
461
user - user of the client, set to NULL until the user has been read from
463
priv_user - The user privilege we are using. May be "" for anonymous user.
470
inline const char *priv_host_name()
472
return (ip.c_str() ? ip.c_str() : (char *)"%");
478
A registry for item tree transformations performed during
479
query optimization. We register only those changes which require
480
a rollback to re-execute a prepared statement or stored procedure
484
struct Item_change_record;
485
typedef I_List<Item_change_record> Item_change_list;
489
Class that holds information about tables which were opened and locked
490
by the thread. It is also used to save/restore this information in
491
push_open_tables_state()/pop_open_tables_state().
494
class Open_tables_state
498
List of regular tables in use by this thread. Contains temporary and
499
base tables that were opened with @see open_tables().
503
List of temporary tables used by this thread. Contains user-level
504
temporary tables, created with CREATE TEMPORARY TABLE, and
505
internal temporary tables, created, e.g., to resolve a SELECT,
506
or for an intermediate table used in ALTER.
507
XXX Why are internal temporary tables added to this list?
509
Table *temporary_tables;
511
List of tables that were opened with HANDLER OPEN and are
512
still in use by this thread.
514
Table *handler_tables;
515
Table *derived_tables;
517
During a MySQL session, one can lock tables in two modes: automatic
518
or manual. In automatic mode all necessary tables are locked just before
519
statement execution, and all acquired locks are stored in 'lock'
520
member. Unlocking takes place automatically as well, when the
522
Manual mode comes into play when a user issues a 'LOCK TABLES'
523
statement. In this mode the user can only use the locked tables.
524
Trying to use any other tables will give an error. The locked tables are
525
stored in 'locked_tables' member. Manual locking is described in
526
the 'LOCK_TABLES' chapter of the MySQL manual.
527
See also lock_tables() for details.
531
Tables that were locked with explicit or implicit LOCK TABLES.
532
(Implicit LOCK TABLES happens when we are prelocking tables for
533
execution of statement which uses stored routines. See description
534
Session::prelocked_mode for more info.)
536
DRIZZLE_LOCK *locked_tables;
539
CREATE-SELECT keeps an extra lock for the table being
540
created. This field is used to keep the extra lock available for
541
lower level routines, which would otherwise miss that lock.
543
DRIZZLE_LOCK *extra_lock;
546
uint32_t current_tablenr;
549
BACKUPS_AVAIL = (1U << 0) /* There are backups available */
553
Flags with information about the open tables state.
555
uint32_t state_flags;
558
This constructor serves for creation of Open_tables_state instances
559
which are used as backup storage.
561
Open_tables_state() : state_flags(0U) { }
563
Open_tables_state(ulong version_arg);
565
void set_open_tables_state(Open_tables_state *state)
570
void reset_open_tables_state()
572
open_tables= temporary_tables= handler_tables= derived_tables= 0;
573
extra_lock= lock= locked_tables= 0;
579
/* Flags for the Session::system_thread variable */
580
enum enum_thread_type
583
SYSTEM_THREAD_SLAVE_IO,
584
SYSTEM_THREAD_SLAVE_SQL
589
This class represents the interface for internal error handlers.
590
Internal error handlers are exception handlers used by the server
593
class Internal_error_handler
596
Internal_error_handler() {}
597
virtual ~Internal_error_handler() {}
601
Handle an error condition.
602
This method can be implemented by a subclass to achieve any of the
604
- mask an error internally, prevent exposing it to the user,
605
- mask an error and throw another one instead.
606
When this method returns true, the error condition is considered
607
'handled', and will not be propagated to upper layers.
608
It is the responsability of the code installing an internal handler
609
to then check for trapped conditions, and implement logic to recover
610
from the anticipated conditions trapped during runtime.
612
This mechanism is similar to C++ try/throw/catch:
613
- 'try' correspond to <code>Session::push_internal_handler()</code>,
614
- 'throw' correspond to <code>my_error()</code>,
615
which invokes <code>my_message_sql()</code>,
616
- 'catch' correspond to checking how/if an internal handler was invoked,
617
before removing it from the exception stack with
618
<code>Session::pop_internal_handler()</code>.
620
@param sql_errno the error number
621
@param level the error level
622
@param session the calling thread
623
@return true if the error is handled
625
virtual bool handle_error(uint32_t sql_errno,
627
DRIZZLE_ERROR::enum_warning_level level,
628
Session *session) = 0;
633
Stores status of the currently executed statement.
634
Cleared at the beginning of the statement, and then
635
can hold either OK, ERROR, or EOF status.
636
Can not be assigned twice per statement.
639
class Diagnostics_area
642
enum enum_diagnostics_status
644
/** The area is cleared at start of a statement. */
646
/** Set whenever one calls my_ok(). */
648
/** Set whenever one calls my_eof(). */
650
/** Set whenever one calls my_error() or my_message(). */
652
/** Set in case of a custom response, such as one from COM_STMT_PREPARE. */
655
/** True if status information is sent to the client. */
657
/** Set to make set_error_status after set_{ok,eof}_status possible. */
658
bool can_overwrite_status;
660
void set_ok_status(Session *session, ha_rows affected_rows_arg,
661
uint64_t last_insert_id_arg,
662
const char *message);
663
void set_eof_status(Session *session);
664
void set_error_status(Session *session, uint32_t sql_errno_arg, const char *message_arg);
666
void disable_status();
668
void reset_diagnostics_area();
670
bool is_set() const { return m_status != DA_EMPTY; }
671
bool is_error() const { return m_status == DA_ERROR; }
672
bool is_eof() const { return m_status == DA_EOF; }
673
bool is_ok() const { return m_status == DA_OK; }
674
bool is_disabled() const { return m_status == DA_DISABLED; }
675
enum_diagnostics_status status() const { return m_status; }
677
const char *message() const
678
{ assert(m_status == DA_ERROR || m_status == DA_OK); return m_message; }
680
uint32_t sql_errno() const
681
{ assert(m_status == DA_ERROR); return m_sql_errno; }
683
uint32_t server_status() const
685
assert(m_status == DA_OK || m_status == DA_EOF);
686
return m_server_status;
689
ha_rows affected_rows() const
690
{ assert(m_status == DA_OK); return m_affected_rows; }
692
uint64_t last_insert_id() const
693
{ assert(m_status == DA_OK); return m_last_insert_id; }
695
uint32_t total_warn_count() const
697
assert(m_status == DA_OK || m_status == DA_EOF);
698
return m_total_warn_count;
701
Diagnostics_area() { reset_diagnostics_area(); }
301
util::string::shared_ptr _schema;
704
/** Message buffer. Can be used by OK or ERROR status. */
705
char m_message[DRIZZLE_ERRMSG_SIZE];
707
SQL error number. One of ER_ codes from share/errmsg.txt.
708
Set by set_error_status.
710
uint32_t m_sql_errno;
713
Copied from session->server_status when the diagnostics area is assigned.
714
We need this member as some places in the code use the following pattern:
715
session->server_status|= ...
717
session->server_status&= ~...
718
Assigned by OK, EOF or ERROR.
720
uint32_t m_server_status;
722
The number of rows affected by the last statement. This is
723
semantically close to session->row_count_func, but has a different
724
life cycle. session->row_count_func stores the value returned by
725
function ROW_COUNT() and is cleared only by statements that
726
update its value, such as INSERT, UPDATE, DELETE and few others.
727
This member is cleared at the beginning of the next statement.
729
We could possibly merge the two, but life cycle of session->row_count_func
732
ha_rows m_affected_rows;
734
Similarly to the previous member, this is a replacement of
735
session->first_successful_insert_id_in_prev_stmt, which is used
736
to implement LAST_INSERT_ID().
738
uint64_t m_last_insert_id;
739
/** The total number of warnings. */
740
uint m_total_warn_count;
741
enum_diagnostics_status m_status;
743
@todo: the following Session members belong here:
744
- warn_list, warn_count,
750
Storage engine specific thread local data.
756
Storage engine specific thread local data.
757
Lifetime: one user connection.
761
0: Life time: one statement within a transaction. If @@autocommit is
762
on, also represents the entire transaction.
763
@sa trans_register_ha()
765
1: Life time: one transaction within a connection.
766
If the storage engine does not participate in a transaction,
767
this should not be used.
768
@sa trans_register_ha()
770
Ha_trx_info ha_info[2];
772
Ha_data() :ha_ptr(NULL) {}
778
For each client connection we create a separate thread with Session serving as
779
a thread/connection descriptor
782
class Session :public Statement,
783
public Open_tables_state
305
util::string::const_shared_ptr schema() const
310
return util::string::const_shared_ptr(new std::string(""));
313
/* current cache key */
314
std::string query_cache_key;
786
/* Used to execute base64 coded binlog events in MySQL server */
787
Relay_log_info* rli_fake;
316
790
Constant for Session::where initialization in the beginning of every query.
318
792
It's needed because we do not save/restore Session::where normally during
321
795
static const char * const DEFAULT_WHERE;
323
memory::Root warn_root; /**< Allocation area for warnings and errors */
325
plugin::Client *client; /**< Pointer to client object */
329
void setClient(plugin::Client *client_arg);
331
plugin::Client *getClient()
336
plugin::Client *getClient() const
341
plugin::Scheduler *scheduler; /**< Pointer to scheduler object */
342
void *scheduler_arg; /**< Pointer to the optional scheduler argument */
344
typedef boost::unordered_map< std::string, user_var_entry *, util::insensitive_hash, util::insensitive_equal_to> UserVars;
347
typedef std::pair< UserVars::iterator, UserVars::iterator > UserVarsRange;
348
UserVars user_vars; /**< Hash of user variables defined during the session's lifetime */
351
const UserVars &getUserVariables() const
356
drizzle_system_variables variables; /**< Mutable local variables local to the session */
358
enum_tx_isolation getTxIsolation()
360
return (enum_tx_isolation)variables.tx_isolation;
363
struct system_status_var status_var; /**< Session-local status counters */
364
THR_LOCK_INFO lock_info; /**< Locking information for this session */
365
THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
366
THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
369
* A pointer to the stack frame of the scheduler thread
370
* which is called first in the thread for handling a client
375
identifier::User::shared_ptr security_ctx;
377
int32_t scoreboard_index;
379
inline void checkSentry() const
381
assert(this->dbug_sentry == Session_SENTRY_MAGIC);
385
identifier::User::const_shared_ptr user() const
390
return identifier::User::const_shared_ptr();
393
void setUser(identifier::User::shared_ptr arg)
398
int32_t getScoreboardIndex()
400
return scoreboard_index;
403
void setScoreboardIndex(int32_t in_scoreboard_index)
405
scoreboard_index= in_scoreboard_index;
409
* Is this session viewable by the current user?
411
bool isViewable(identifier::User::const_reference) const;
797
NET net; // client connection descriptor
798
MEM_ROOT warn_root; // For warnings and errors
799
Protocol *protocol; // Current protocol
800
Protocol_text protocol_text; // Normal protocol
801
HASH user_vars; // hash for user variables
802
String packet; // dynamic buffer for network I/O
803
String convert_buffer; // buffer for charset conversions
804
struct rand_struct rand; // used for authentication
805
struct system_variables variables; // Changeable local variables
806
struct system_status_var status_var; // Per thread statistic vars
807
struct system_status_var *initial_status_var; /* used by show status */
808
THR_LOCK_INFO lock_info; // Locking info of this thread
809
THR_LOCK_OWNER main_lock_id; // To use for conventional queries
810
THR_LOCK_OWNER *lock_id; // If not main_lock_id, points to
811
// the lock_id of a cursor.
812
pthread_mutex_t LOCK_delete; // Locked before session is deleted
814
A pointer to the stack frame of handle_one_connection(),
815
which is called first in the thread for handling a client
820
Currently selected catalog.
826
Some members of Session (currently 'Statement::db',
827
'catalog' and 'query') are set and alloced by the slave SQL thread
828
(for the Session of that thread); that thread is (and must remain, for now)
829
the only responsible for freeing these 3 members. If you add members
830
here, and you add code to set them in replication, don't forget to
831
free_them_and_set_them_to_0 in replication properly. For details see
832
the 'err:' label of the handle_slave_sql() in sql/slave.cc.
834
@see handle_slave_sql
837
Security_context security_ctx;
840
Points to info-string that we show in SHOW PROCESSLIST
841
You are supposed to call Session_SET_PROC_INFO only if you have coded
842
a time-consuming piece that MySQL can get stuck in for a long time.
844
Set it using the session_proc_info(Session *thread, const char *message)
847
void set_proc_info(const char *info) { proc_info= info; }
848
const char* get_proc_info() const { return proc_info; }
415
851
Used in error messages to tell user in what part of MySQL we found an
416
852
error. E. g. when where= "having clause", if fix_fields() fails, user
417
853
will know that the error was in having clause.
427
void setWhere(const char *arg)
857
double tmp_double_value; /* Used in set_var.cc */
858
ulong client_capabilities; /* What the client supports */
859
ulong max_client_packet_length;
861
HASH handler_tables_hash;
433
863
One thread can hold up to one named user-level lock. This variable
434
864
points to a lock object if the lock is present. See item_func.cc and
435
865
chapter 'Miscellaneous functions', for functions GET_LOCK, RELEASE_LOCK.
437
uint32_t dbug_sentry; /**< watch for memory corruption */
440
boost::thread::id boost_thread_id;
441
boost_thread_shared_ptr _thread;
442
boost::this_thread::disable_interruption *interrupt;
444
internal::st_my_thread_var *mysys_var;
447
boost_thread_shared_ptr &getThread()
452
void pushInterrupt(boost::this_thread::disable_interruption *interrupt_arg)
454
interrupt= interrupt_arg;
457
boost::this_thread::disable_interruption &getThreadInterupt()
463
internal::st_my_thread_var *getThreadVar()
469
* Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
470
* first byte of the packet in executeStatement()
867
uint32_t dbug_sentry; // watch out for memory corruption
868
struct st_my_thread_var *mysys_var;
870
Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
871
first byte of the packet in do_command()
472
873
enum enum_server_command command;
473
uint32_t file_id; /**< File ID for LOAD DATA INFILE */
474
/* @note the following three members should likely move to Client */
475
uint32_t max_client_packet_length; /**< Maximum number of bytes a client can send in a single packet */
478
boost::posix_time::ptime _epoch;
479
boost::posix_time::ptime _connect_time;
480
boost::posix_time::ptime _start_timer;
481
boost::posix_time::ptime _end_timer;
483
boost::posix_time::ptime _user_time;
485
uint64_t utime_after_lock; // This used by Innodb.
489
_user_time= boost::posix_time::not_a_date_time;
492
const boost::posix_time::ptime &start_timer() const
497
void getTimeDifference(boost::posix_time::time_duration &result_arg, const boost::posix_time::ptime &arg) const
499
result_arg= arg - _start_timer;
875
uint32_t file_id; // for LOAD DATA INFILE
876
/* remote (peer) port */
878
time_t start_time, user_time;
879
uint64_t connect_utime, thr_create_utime; // track down slow pthread_create
880
uint64_t start_utime, utime_after_lock;
502
882
thr_lock_type update_lock_default;
595
989
in the binlog is still needed; the list's minimum will contain 3.
597
991
Discrete_intervals_list auto_inc_intervals_in_cur_stmt_for_binlog;
598
/** Used by replication and SET INSERT_ID */
992
/* Used by replication and SET INSERT_ID */
599
993
Discrete_intervals_list auto_inc_intervals_forced;
601
uint64_t limit_found_rows;
602
uint64_t options; /**< Bitmap of options */
603
int64_t row_count_func; /**< For the ROW_COUNT() function */
605
int64_t rowCount() const
607
return row_count_func;
610
ha_rows cuted_fields; /**< Count of "cut" or truncated fields. @todo Kill this friggin thing. */
613
* Number of rows we actually sent to the client, including "synthetic"
614
* rows in ROLLUP etc.
616
ha_rows sent_row_count;
619
* Number of rows we read, sent or not, including in create_sort_index()
621
ha_rows examined_row_count;
624
* The set of those tables whose fields are referenced in all subqueries
629
* Possibly this it is incorrect to have used tables in Session because
630
* with more than one subquery, it is not clear what does the field mean.
632
table_map used_tables;
637
This, and some other variables like 'count_cuted_fields'
638
maybe should be statement/cursor local, that is, moved to Statement
639
class. With current implementation warnings produced in each prepared
640
statement/cursor settle here.
642
List<DRIZZLE_ERROR> warn_list;
643
uint32_t warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_END];
644
uint32_t total_warn_count;
645
Diagnostics_area main_da;
649
/* Statement id is thread-wide. This counter is used to generate ids */
650
uint32_t statement_id_counter;
651
uint32_t rand_saved_seed1;
652
uint32_t rand_saved_seed2;
654
Row counter, mainly for errors and warnings. Not increased in
655
create_sort_index(); may differ from examined_row_count.
659
uint32_t getRowCount() const
664
session_id_t thread_id;
666
enum global_read_lock_t
669
GOT_GLOBAL_READ_LOCK= 1,
670
MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT= 2
673
global_read_lock_t _global_read_lock;
677
global_read_lock_t isGlobalReadLock() const
679
return _global_read_lock;
682
void setGlobalReadLock(global_read_lock_t arg)
684
_global_read_lock= arg;
687
DrizzleLock *lockTables(Table **tables, uint32_t count, uint32_t flags);
688
bool lockGlobalReadLock();
689
bool lock_table_names(TableList *table_list);
690
bool lock_table_names_exclusively(TableList *table_list);
691
bool makeGlobalReadLockBlockCommit();
692
bool abortLockForThread(Table *table);
693
bool wait_if_global_read_lock(bool abort_on_refresh, bool is_not_commit);
694
int lock_table_name(TableList *table_list);
695
void abortLock(Table *table);
696
void removeLock(Table *table);
697
void unlockReadTables(DrizzleLock *sql_lock);
698
void unlockSomeTables(Table **table, uint32_t count);
699
void unlockTables(DrizzleLock *sql_lock);
700
void startWaitingGlobalReadLock();
701
void unlockGlobalReadLock();
704
int unlock_external(Table **table, uint32_t count);
705
int lock_external(Table **tables, uint32_t count);
706
bool wait_for_locked_table_names(TableList *table_list);
707
DrizzleLock *get_lock_data(Table **table_ptr, uint32_t count,
708
bool should_lock, Table **write_lock_used);
711
uint32_t server_status;
712
uint32_t open_options;
713
uint32_t select_number; /**< number of select (used for EXPLAIN) */
714
/* variables.transaction_isolation is reset to this after each commit */
715
enum_tx_isolation session_tx_isolation;
716
enum_check_fields count_cuted_fields;
724
KILLED_NO_VALUE /* means none of the above states apply */
727
killed_state_t volatile _killed;
731
void setKilled(killed_state_t arg)
736
killed_state_t getKilled()
741
volatile killed_state_t *getKilledPtr() // Do not use this method, it is here for historical convience.
746
bool is_admin_connection;
747
bool some_tables_deleted;
751
Set to true if execution of the current compound statement
752
can not continue. In particular, disables activation of
753
CONTINUE or EXIT handlers of stored routines.
754
Reset in the end of processing of the current user request, in
755
@see reset_session_for_next_command().
759
Set by a storage engine to request the entire
760
transaction (that possibly spans multiple engines) to
761
rollback. Reset in ha_rollback.
763
bool transaction_rollback_request;
765
true if we are in a sub-statement and the current error can
766
not be safely recovered until we left the sub-statement mode.
767
In particular, disables activation of CONTINUE and EXIT
768
handlers inside sub-statements. E.g. if it is a deadlock
769
error and requires a transaction-wide rollback, this flag is
770
raised (traditionally, MySQL first has to close all the reads
771
via @see handler::ha_index_or_rnd_end() and only then perform
773
Reset to false when we leave the sub-statement mode.
775
bool is_fatal_sub_stmt_error;
776
/** for IS NULL => = last_insert_id() fix in remove_eq_conds() */
777
bool substitute_null_with_insert_id;
781
bool abort_on_warning;
782
bool tablespace_op; /**< This is true in DISCARD/IMPORT TABLESPACE */
785
bool got_warning; /**< Set on call to push_warning() */
786
bool no_warnings_for_error; /**< no warnings on call to my_error() */
787
/** set during loop of derived table processing */
788
bool derived_tables_processing;
790
bool doing_tablespace_operation(void)
792
return tablespace_op;
795
void setDoingTablespaceOperation(bool doing)
797
tablespace_op= doing;
801
/** Used by the sys_var class to store temporary values */
805
uint32_t uint32_t_value;
806
int32_t int32_t_value;
807
uint64_t uint64_t_value;
811
Character input stream consumed by the lexical analyser,
813
Note that since the parser is not re-entrant, we keep only one input
814
stream here. This member is valid only when executing code during parsing,
815
and may point to invalid memory after that.
817
Lex_input_stream *m_lip;
819
/** Place to store various things */
820
void *session_marker;
822
/** Keeps a copy of the previous table around in case we are just slamming on particular table */
826
Points to info-string that we show in SHOW PROCESSLIST
827
You are supposed to call Session_SET_PROC_INFO only if you have coded
828
a time-consuming piece that MySQL can get stuck in for a long time.
830
Set it using the session_proc_info(Session *thread, const char *message)
833
inline void set_proc_info(const char *info)
837
inline const char* get_proc_info() const
842
/** Sets this Session's current query ID */
843
inline void setQueryId(query_id_t in_query_id)
845
query_id= in_query_id;
848
/** Returns the current query ID */
849
query_id_t getQueryId() const
855
/** Sets this Session's warning query ID */
856
inline void setWarningQueryId(query_id_t in_query_id)
858
warn_query_id= in_query_id;
861
/** Returns the Session's warning query ID */
862
inline query_id_t getWarningQueryId() const
864
return warn_query_id;
867
/** Accessor method returning the session's ID. */
868
inline session_id_t getSessionId() const
873
/** Accessor method returning the server's ID. */
874
inline uint32_t getServerId() const
876
/* We return the global server ID. */
880
/** Returns the current transaction ID for the session's current statement */
881
inline my_xid getTransactionId()
883
return transaction.xid_state.xid.quick_get_my_xid();
886
995
There is BUG#19630 where statement-based replication of stored
887
996
functions/triggers with two auto_increment columns breaks.
888
997
We however ensure that it works when there is 0 or 1 auto_increment
938
1047
auto_inc_intervals_forced.append(next_id, UINT64_MAX, 0);
941
Session(plugin::Client *client_arg, catalog::Instance::shared_ptr catalog);
946
* Cleans up after query.
950
* This function is used to reset thread data to its default state.
952
* This function is not suitable for setting thread data to some
953
* non-default values, as there is only one replication thread, so
954
* different master threads may overwrite data of each other on
957
void cleanup_after_query();
959
void awake(Session::killed_state_t state_to_set);
961
* Pulls thread-specific variables into Session state.
963
* Returns true most times, or false if there was a problem
964
* allocating resources for thread-specific storage.
966
* @TODO Kill this. It's not necessary once my_thr_init() is bye bye.
1050
uint64_t limit_found_rows;
1051
uint64_t options; /* Bitmap of states */
1052
int64_t row_count_func; /* For the ROW_COUNT() function */
1053
ha_rows cuted_fields;
1056
number of rows we actually sent to the client, including "synthetic"
1059
ha_rows sent_row_count;
1062
number of rows we read, sent or not, including in create_sort_index()
1064
ha_rows examined_row_count;
1067
The set of those tables whose fields are referenced in all subqueries
1069
TODO: possibly this it is incorrect to have used tables in Session because
1070
with more than one subquery, it is not clear what does the field mean.
1072
table_map used_tables;
1073
USER_CONN *user_connect;
1074
const CHARSET_INFO *db_charset;
1076
FIXME: this, and some other variables like 'count_cuted_fields'
1077
maybe should be statement/cursor local, that is, moved to Statement
1078
class. With current implementation warnings produced in each prepared
1079
statement/cursor settle here.
1081
List <DRIZZLE_ERROR> warn_list;
1082
uint warn_count[(uint) DRIZZLE_ERROR::WARN_LEVEL_END];
1083
uint total_warn_count;
1084
Diagnostics_area main_da;
1087
Id of current query. Statement can be reused to execute several queries
1088
query_id is global in context of the whole MySQL server.
1089
ID is automatically generated from mutex-protected counter.
1090
It's used in handler code for various purposes: to check which columns
1091
from table are necessary for this select, to check if it's necessary to
1092
update auto-updatable fields (like auto_increment and timestamp).
1094
query_id_t query_id, warn_id;
1097
#ifdef ERROR_INJECT_SUPPORT
1098
ulong error_inject_value;
1100
/* Statement id is thread-wide. This counter is used to generate ids */
1101
ulong statement_id_counter;
1102
ulong rand_saved_seed1, rand_saved_seed2;
1104
Row counter, mainly for errors and warnings. Not increased in
1105
create_sort_index(); may differ from examined_row_count.
1108
pthread_t real_id; /* For debugging */
1109
my_thread_id thread_id;
1110
uint tmp_table, global_read_lock;
1111
uint server_status,open_options;
1112
enum enum_thread_type system_thread;
1113
uint32_t select_number; //number of select (used for EXPLAIN)
1114
/* variables.transaction_isolation is reset to this after each commit */
1115
enum_tx_isolation session_tx_isolation;
1116
enum_check_fields count_cuted_fields;
1118
DYNAMIC_ARRAY user_var_events; /* For user variables replication */
1119
MEM_ROOT *user_var_events_alloc; /* Allocate above array elements here */
1127
KILLED_NO_VALUE /* means neither of the states */
1129
killed_state volatile killed;
1131
/* scramble - random string sent to client on handshake */
1132
char scramble[SCRAMBLE_LENGTH+1];
1135
bool some_tables_deleted;
1136
bool last_cuted_field;
1137
bool no_errors, password;
1139
Set to true if execution of the current compound statement
1140
can not continue. In particular, disables activation of
1141
CONTINUE or EXIT handlers of stored routines.
1142
Reset in the end of processing of the current user request, in
1143
@see mysql_reset_session_for_next_command().
1145
bool is_fatal_error;
1147
Set by a storage engine to request the entire
1148
transaction (that possibly spans multiple engines) to
1149
rollback. Reset in ha_rollback.
1151
bool transaction_rollback_request;
1153
true if we are in a sub-statement and the current error can
1154
not be safely recovered until we left the sub-statement mode.
1155
In particular, disables activation of CONTINUE and EXIT
1156
handlers inside sub-statements. E.g. if it is a deadlock
1157
error and requires a transaction-wide rollback, this flag is
1158
raised (traditionally, MySQL first has to close all the reads
1159
via @see handler::ha_index_or_rnd_end() and only then perform
1161
Reset to false when we leave the sub-statement mode.
1163
bool is_fatal_sub_stmt_error;
1164
/* for IS NULL => = last_insert_id() fix in remove_eq_conds() */
1165
bool substitute_null_with_insert_id;
1166
bool in_lock_tables;
1168
True if a slave error. Causes the slave to stop. Not the same
1169
as the statement execution error (is_error()), since
1170
a statement may be expected to return an error, e.g. because
1171
it returned an error on master, and this is OK on the slave.
1173
bool is_slave_error;
1176
/** is set if some thread specific value(s) used in a statement. */
1177
bool thread_specific_used;
1178
bool charset_is_system_charset, charset_is_collation_connection;
1179
bool charset_is_character_set_filesystem;
1180
bool abort_on_warning;
1181
bool got_warning; /* Set on call to push_warning() */
1182
bool no_warnings_for_error; /* no warnings on call to my_error() */
1183
/* set during loop of derived table processing */
1184
bool derived_tables_processing;
1185
bool tablespace_op; /* This is true in DISCARD/IMPORT TABLESPACE */
1188
If we do a purge of binary logs, log index info of the threads
1189
that are currently reading it needs to be adjusted. To do that
1190
each thread that is using LOG_INFO needs to adjust the pointer to it
1192
LOG_INFO* current_linfo;
1193
NET* slave_net; // network connection from slave -> m.
1194
/* Used by the sys_var class to store temporary values */
1200
uint64_t uint64_t_value;
1205
If true, drizzle_bin_log::write(Log_event) call will not write events to
1206
binlog, and maintain 2 below variables instead (use
1207
drizzle_bin_log.start_union_events to turn this on)
1211
If true, at least one drizzle_bin_log::write(Log_event) call has been
1212
made after last drizzle_bin_log.start_union_events() call.
1214
bool unioned_events;
1216
If true, at least one drizzle_bin_log::write(Log_event e), where
1217
e.cache_stmt == true call has been made after last
1218
drizzle_bin_log.start_union_events() call.
1220
bool unioned_events_trans;
1223
'queries' (actually SP statements) that run under inside this binlog
1224
union have session->query_id >= first_query_id.
1226
query_id_t first_query_id;
1230
Character input stream consumed by the lexical analyser,
1231
used during parsing.
1232
Note that since the parser is not re-entrant, we keep only one input
1233
stream here. This member is valid only when executing code during parsing,
1234
and may point to invalid memory after that.
1236
Lex_input_stream *m_lip;
972
1243
Initialize memory roots necessary for query processing and (!)
973
1244
pre-allocate memory for it. We can't do that in Session constructor because
974
there are use cases where it's vital to not allocate excessive and not used
1245
there are use cases (acl_init, watcher threads,
1246
killing mysqld) where it's vital to not allocate excessive and not used
1247
memory. Note, that we still don't return error from init_for_queries():
1248
if preallocation fails, we should notice that at the first call to
977
void prepareForQueries();
980
* Executes a single statement received from the
983
* Returns true if the statement was successful, or false
988
* For profiling to work, it must never be called recursively.
990
* In MySQL, this used to be the do_command() C function whic
991
* accepted a single parameter of the THD pointer.
993
bool executeStatement();
996
* Reads a query from packet and stores it.
998
* Returns true if query is read and allocated successfully,
999
* false otherwise. On a return of false, Session::fatal_error
1002
* @note Used in COM_QUERY and COM_STMT_PREPARE.
1004
* Sets the following Session variables:
1008
* @param The packet pointer to read from
1009
* @param The length of the query to read
1011
bool readAndStoreQuery(const char *in_packet, uint32_t in_packet_length);
1014
* Ends the current transaction and (maybe) begins the next.
1016
* Returns true if the transaction completed successfully,
1019
* @param Completion type
1021
bool endTransaction(enum enum_mysql_completiontype completion);
1022
bool endActiveTransaction();
1023
bool startTransaction(start_transaction_option_t opt= START_TRANS_NO_OPTIONS);
1024
void markTransactionForRollback(bool all);
1027
* Authenticates users, with error reporting.
1029
* Returns true on success, or false on failure.
1031
bool authenticate();
1036
* This will initialize the session and begin the command loop.
1041
* Schedule a session to be run on the default scheduler.
1043
static bool schedule(Session::shared_ptr&);
1045
static void unlink(session_id_t &session_id);
1046
static void unlink(Session::shared_ptr&);
1251
void init_for_queries();
1253
void cleanup_after_query();
1254
bool store_globals();
1255
void awake(Session::killed_state state_to_set);
1257
enum enum_binlog_query_type {
1259
The query can be logged row-based or statement-based
1264
The query has to be logged statement-based
1269
The query represents a change to a table in the "mysql"
1270
database and is currently mapped to ROW_QUERY_TYPE.
1049
1277
For enter_cond() / exit_cond() to work the mutex must be got before
1050
1278
enter_cond(); this mutex is then released by exit_cond().
1051
1279
Usage must be: lock mutex; enter_cond(); your code; exit_cond().
1053
const char* enter_cond(boost::condition_variable_any &cond, boost::mutex &mutex, const char* msg);
1054
void exit_cond(const char* old_msg);
1056
type::Time::epoch_t query_start()
1058
return getCurrentTimestampEpoch();
1063
_end_timer= _start_timer= boost::posix_time::microsec_clock::universal_time();
1064
utime_after_lock= (_start_timer - _epoch).total_microseconds();
1067
void set_time(time_t t) // This is done by a sys_var, as long as user_time is set, we will use that for all references to time
1069
_user_time= boost::posix_time::from_time_t(t);
1072
void set_time_after_lock()
1074
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
1075
utime_after_lock= (mytime - _epoch).total_microseconds();
1078
void set_end_timer()
1080
_end_timer= boost::posix_time::microsec_clock::universal_time();
1081
status_var.execution_time_nsec+=(_end_timer - _start_timer).total_microseconds();
1084
uint64_t getElapsedTime() const
1086
return (_end_timer - _start_timer).total_microseconds();
1090
* Returns the current micro-timestamp
1092
type::Time::epoch_t getCurrentTimestamp(bool actual= true) const
1094
type::Time::epoch_t t_mark;
1281
inline const char* enter_cond(pthread_cond_t *cond, pthread_mutex_t* mutex,
1284
const char* old_msg = get_proc_info();
1285
safe_mutex_assert_owner(mutex);
1286
mysys_var->current_mutex = mutex;
1287
mysys_var->current_cond = cond;
1288
this->set_proc_info(msg);
1291
inline void exit_cond(const char* old_msg)
1294
Putting the mutex unlock in exit_cond() ensures that
1295
mysys_var->current_mutex is always unlocked _before_ mysys_var->mutex is
1296
locked (if that would not be the case, you'll get a deadlock if someone
1297
does a Session::awake() on you).
1299
pthread_mutex_unlock(mysys_var->current_mutex);
1300
pthread_mutex_lock(&mysys_var->mutex);
1301
mysys_var->current_mutex = 0;
1302
mysys_var->current_cond = 0;
1303
this->set_proc_info(old_msg);
1304
pthread_mutex_unlock(&mysys_var->mutex);
1306
inline time_t query_start() { return start_time; }
1307
inline void set_time()
1098
boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::universal_time());
1099
t_mark= (mytime - _epoch).total_microseconds();
1311
start_time= user_time;
1312
start_utime= utime_after_lock= my_micro_time();
1103
t_mark= (_end_timer - _epoch).total_microseconds();
1109
// We may need to set user on this
1110
type::Time::epoch_t getCurrentTimestampEpoch() const
1112
if (not _user_time.is_not_a_date_time())
1113
return (_user_time - _epoch).total_seconds();
1115
return (_start_timer - _epoch).total_seconds();
1118
type::Time::epoch_t getCurrentTimestampEpoch(type::Time::usec_t &fraction_arg) const
1120
if (not _user_time.is_not_a_date_time())
1123
return (_user_time - _epoch).total_seconds();
1126
fraction_arg= _start_timer.time_of_day().fractional_seconds() % 1000000;
1127
return (_start_timer - _epoch).total_seconds();
1130
uint64_t found_rows(void) const
1315
start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
1317
inline void set_current_time() { start_time= time(NULL); }
1318
inline void set_time(time_t t)
1320
start_time= user_time= t;
1321
start_utime= utime_after_lock= my_micro_time();
1323
void set_time_after_lock() { utime_after_lock= my_micro_time(); }
1324
uint64_t current_utime() { return my_micro_time(); }
1325
inline uint64_t found_rows(void)
1132
1327
return limit_found_rows;
1135
/** Returns whether the session is currently inside a transaction */
1136
bool inTransaction() const
1329
inline bool active_transaction()
1138
1331
return server_status & SERVER_STATUS_IN_TRANS;
1333
inline bool fill_derived_tables()
1335
return !lex->only_view_structure();
1337
inline void* trans_alloc(unsigned int size)
1339
return alloc_root(&transaction.mem_root,size);
1141
1342
LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1142
1343
const char* str, uint32_t length,
1143
1344
bool allocate_lex_string);
1145
LEX_STRING *make_lex_string(LEX_STRING *lex_str,
1146
const std::string &str,
1147
bool allocate_lex_string);
1346
bool convert_string(LEX_STRING *to, const CHARSET_INFO * const to_cs,
1347
const char *from, uint32_t from_length,
1348
const CHARSET_INFO * const from_cs);
1350
bool convert_string(String *s, const CHARSET_INFO * const from_cs, const CHARSET_INFO * const to_cs);
1352
void add_changed_table(Table *table);
1353
void add_changed_table(const char *key, long key_length);
1354
CHANGED_TableList * changed_table_dup(const char *key, long key_length);
1149
1355
int send_explain_fields(select_result *result);
1152
1357
Clear the current error, if any.
1153
1358
We do not clear is_fatal_error or is_fatal_sub_stmt_error since we
1468
1522
- for prepared queries, only to allocate runtime data. The parsed
1469
1523
tree itself is reused between executions and thus is stored elsewhere.
1471
memory::Root main_mem_root;
1474
* Marks all tables in the list which were used by current substatement
1475
* as free for reuse.
1477
* @param Head of the list of tables
1481
* The reason we reset query_id is that it's not enough to just test
1482
* if table->query_id != session->query_id to know if a table is in use.
1486
* SELECT f1_that_uses_t1() FROM t1;
1488
* In f1_that_uses_t1() we will see one instance of t1 where query_id is
1489
* set to query_id of original query.
1491
void mark_used_tables_as_free_for_reuse(Table *table);
1495
/** A short cut for session->main_da.set_ok_status(). */
1496
inline void my_ok(ha_rows affected_rows= 0, ha_rows found_rows_arg= 0,
1497
uint64_t passed_id= 0, const char *message= NULL)
1499
main_da.set_ok_status(this, affected_rows, found_rows_arg, passed_id, message);
1503
/** A short cut for session->main_da.set_eof_status(). */
1505
inline void my_eof()
1507
main_da.set_eof_status(this);
1510
/* Some inline functions for more speed */
1512
inline bool add_item_to_list(Item *item)
1514
return lex->current_select->add_item_to_list(this, item);
1517
inline bool add_value_to_list(Item *value)
1519
return lex->value_list.push_back(value);
1522
inline bool add_order_to_list(Item *item, bool asc)
1524
return lex->current_select->add_order_to_list(this, item, asc);
1527
inline bool add_group_to_list(Item *item, bool asc)
1529
return lex->current_select->add_group_to_list(this, item, asc);
1531
void refresh_status();
1532
user_var_entry *getVariable(LEX_STRING &name, bool create_if_not_exists);
1533
user_var_entry *getVariable(const std::string &name, bool create_if_not_exists);
1534
void setVariable(const std::string &name, const std::string &value);
1537
* Closes all tables used by the current substatement, or all tables
1538
* used by this thread if we are on the upper level.
1540
void close_thread_tables();
1541
void close_old_data_files(bool morph_locks= false,
1542
bool send_refresh= false);
1543
void close_open_tables();
1544
void close_data_files_and_morph_locks(const identifier::Table &identifier);
1547
bool free_cached_table(boost::mutex::scoped_lock &scopedLock);
1552
* Prepares statement for reopening of tables and recalculation of set of
1555
* @param Pointer to a pointer to a list of tables which we were trying to open and lock
1557
void close_tables_for_reopen(TableList **tables);
1561
* Open all tables in list, locks them (all, including derived)
1563
* @param Pointer to a list of tables for open & locking
1572
* The lock will automaticaly be freed by close_thread_tables()
1574
bool openTablesLock(TableList *tables);
1576
int open_tables_from_list(TableList **start, uint32_t *counter, uint32_t flags= 0);
1578
Table *openTableLock(TableList *table_list, thr_lock_type lock_type);
1579
Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1581
void unlink_open_table(Table *find);
1582
void drop_open_table(Table *table, const identifier::Table &identifier);
1583
void close_cached_table(Table *table);
1585
/* Create a lock in the cache */
1586
table::Placeholder *table_cache_insert_placeholder(const identifier::Table &identifier);
1587
bool lock_table_name_if_not_cached(const identifier::Table &identifier, Table **table);
1590
session::TableMessages _table_message_cache;
1593
session::TableMessages &getMessageCache()
1595
return _table_message_cache;
1598
/* Reopen operations */
1599
bool reopen_tables();
1600
bool close_cached_tables(TableList *tables, bool wait_for_refresh, bool wait_for_placeholders);
1602
void wait_for_condition(boost::mutex &mutex, boost::condition_variable_any &cond);
1603
int setup_conds(TableList *leaves, COND **conds);
1604
int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1606
drizzled::util::Storable *getProperty(const std::string &arg)
1608
return life_properties.getProperty(arg);
1612
bool setProperty(const std::string &arg, T *value)
1614
life_properties.setProperty(arg, value);
1620
Return the default storage engine
1622
@param getDefaultStorageEngine()
1625
pointer to plugin::StorageEngine
1627
plugin::StorageEngine *getDefaultStorageEngine()
1629
if (variables.storage_engine)
1630
return variables.storage_engine;
1631
return global_system_variables.storage_engine;
1634
void get_xid(DRIZZLE_XID *xid); // Innodb only
1636
table::Singular *getInstanceTable();
1637
table::Singular *getInstanceTable(List<CreateField> &field_list);
1642
if (getrusage(RUSAGE_THREAD, &usage))
1652
void setUsage(bool arg)
1657
const struct rusage &getUsage()
1662
catalog::Instance::const_reference catalog() const
1664
return *(_catalog.get());
1667
catalog::Instance::reference catalog()
1669
return *(_catalog.get());
1673
catalog::Instance::shared_ptr _catalog;
1675
// This lives throughout the life of Session
1677
session::PropertyMap life_properties;
1678
std::vector<table::Singular *> temporary_shares;
1679
struct rusage usage;
1525
MEM_ROOT main_mem_root;
1530
/** A short cut for session->main_da.set_ok_status(). */
1533
my_ok(Session *session, ha_rows affected_rows= 0, uint64_t id= 0,
1534
const char *message= NULL)
1536
session->main_da.set_ok_status(session, affected_rows, id, message);
1540
/** A short cut for session->main_da.set_eof_status(). */
1543
my_eof(Session *session)
1545
session->main_da.set_eof_status(session);
1548
#define tmp_disable_binlog(A) \
1549
{uint64_t tmp_disable_binlog__save_options= (A)->options; \
1550
(A)->options&= ~OPTION_BIN_LOG
1552
#define reenable_binlog(A) (A)->options= tmp_disable_binlog__save_options;}
1556
Used to hold information about file and file structure in exchange
1557
via non-DB file (...INTO OUTFILE..., ...LOAD DATA...)
1558
XXX: We never call destructor for objects of this class.
1561
class sql_exchange :public Sql_alloc
1564
enum enum_filetype filetype; /* load XML, Added by Arnold & Erik */
1566
String *field_term,*enclosed,*line_term,*line_start,*escaped;
1570
const CHARSET_INFO *cs;
1571
sql_exchange(char *name, bool dumpfile_flag,
1572
enum_filetype filetype_arg= FILETYPE_CSV);
1575
#include "log_event.h"
1578
This is used to get result from a select
1583
class select_result :public Sql_alloc {
1586
SELECT_LEX_UNIT *unit;
1589
virtual ~select_result() {};
1590
virtual int prepare(List<Item> &,
1596
virtual int prepare2(void) { return 0; }
1598
Because of peculiarities of prepared statements protocol
1599
we need to know number of columns in the result set (if
1600
there is a result set) apart from sending columns metadata.
1602
virtual uint32_t field_count(List<Item> &fields) const
1603
{ return fields.elements; }
1604
virtual bool send_fields(List<Item> &list, uint32_t flags)=0;
1605
virtual bool send_data(List<Item> &items)=0;
1606
virtual bool initialize_tables (JOIN *)
1608
virtual void send_error(uint32_t errcode,const char *err);
1609
virtual bool send_eof()=0;
1610
virtual void abort() {}
1612
Cleanup instance of this class for next execution of a prepared
1613
statement/stored procedure.
1615
virtual void cleanup();
1616
void set_session(Session *session_arg) { session= session_arg; }
1617
void begin_dataset() {}
1622
Base class for select_result descendands which intercept and
1623
transform result set rows. As the rows are not sent to the client,
1624
sending of result set metadata should be suppressed as well.
1627
class select_result_interceptor: public select_result
1630
select_result_interceptor() {} /* Remove gcc warning */
1631
uint32_t field_count(List<Item> &) const
1633
bool send_fields(List<Item> &,
1639
class select_send :public select_result {
1641
True if we have sent result set metadata to the client.
1642
In this case the client always expects us to end the result
1643
set with an eof or error packet
1645
bool is_result_set_started;
1647
select_send() :is_result_set_started(false) {}
1648
bool send_fields(List<Item> &list, uint32_t flags);
1649
bool send_data(List<Item> &items);
1652
virtual void cleanup();
1656
class select_to_file :public select_result_interceptor {
1658
sql_exchange *exchange;
1662
char path[FN_REFLEN];
1665
select_to_file(sql_exchange *ex) :exchange(ex), file(-1),row_count(0L)
1668
void send_error(uint32_t errcode,const char *err);
1684
1674
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
1686
} /* namespace drizzled */
1688
/** @TODO why is this in the middle of the file */
1689
#include <drizzled/select_to_file.h>
1690
#include <drizzled/select_export.h>
1691
#include <drizzled/select_dump.h>
1692
#include <drizzled/select_insert.h>
1693
#include <drizzled/select_create.h>
1694
#include <drizzled/tmp_table_param.h>
1695
#include <drizzled/select_union.h>
1696
#include <drizzled/select_subselect.h>
1697
#include <drizzled/select_singlerow_subselect.h>
1698
#include <drizzled/select_max_min_finder_subselect.h>
1699
#include <drizzled/select_exists_subselect.h>
1705
* A structure used to describe sort information
1706
* for a field or item used in ORDER BY.
1678
List of all possible characters of a numeric value text representation.
1680
#define NUMERIC_CHARS ".0123456789e+-"
1683
class select_export :public select_to_file {
1684
uint32_t field_term_length;
1685
int field_sep_char,escape_char,line_sep_char;
1686
int field_term_char; // first char of FIELDS TERMINATED BY or MAX_INT
1688
The is_ambiguous_field_sep field is true if a value of the field_sep_char
1689
field is one of the 'n', 't', 'r' etc characters
1690
(see the READ_INFO::unescape method and the ESCAPE_CHARS constant value).
1692
bool is_ambiguous_field_sep;
1694
The is_ambiguous_field_term is true if field_sep_char contains the first
1695
char of the FIELDS TERMINATED BY (ENCLOSED BY is empty), and items can
1696
contain this character.
1698
bool is_ambiguous_field_term;
1700
The is_unsafe_field_sep field is true if a value of the field_sep_char
1701
field is one of the '0'..'9', '+', '-', '.' and 'e' characters
1702
(see the NUMERIC_CHARS constant value).
1704
bool is_unsafe_field_sep;
1705
bool fixed_row_size;
1707
select_export(sql_exchange *ex) :select_to_file(ex) {}
1709
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1710
bool send_data(List<Item> &items);
1714
class select_dump :public select_to_file {
1716
select_dump(sql_exchange *ex) :select_to_file(ex) {}
1717
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1718
bool send_data(List<Item> &items);
1722
class select_insert :public select_result_interceptor {
1724
TableList *table_list;
1727
uint64_t autoinc_value_of_last_inserted_row; // autogenerated or not
1729
bool insert_into_view;
1730
select_insert(TableList *table_list_par,
1731
Table *table_par, List<Item> *fields_par,
1732
List<Item> *update_fields, List<Item> *update_values,
1733
enum_duplicates duplic, bool ignore);
1735
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1736
virtual int prepare2(void);
1737
bool send_data(List<Item> &items);
1738
virtual void store_values(List<Item> &values);
1739
virtual bool can_rollback_data() { return 0; }
1740
void send_error(uint32_t errcode,const char *err);
1743
/* not implemented: select_insert is never re-used in prepared statements */
1748
class select_create: public select_insert {
1750
TableList *create_table;
1751
HA_CREATE_INFO *create_info;
1752
TableList *select_tables;
1753
Alter_info *alter_info;
1755
/* lock data for tmp table */
1756
DRIZZLE_LOCK *m_lock;
1757
/* m_lock or session->extra_lock */
1758
DRIZZLE_LOCK **m_plock;
1760
select_create (TableList *table_arg,
1761
HA_CREATE_INFO *create_info_par,
1762
Alter_info *alter_info_arg,
1763
List<Item> &select_fields,enum_duplicates duplic, bool ignore,
1764
TableList *select_tables_arg)
1765
:select_insert (NULL, NULL, &select_fields, 0, 0, duplic, ignore),
1766
create_table(table_arg),
1767
create_info(create_info_par),
1768
select_tables(select_tables_arg),
1769
alter_info(alter_info_arg),
1772
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1774
void binlog_show_create_table(Table **tables, uint32_t count);
1775
void store_values(List<Item> &values);
1776
void send_error(uint32_t errcode,const char *err);
1779
virtual bool can_rollback_data() { return 1; }
1781
// Needed for access from local class MY_HOOKS in prepare(), since session is proteted.
1782
const Session *get_session(void) { return session; }
1783
const HA_CREATE_INFO *get_create_info() { return create_info; };
1784
int prepare2(void) { return 0; }
1787
#include <storage/myisam/myisam.h>
1790
Param to create temporary tables when doing SELECT:s
1792
This structure is copied using memcpy as a part of JOIN.
1795
class TMP_TABLE_PARAM :public Sql_alloc
1798
/* Prevent use of these (not safe because of lists and copy_field) */
1799
TMP_TABLE_PARAM(const TMP_TABLE_PARAM &);
1800
void operator=(TMP_TABLE_PARAM &);
1803
List<Item> copy_funcs;
1804
List<Item> save_copy_funcs;
1805
Copy_field *copy_field, *copy_field_end;
1806
Copy_field *save_copy_field, *save_copy_field_end;
1807
unsigned char *group_buff;
1808
Item **items_to_copy; /* Fields in tmp table */
1809
MI_COLUMNDEF *recinfo,*start_recinfo;
1811
ha_rows end_write_records;
1812
uint field_count,sum_func_count,func_count;
1813
uint32_t hidden_field_count;
1814
uint group_parts,group_length,group_null_parts;
1816
bool using_indirect_summary_function;
1817
/* If >0 convert all blob fields to varchar(convert_blob_length) */
1818
uint32_t convert_blob_length;
1819
const CHARSET_INFO *table_charset;
1822
True if GROUP BY and its aggregate functions are already computed
1823
by a table access method (e.g. by loose index scan). In this case
1824
query execution should not perform aggregation and should treat
1825
aggregate functions as normal functions.
1827
bool precomputed_group_by;
1828
bool force_copy_fields;
1830
If true, create_tmp_field called from create_tmp_table will convert
1831
all BIT fields to 64-bit longs. This is a workaround the limitation
1832
that MEMORY tables cannot index BIT columns.
1834
bool bit_fields_as_long;
1837
:copy_field(0), group_parts(0),
1838
group_length(0), group_null_parts(0), convert_blob_length(0),
1839
schema_table(0), precomputed_group_by(0), force_copy_fields(0),
1840
bit_fields_as_long(0)
1850
class select_union :public select_result_interceptor
1852
TMP_TABLE_PARAM tmp_table_param;
1856
select_union() :table(0) {}
1857
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
1858
bool send_data(List<Item> &items);
1862
bool create_result_table(Session *session, List<Item> *column_types,
1863
bool is_distinct, uint64_t options,
1864
const char *alias, bool bit_fields_as_long);
1867
/* Base subselect interface class */
1868
class select_subselect :public select_result_interceptor
1871
Item_subselect *item;
1873
select_subselect(Item_subselect *item);
1874
bool send_data(List<Item> &items)=0;
1875
bool send_eof() { return 0; };
1878
/* Single value subselect interface class */
1879
class select_singlerow_subselect :public select_subselect
1882
select_singlerow_subselect(Item_subselect *item_arg)
1883
:select_subselect(item_arg)
1885
bool send_data(List<Item> &items);
1888
/* used in independent ALL/ANY optimisation */
1889
class select_max_min_finder_subselect :public select_subselect
1892
bool (select_max_min_finder_subselect::*op)();
1895
select_max_min_finder_subselect(Item_subselect *item_arg, bool mx)
1896
:select_subselect(item_arg), cache(0), fmax(mx)
1899
bool send_data(List<Item> &items);
1906
/* EXISTS subselect interface class */
1907
class select_exists_subselect :public select_subselect
1910
select_exists_subselect(Item_subselect *item_arg)
1911
:select_subselect(item_arg){}
1912
bool send_data(List<Item> &items);
1915
/* Structs used when sorting */
1917
typedef struct st_sort_field {
1918
Field *field; /* Field to sort */
1919
Item *item; /* Item if not sorting fields */
1920
uint length; /* Length of sort field */
1921
uint32_t suffix_length; /* Length suffix (0-4) */
1922
Item_result result_type; /* Type of item */
1923
bool reverse; /* if descending sort */
1924
bool need_strxnfrm; /* If we have to use strxnfrm() */
1928
typedef struct st_sort_buffer {
1929
uint32_t index; /* 0 or 1 */
1930
uint32_t sort_orders;
1931
uint32_t change_pos; /* If sort-fields changed */
1933
SORT_FIELD *sortorder;
1936
/* Structure for db & table in sql_yacc */
1938
class Table_ident :public Sql_alloc
1943
SELECT_LEX_UNIT *sel;
1944
inline Table_ident(Session *session, LEX_STRING db_arg, LEX_STRING table_arg,
1946
:table(table_arg), sel((SELECT_LEX_UNIT *)0)
1948
if (!force && (session->client_capabilities & CLIENT_NO_SCHEMA))
1953
inline Table_ident(LEX_STRING table_arg)
1954
:table(table_arg), sel((SELECT_LEX_UNIT *)0)
1959
This constructor is used only for the case when we create a derived
1960
table. A derived table has no name and doesn't belong to any database.
1961
Later, if there was an alias specified for the table, it will be set
1962
by add_table_to_list.
1964
inline Table_ident(SELECT_LEX_UNIT *s) : sel(s)
1966
/* We must have a table name here as this is used with add_table_to_list */
1967
db.str= empty_c_string; /* a subject to casedn_str */
1969
table.str= internal_table_name;
1972
bool is_derived_table() const { return test(sel); }
1973
inline void change_db(char *db_name)
1975
db.str= db_name; db.length= (uint) strlen(db_name);
1979
// this is needed for user_vars hash
1980
class user_var_entry
1983
user_var_entry() {} /* Remove gcc warning */
1987
query_id_t update_query_id, used_query_id;
1991
double val_real(bool *null_value);
1992
int64_t val_int(bool *null_value) const;
1993
String *val_str(bool *null_value, String *str, uint32_t decimals);
1994
my_decimal *val_decimal(bool *null_value, my_decimal *result);
1995
DTCollation collation;
1999
Unique -- class for unique (removing of duplicates).
2000
Puts all values to the TREE. If the tree becomes too big,
2001
it's dumped to the file. User can request sorted values, or
2002
just iterate through them. In the last case tree merging is performed in
2003
memory simultaneously with iteration, so it should be ~2-3x faster.
1711
Field *field; /**< Field to sort */
1712
Item *item; /**< Item if not sorting fields */
1713
size_t length; /**< Length of sort field */
1714
uint32_t suffix_length; /**< Length suffix (0-4) */
1715
Item_result result_type; /**< Type of item */
1716
bool reverse; /**< if descending sort */
1717
bool need_strxnfrm; /**< If we have to use strxnfrm() */
1724
result_type(STRING_RESULT),
1731
} /* namespace drizzled */
1733
/** @TODO why is this in the middle of the file */
1735
#include <drizzled/table_ident.h>
1736
#include <drizzled/user_var_entry.h>
1737
#include <drizzled/unique.h>
1738
#include <drizzled/var.h>
1739
#include <drizzled/select_dumpvar.h>
2006
class Unique :public Sql_alloc
2008
DYNAMIC_ARRAY file_ptrs;
2010
size_t max_in_memory_size;
2013
unsigned char *record_pointers;
2019
Unique(qsort_cmp2 comp_func, void *comp_func_fixed_arg,
2020
uint32_t size_arg, size_t max_in_memory_size_arg);
2022
ulong elements_in_tree() { return tree.elements_in_tree; }
2023
inline bool unique_add(void *ptr)
2025
if (tree.elements_in_tree > max_elements && flush())
2027
return(!tree_insert(&tree, ptr, 0, tree.custom_arg));
2030
bool get(Table *table);
2031
static double get_use_cost(uint32_t *buffer, uint32_t nkeys, uint32_t key_size,
2032
size_t max_in_memory_size);
2033
inline static int get_cost_calc_buff_size(ulong nkeys, uint32_t key_size,
2034
size_t max_in_memory_size)
2036
register size_t max_elems_in_tree=
2037
(1 + max_in_memory_size / ALIGN_SIZE(sizeof(TREE_ELEMENT)+key_size));
2038
return (int) (sizeof(uint)*(1 + nkeys/max_elems_in_tree));
2042
bool walk(tree_walk_action action, void *walk_action_arg);
2044
friend int unique_write_to_file(unsigned char* key, element_count count, Unique *unique);
2045
friend int unique_write_to_ptrs(unsigned char* key, element_count count, Unique *unique);
2049
class multi_delete :public select_result_interceptor
2051
TableList *delete_tables, *table_being_deleted;
2053
ha_rows deleted, found;
2054
uint32_t num_of_tables;
2057
/* True if at least one table we delete from is transactional */
2058
bool transactional_tables;
2059
/* True if at least one table we delete from is not transactional */
2061
bool delete_while_scanning;
2063
error handling (rollback and binlogging) can happen in send_eof()
2064
so that afterward send_error() needs to find out that.
2069
multi_delete(TableList *dt, uint32_t num_of_tables);
2071
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2072
bool send_data(List<Item> &items);
2073
bool initialize_tables (JOIN *join);
2074
void send_error(uint32_t errcode,const char *err);
2077
virtual void abort();
2081
class multi_update :public select_result_interceptor
2083
TableList *all_tables; /* query/update command tables */
2084
TableList *leaves; /* list of leves of join table tree */
2085
TableList *update_tables, *table_being_updated;
2086
Table **tmp_tables, *main_table, *table_to_update;
2087
TMP_TABLE_PARAM *tmp_table_param;
2088
ha_rows updated, found;
2089
List <Item> *fields, *values;
2090
List <Item> **fields_for_table, **values_for_table;
2091
uint32_t table_count;
2093
List of tables referenced in the CHECK OPTION condition of
2094
the updated view excluding the updated table.
2096
List <Table> unupdated_check_opt_tables;
2097
Copy_field *copy_field;
2098
enum enum_duplicates handle_duplicates;
2099
bool do_update, trans_safe;
2100
/* True if the update operation has made a change in a transactional table */
2101
bool transactional_tables;
2104
error handling (rollback and binlogging) can happen in send_eof()
2105
so that afterward send_error() needs to find out that.
2110
multi_update(TableList *ut, TableList *leaves_list,
2111
List<Item> *fields, List<Item> *values,
2112
enum_duplicates handle_duplicates, bool ignore);
2114
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2115
bool send_data(List<Item> &items);
2116
bool initialize_tables (JOIN *join);
2117
void send_error(uint32_t errcode,const char *err);
2120
virtual void abort();
2123
class my_var : public Sql_alloc {
2128
enum_field_types type;
2129
my_var (LEX_STRING& j, bool i, uint32_t o, enum_field_types t)
2130
:s(j), local(i), offset(o), type(t)
2135
class select_dumpvar :public select_result_interceptor {
2138
List<my_var> var_list;
2139
select_dumpvar() { var_list.empty(); row_count= 0;}
2140
~select_dumpvar() {}
2141
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
2142
bool send_data(List<Item> &items);
1744
2147
/* Bits in sql_command_flags */
1746
enum sql_command_flag_bits
2149
enum sql_command_flag_bits {
1748
2150
CF_BIT_CHANGES_DATA,
1749
2151
CF_BIT_HAS_ROW_COUNT,
1750
2152
CF_BIT_STATUS_COMMAND,