~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_class.h

  • Committer: Monty Taylor
  • Date: 2008-10-22 01:52:54 UTC
  • Revision ID: monty@inaugust.com-20081022015254-65qfk9f2v0b8jlk3
Moved drizzle_com to drizzled/drizzle_common. Started splitting it up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
 
21
21
/* Classes in mysql */
 
22
 
22
23
#include <drizzled/global.h>
23
24
#include "log.h"
24
25
#include "rpl_tblmap.h"
35
36
enum enum_ha_read_modes { RFIRST, RNEXT, RPREV, RLAST, RKEY, RNEXT_SAME };
36
37
enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_UPDATE };
37
38
enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON,
38
 
                            DELAY_KEY_WRITE_ALL };
 
39
                            DELAY_KEY_WRITE_ALL };
39
40
enum enum_slave_exec_mode { SLAVE_EXEC_MODE_STRICT,
40
41
                            SLAVE_EXEC_MODE_IDEMPOTENT,
41
42
                            SLAVE_EXEC_MODE_LAST_BIT};
97
98
 
98
99
class Key_part_spec :public Sql_alloc {
99
100
public:
100
 
  LEX_STRING field_name;
 
101
  const LEX_STRING field_name;
101
102
  uint32_t length;
102
103
  Key_part_spec(const LEX_STRING &name, uint32_t len)
103
104
    : field_name(name), length(len)
113
114
    is why we supply it with a copy.
114
115
 
115
116
    @return If out of memory, 0 is returned and an error is set in
116
 
    THD.
 
117
    Session.
117
118
  */
118
119
  Key_part_spec *clone(MEM_ROOT *mem_root) const
119
120
  { return new (mem_root) Key_part_spec(*this); }
214
215
  */
215
216
  virtual Key *clone(MEM_ROOT *mem_root) const
216
217
  { return new (mem_root) Foreign_key(*this, mem_root); }
 
218
  /* Used to validate foreign key options */
 
219
  bool validate(List<Create_field> &table_fields);
217
220
};
218
221
 
219
222
typedef struct st_mysql_lock
235
238
class select_result;
236
239
class Time_zone;
237
240
 
238
 
#define THD_SENTRY_MAGIC 0xfeedd1ff
239
 
#define THD_SENTRY_GONE  0xdeadbeef
 
241
#define Session_SENTRY_MAGIC 0xfeedd1ff
 
242
#define Session_SENTRY_GONE  0xdeadbeef
240
243
 
241
 
#define THD_CHECK_SENTRY(thd) assert(thd->dbug_sentry == THD_SENTRY_MAGIC)
 
244
#define Session_CHECK_SENTRY(session) assert(session->dbug_sentry == Session_SENTRY_MAGIC)
242
245
 
243
246
struct system_variables
244
247
{
260
263
  uint64_t myisam_max_sort_file_size;
261
264
  uint64_t max_heap_table_size;
262
265
  uint64_t tmp_table_size;
263
 
  uint64_t long_query_time;
264
266
  ha_rows select_limit;
265
267
  ha_rows max_join_size;
266
268
  ulong auto_increment_increment, auto_increment_offset;
293
295
  /* A bitmap for switching optimizations on/off */
294
296
  ulong optimizer_switch;
295
297
  ulong preload_buff_size;
296
 
  ulong profiling_history_size;
297
 
  ulong query_cache_type;
298
298
  ulong read_buff_size;
299
299
  ulong read_rnd_buff_size;
300
300
  ulong div_precincrement;
313
313
  ulong trans_prealloc_size;
314
314
  ulong log_warnings;
315
315
  ulong group_concat_max_len;
316
 
  ulong binlog_format; // binlog format for this thd (see enum_binlog_format)
 
316
  ulong binlog_format; // binlog format for this session (see enum_binlog_format)
317
317
  /*
318
318
    In slave thread we need to know in behalf of which
319
319
    thread the query is being run to replicate temp tables properly
440
440
 
441
441
#define last_system_status_var questions
442
442
 
443
 
void mark_transaction_to_rollback(THD *thd, bool all);
 
443
void mark_transaction_to_rollback(Session *session, bool all);
444
444
 
445
445
#ifdef DRIZZLE_SERVER
446
446
 
498
498
  One connection can contain a lot of simultaneously running statements,
499
499
  some of which could be:
500
500
   - prepared, that is, contain placeholders,
501
 
  To perform some action with statement we reset THD part to the state  of
502
 
  that statement, do the action, and then save back modified state from THD
 
501
  To perform some action with statement we reset Session part to the state  of
 
502
  that statement, do the action, and then save back modified state from Session
503
503
  to the statement. It will be changed in near future, and Statement will
504
504
  be used explicitly.
505
505
*/
520
520
                        handler of fields used is set
521
521
    MARK_COLUMNS_READ:  Means a bit in read set is set to inform handler
522
522
                        that the field is to be read. If field list contains
523
 
                        duplicates, then thd->dup_field is set to point
 
523
                        duplicates, then session->dup_field is set to point
524
524
                        to the last found duplicate.
525
525
    MARK_COLUMNS_WRITE: Means a bit is set in write set to inform handler
526
526
                        that it needs to update this field in write_row
539
539
    LOCK_thread_count mutex. And (B) we are ONLY allowed to set query to a
540
540
    non-NULL value if its previous value is NULL. We do not need to protect
541
541
    operation (B) with any mutex. To avoid crashes in races, if we do not
542
 
    know that thd->query cannot change at the moment, one should print
543
 
    thd->query like this:
 
542
    know that session->query cannot change at the moment, one should print
 
543
    session->query like this:
544
544
      (1) reserve the LOCK_thread_count mutex;
545
 
      (2) check if thd->query is NULL;
546
 
      (3) if not NULL, then print at most thd->query_length characters from
 
545
      (2) check if session->query is NULL;
 
546
      (3) if not NULL, then print at most session->query_length characters from
547
547
      it. We will see the query_length field as either 0, or the right value
548
548
      for it.
549
549
    Assuming that the write and read of an n-bit memory field in an n-bit
563
563
    valid database name.
564
564
 
565
565
    @note this attribute is set and alloced by the slave SQL thread (for
566
 
    the THD of that thread); that thread is (and must remain, for now) the
 
566
    the Session of that thread); that thread is (and must remain, for now) the
567
567
    only responsible for freeing this member.
568
568
  */
569
569
 
593
593
  /* For now, this is only used to catch duplicated external xids */
594
594
  XID  xid;                           // transaction identifier
595
595
  enum xa_states xa_state;            // used by external XA only
596
 
  bool in_thd;
 
596
  bool in_session;
597
597
} XID_STATE;
598
598
 
599
599
extern pthread_mutex_t LOCK_xid_cache;
607
607
 
608
608
/**
609
609
  @class Security_context
610
 
  @brief A set of THD members describing the current authenticated user.
 
610
  @brief A set of Session members describing the current authenticated user.
611
611
*/
612
612
 
613
613
class Security_context {
690
690
    Tables that were locked with explicit or implicit LOCK TABLES.
691
691
    (Implicit LOCK TABLES happens when we are prelocking tables for
692
692
     execution of statement which uses stored routines. See description
693
 
     THD::prelocked_mode for more info.)
 
693
     Session::prelocked_mode for more info.)
694
694
  */
695
695
  DRIZZLE_LOCK *locked_tables;
696
696
 
735
735
};
736
736
 
737
737
 
738
 
/* Flags for the THD::system_thread variable */
 
738
/* Flags for the Session::system_thread variable */
739
739
enum enum_thread_type
740
740
{
741
741
  NON_SYSTEM_THREAD,
769
769
    from the anticipated conditions trapped during runtime.
770
770
 
771
771
    This mechanism is similar to C++ try/throw/catch:
772
 
    - 'try' correspond to <code>THD::push_internal_handler()</code>,
 
772
    - 'try' correspond to <code>Session::push_internal_handler()</code>,
773
773
    - 'throw' correspond to <code>my_error()</code>,
774
774
    which invokes <code>my_message_sql()</code>,
775
775
    - 'catch' correspond to checking how/if an internal handler was invoked,
776
776
    before removing it from the exception stack with
777
 
    <code>THD::pop_internal_handler()</code>.
 
777
    <code>Session::pop_internal_handler()</code>.
778
778
 
779
779
    @param sql_errno the error number
780
780
    @param level the error level
781
 
    @param thd the calling thread
 
781
    @param session the calling thread
782
782
    @return true if the error is handled
783
783
  */
784
784
  virtual bool handle_error(uint32_t sql_errno,
785
785
                            const char *message,
786
786
                            DRIZZLE_ERROR::enum_warning_level level,
787
 
                            THD *thd) = 0;
 
787
                            Session *session) = 0;
788
788
};
789
789
 
790
790
 
816
816
  /** Set to make set_error_status after set_{ok,eof}_status possible. */
817
817
  bool can_overwrite_status;
818
818
 
819
 
  void set_ok_status(THD *thd, ha_rows affected_rows_arg,
 
819
  void set_ok_status(Session *session, ha_rows affected_rows_arg,
820
820
                     uint64_t last_insert_id_arg,
821
821
                     const char *message);
822
 
  void set_eof_status(THD *thd);
823
 
  void set_error_status(THD *thd, uint32_t sql_errno_arg, const char *message_arg);
 
822
  void set_eof_status(Session *session);
 
823
  void set_error_status(Session *session, uint32_t sql_errno_arg, const char *message_arg);
824
824
 
825
825
  void disable_status();
826
826
 
869
869
  uint32_t m_sql_errno;
870
870
 
871
871
  /**
872
 
    Copied from thd->server_status when the diagnostics area is assigned.
 
872
    Copied from session->server_status when the diagnostics area is assigned.
873
873
    We need this member as some places in the code use the following pattern:
874
 
    thd->server_status|= ...
875
 
    my_eof(thd);
876
 
    thd->server_status&= ~...
 
874
    session->server_status|= ...
 
875
    my_eof(session);
 
876
    session->server_status&= ~...
877
877
    Assigned by OK, EOF or ERROR.
878
878
  */
879
879
  uint32_t m_server_status;
880
880
  /**
881
881
    The number of rows affected by the last statement. This is
882
 
    semantically close to thd->row_count_func, but has a different
883
 
    life cycle. thd->row_count_func stores the value returned by
 
882
    semantically close to session->row_count_func, but has a different
 
883
    life cycle. session->row_count_func stores the value returned by
884
884
    function ROW_COUNT() and is cleared only by statements that
885
885
    update its value, such as INSERT, UPDATE, DELETE and few others.
886
886
    This member is cleared at the beginning of the next statement.
887
887
 
888
 
    We could possibly merge the two, but life cycle of thd->row_count_func
 
888
    We could possibly merge the two, but life cycle of session->row_count_func
889
889
    can not be changed.
890
890
  */
891
891
  ha_rows    m_affected_rows;
892
892
  /**
893
893
    Similarly to the previous member, this is a replacement of
894
 
    thd->first_successful_insert_id_in_prev_stmt, which is used
 
894
    session->first_successful_insert_id_in_prev_stmt, which is used
895
895
    to implement LAST_INSERT_ID().
896
896
  */
897
897
  uint64_t   m_last_insert_id;
899
899
  uint       m_total_warn_count;
900
900
  enum_diagnostics_status m_status;
901
901
  /**
902
 
    @todo: the following THD members belong here:
 
902
    @todo: the following Session members belong here:
903
903
    - warn_list, warn_count,
904
904
  */
905
905
};
933
933
 
934
934
 
935
935
/**
936
 
  @class THD
937
 
  For each client connection we create a separate thread with THD serving as
 
936
  @class Session
 
937
  For each client connection we create a separate thread with Session serving as
938
938
  a thread/connection descriptor
939
939
*/
940
940
 
941
 
class THD :public Statement,
 
941
class Session :public Statement,
942
942
           public Open_tables_state
943
943
{
944
944
public:
946
946
  Relay_log_info* rli_fake;
947
947
 
948
948
  /*
949
 
    Constant for THD::where initialization in the beginning of every query.
 
949
    Constant for Session::where initialization in the beginning of every query.
950
950
 
951
 
    It's needed because we do not save/restore THD::where normally during
 
951
    It's needed because we do not save/restore Session::where normally during
952
952
    primary (non subselect) query execution.
953
953
  */
954
954
  static const char * const DEFAULT_WHERE;
968
968
  THR_LOCK_OWNER main_lock_id;          // To use for conventional queries
969
969
  THR_LOCK_OWNER *lock_id;              // If not main_lock_id, points to
970
970
                                        // the lock_id of a cursor.
971
 
  pthread_mutex_t LOCK_delete;          // Locked before thd is deleted
 
971
  pthread_mutex_t LOCK_delete;          // Locked before session is deleted
972
972
  /*
973
973
    A pointer to the stack frame of handle_one_connection(),
974
974
    which is called first in the thread for handling a client
982
982
 
983
983
  /**
984
984
    @note
985
 
    Some members of THD (currently 'Statement::db',
 
985
    Some members of Session (currently 'Statement::db',
986
986
    'catalog' and 'query')  are set and alloced by the slave SQL thread
987
 
    (for the THD of that thread); that thread is (and must remain, for now)
 
987
    (for the Session of that thread); that thread is (and must remain, for now)
988
988
    the only responsible for freeing these 3 members. If you add members
989
989
    here, and you add code to set them in replication, don't forget to
990
990
    free_them_and_set_them_to_0 in replication properly. For details see
998
998
 
999
999
  /*
1000
1000
    Points to info-string that we show in SHOW PROCESSLIST
1001
 
    You are supposed to call THD_SET_PROC_INFO only if you have coded
 
1001
    You are supposed to call Session_SET_PROC_INFO only if you have coded
1002
1002
    a time-consuming piece that MySQL can get stuck in for a long time.
1003
1003
 
1004
 
    Set it using the  thd_proc_info(THD *thread, const char *message)
 
1004
    Set it using the  session_proc_info(Session *thread, const char *message)
1005
1005
    macro/function.
1006
1006
  */
1007
1007
  void        set_proc_info(const char *info) { proc_info= info; }
1041
1041
  
1042
1042
  thr_lock_type update_lock_default;
1043
1043
 
1044
 
  /* <> 0 if we are inside of trigger or stored function. */
1045
 
  uint32_t in_sub_stmt;
1046
 
 
1047
1044
  /* container for handler's private per-connection data */
1048
1045
  Ha_data ha_data[MAX_HA];
1049
1046
 
1050
1047
  /* Place to store various things */
1051
 
  void *thd_marker;
 
1048
  void *session_marker;
1052
1049
  int binlog_setup_trx_data();
1053
1050
 
1054
1051
  /*
1103
1100
 
1104
1101
  struct st_transactions {
1105
1102
    SAVEPOINT *savepoints;
1106
 
    THD_TRANS all;                      // Trans since BEGIN WORK
1107
 
    THD_TRANS stmt;                     // Trans for current statement
 
1103
    Session_TRANS all;                  // Trans since BEGIN WORK
 
1104
    Session_TRANS stmt;                 // Trans for current statement
1108
1105
    bool on;                            // see ha_enable_transaction()
1109
1106
    XID_STATE xid_state;
1110
1107
    Rows_log_event *m_pending_rows_event;
1134
1131
  /*
1135
1132
    This is to track items changed during execution of a prepared
1136
1133
    statement/stored procedure. It's created by
1137
 
    register_item_tree_change() in memory root of THD, and freed in
 
1134
    register_item_tree_change() in memory root of Session, and freed in
1138
1135
    rollback_item_tree_changes(). For conventional execution it's always
1139
1136
    empty.
1140
1137
  */
1293
1290
  /*
1294
1291
    The set of those tables whose fields are referenced in all subqueries
1295
1292
    of the query.
1296
 
    TODO: possibly this it is incorrect to have used tables in THD because
 
1293
    TODO: possibly this it is incorrect to have used tables in Session because
1297
1294
    with more than one subquery, it is not clear what does the field mean.
1298
1295
  */
1299
1296
  table_map  used_tables;
1369
1366
    can not continue. In particular, disables activation of
1370
1367
    CONTINUE or EXIT handlers of stored routines.
1371
1368
    Reset in the end of processing of the current user request, in
1372
 
    @see mysql_reset_thd_for_next_command().
 
1369
    @see mysql_reset_session_for_next_command().
1373
1370
  */
1374
1371
  bool is_fatal_error;
1375
1372
  /**
1401
1398
    it returned an error on master, and this is OK on the slave.
1402
1399
  */
1403
1400
  bool       is_slave_error;
1404
 
  bool       bootstrap, cleanup_done;
 
1401
  bool       cleanup_done;
1405
1402
  
1406
1403
  /**  is set if some thread specific value(s) used in a statement. */
1407
1404
  bool       thread_specific_used;
1408
1405
  bool       charset_is_system_charset, charset_is_collation_connection;
1409
1406
  bool       charset_is_character_set_filesystem;
1410
 
  bool       enable_slow_log;   /* enable slow log for current statement */
1411
1407
  bool       abort_on_warning;
1412
1408
  bool       got_warning;       /* Set on call to push_warning() */
1413
1409
  bool       no_warnings_for_error; /* no warnings on call to my_error() */
1452
1448
    
1453
1449
    /* 
1454
1450
      'queries' (actually SP statements) that run under inside this binlog
1455
 
      union have thd->query_id >= first_query_id.
 
1451
      union have session->query_id >= first_query_id.
1456
1452
    */
1457
1453
    query_id_t first_query_id;
1458
1454
  } binlog_evt_union;
1466
1462
  */
1467
1463
  Lex_input_stream *m_lip;
1468
1464
 
1469
 
  THD();
1470
 
  ~THD();
 
1465
  Session();
 
1466
  ~Session();
1471
1467
 
1472
1468
  void init(void);
1473
1469
  /*
1474
1470
    Initialize memory roots necessary for query processing and (!)
1475
 
    pre-allocate memory for it. We can't do that in THD constructor because
 
1471
    pre-allocate memory for it. We can't do that in Session constructor because
1476
1472
    there are use cases (acl_init, watcher threads,
1477
1473
    killing mysqld) where it's vital to not allocate excessive and not used
1478
1474
    memory. Note, that we still don't return error from init_for_queries():
1484
1480
  void cleanup(void);
1485
1481
  void cleanup_after_query();
1486
1482
  bool store_globals();
1487
 
  void awake(THD::killed_state state_to_set);
 
1483
  void awake(Session::killed_state state_to_set);
1488
1484
 
1489
1485
  enum enum_binlog_query_type {
1490
1486
    /*
1508
1504
  int binlog_query(enum_binlog_query_type qtype,
1509
1505
                   char const *query, ulong query_len,
1510
1506
                   bool is_trans, bool suppress_use,
1511
 
                   THD::killed_state killed_err_arg= THD::KILLED_NO_VALUE);
 
1507
                   Session::killed_state killed_err_arg= Session::KILLED_NO_VALUE);
1512
1508
 
1513
1509
  /*
1514
1510
    For enter_cond() / exit_cond() to work the mutex must be got before
1522
1518
    safe_mutex_assert_owner(mutex);
1523
1519
    mysys_var->current_mutex = mutex;
1524
1520
    mysys_var->current_cond = cond;
1525
 
    thd_proc_info(this, msg);
 
1521
    this->set_proc_info(msg);
1526
1522
    return old_msg;
1527
1523
  }
1528
1524
  inline void exit_cond(const char* old_msg)
1531
1527
      Putting the mutex unlock in exit_cond() ensures that
1532
1528
      mysys_var->current_mutex is always unlocked _before_ mysys_var->mutex is
1533
1529
      locked (if that would not be the case, you'll get a deadlock if someone
1534
 
      does a THD::awake() on you).
 
1530
      does a Session::awake() on you).
1535
1531
    */
1536
1532
    pthread_mutex_unlock(mysys_var->current_mutex);
1537
1533
    pthread_mutex_lock(&mysys_var->mutex);
1538
1534
    mysys_var->current_mutex = 0;
1539
1535
    mysys_var->current_cond = 0;
1540
 
    thd_proc_info(this, old_msg);
 
1536
    this->set_proc_info(old_msg);
1541
1537
    pthread_mutex_unlock(&mysys_var->mutex);
1542
1538
  }
1543
1539
  inline time_t query_start() { query_start_used=1; return start_time; }
1663
1659
 
1664
1660
  inline void set_current_stmt_binlog_row_based_if_mixed()
1665
1661
  {
1666
 
    /*
1667
 
      If in a stored/function trigger, the caller should already have done the
1668
 
      change. We test in_sub_stmt to prevent introducing bugs where people
1669
 
      wouldn't ensure that, and would switch to row-based mode in the middle
1670
 
      of executing a stored function/trigger (which is too late, see also
1671
 
      reset_current_stmt_binlog_row_based()); this condition will make their
1672
 
      tests fail and so force them to propagate the
1673
 
      lex->binlog_row_based_if_mixed upwards to the caller.
1674
 
    */
1675
 
    if ((variables.binlog_format == BINLOG_FORMAT_MIXED) &&
1676
 
        (in_sub_stmt == 0))
 
1662
    if (variables.binlog_format == BINLOG_FORMAT_MIXED)
1677
1663
      current_stmt_binlog_row_based= true;
1678
1664
  }
1679
1665
  inline void set_current_stmt_binlog_row_based()
1692
1678
      CREATE TEMPORARY TABLE t SELECT UUID(); # row-based
1693
1679
      # and row-based does not store updates to temp tables
1694
1680
      # in the binlog.
1695
 
      INSERT INTO u SELECT * FROM t; # stmt-based
1696
 
      and then the INSERT will fail as data inserted into t was not logged.
1697
 
      So we continue with row-based until the temp table is dropped.
1698
 
      If we are in a stored function or trigger, we mustn't reset in the
1699
 
      middle of its execution (as the binary logging way of a stored function
1700
 
      or trigger is decided when it starts executing, depending for example on
1701
 
      the caller (for a stored function: if caller is SELECT or
1702
 
      INSERT/UPDATE/DELETE...).
1703
1681
 
1704
1682
      Don't reset binlog format for NDB binlog injector thread.
1705
1683
    */
1706
 
    if ((temporary_tables == NULL) && (in_sub_stmt == 0))
 
1684
    if (temporary_tables == NULL)
1707
1685
    {
1708
1686
      current_stmt_binlog_row_based= 
1709
1687
        test(variables.binlog_format == BINLOG_FORMAT_ROW);
1771
1749
    a statement is parsed but before it's executed.
1772
1750
  */
1773
1751
  bool copy_db_to(char **p_db, size_t *p_db_length);
1774
 
  thd_scheduler scheduler;
 
1752
  session_scheduler scheduler;
1775
1753
 
1776
1754
public:
1777
1755
  /**
1818
1796
};
1819
1797
 
1820
1798
 
1821
 
/** A short cut for thd->main_da.set_ok_status(). */
 
1799
/** A short cut for session->main_da.set_ok_status(). */
1822
1800
 
1823
1801
inline void
1824
 
my_ok(THD *thd, ha_rows affected_rows= 0, uint64_t id= 0,
 
1802
my_ok(Session *session, ha_rows affected_rows= 0, uint64_t id= 0,
1825
1803
        const char *message= NULL)
1826
1804
{
1827
 
  thd->main_da.set_ok_status(thd, affected_rows, id, message);
 
1805
  session->main_da.set_ok_status(session, affected_rows, id, message);
1828
1806
}
1829
1807
 
1830
1808
 
1831
 
/** A short cut for thd->main_da.set_eof_status(). */
 
1809
/** A short cut for session->main_da.set_eof_status(). */
1832
1810
 
1833
1811
inline void
1834
 
my_eof(THD *thd)
 
1812
my_eof(Session *session)
1835
1813
{
1836
 
  thd->main_da.set_eof_status(thd);
 
1814
  session->main_da.set_eof_status(session);
1837
1815
}
1838
1816
 
1839
1817
#define tmp_disable_binlog(A)       \
1873
1851
 
1874
1852
class select_result :public Sql_alloc {
1875
1853
protected:
1876
 
  THD *thd;
 
1854
  Session *session;
1877
1855
  SELECT_LEX_UNIT *unit;
1878
1856
public:
1879
1857
  select_result();
1912
1890
    statement/stored procedure.
1913
1891
  */
1914
1892
  virtual void cleanup();
1915
 
  void set_thd(THD *thd_arg) { thd= thd_arg; }
 
1893
  void set_session(Session *session_arg) { session= session_arg; }
1916
1894
  void begin_dataset() {}
1917
1895
};
1918
1896
 
2053
2031
  Field **field;
2054
2032
  /* lock data for tmp table */
2055
2033
  DRIZZLE_LOCK *m_lock;
2056
 
  /* m_lock or thd->extra_lock */
 
2034
  /* m_lock or session->extra_lock */
2057
2035
  DRIZZLE_LOCK **m_plock;
2058
2036
public:
2059
2037
  select_create (TableList *table_arg,
2077
2055
  void abort();
2078
2056
  virtual bool can_rollback_data() { return 1; }
2079
2057
 
2080
 
  // Needed for access from local class MY_HOOKS in prepare(), since thd is proteted.
2081
 
  const THD *get_thd(void) { return thd; }
 
2058
  // Needed for access from local class MY_HOOKS in prepare(), since session is proteted.
 
2059
  const Session *get_session(void) { return session; }
2082
2060
  const HA_CREATE_INFO *get_create_info() { return create_info; };
2083
2061
  int prepare2(void) { return 0; }
2084
2062
};
2165
2143
  bool send_eof();
2166
2144
  bool flush();
2167
2145
  void cleanup();
2168
 
  bool create_result_table(THD *thd, List<Item> *column_types,
 
2146
  bool create_result_table(Session *session, List<Item> *column_types,
2169
2147
                           bool is_distinct, uint64_t options,
2170
2148
                           const char *alias, bool bit_fields_as_long);
2171
2149
};
2247
2225
  LEX_STRING db;
2248
2226
  LEX_STRING table;
2249
2227
  SELECT_LEX_UNIT *sel;
2250
 
  inline Table_ident(THD *thd, LEX_STRING db_arg, LEX_STRING table_arg,
 
2228
  inline Table_ident(Session *session, LEX_STRING db_arg, LEX_STRING table_arg,
2251
2229
                     bool force)
2252
2230
    :table(table_arg), sel((SELECT_LEX_UNIT *)0)
2253
2231
  {
2254
 
    if (!force && (thd->client_capabilities & CLIENT_NO_SCHEMA))
 
2232
    if (!force && (session->client_capabilities & CLIENT_NO_SCHEMA))
2255
2233
      db.str=0;
2256
2234
    else
2257
2235
      db= db_arg;