~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

Merge Stewart - fix bug 587772: READ COMMITTED isolation level doesn't work (at least with InnoDB)

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
#include "drizzled/transaction_context.h"
37
37
#include "drizzled/util/storable.h"
38
38
#include "drizzled/my_hash.h"
39
 
#include "drizzled/pthread_globals.h"
 
39
 
40
40
#include <netdb.h>
41
 
#include <sys/time.h>
42
 
#include <sys/resource.h>
43
 
 
44
 
#include <algorithm>
 
41
#include <map>
 
42
#include <string>
45
43
#include <bitset>
46
44
#include <deque>
47
 
#include <map>
48
 
#include <string>
49
45
 
50
 
#include "drizzled/identifier.h"
 
46
#include "drizzled/internal/getrusage.h"
 
47
#include "drizzled/security_context.h"
51
48
#include "drizzled/open_tables_state.h"
52
49
#include "drizzled/internal_error_handler.h"
53
50
#include "drizzled/diagnostics_area.h"
54
51
#include "drizzled/plugin/authorization.h"
55
52
 
56
53
#include <boost/unordered_map.hpp>
57
 
 
58
 
#include <boost/thread/thread.hpp>
59
54
#include <boost/thread/mutex.hpp>
60
55
#include <boost/thread/shared_mutex.hpp>
61
56
#include <boost/thread/condition_variable.hpp>
62
 
#include <boost/make_shared.hpp>
63
 
 
64
57
 
65
58
#define MIN_HANDSHAKE_SIZE      6
66
59
 
126
119
      of the INSERT ... ON DUPLICATE KEY UPDATE no matter whether the row
127
120
      was actually changed or not.
128
121
*/
129
 
class CopyInfo 
 
122
struct CopyInfo 
130
123
{
131
 
public:
132
124
  ha_rows records; /**< Number of processed records */
133
125
  ha_rows deleted; /**< Number of deleted records */
134
126
  ha_rows updated; /**< Number of updated records */
176
168
struct drizzle_system_variables
177
169
{
178
170
  drizzle_system_variables()
179
 
  {}
 
171
  {};
180
172
  /*
181
173
    How dynamically allocated system variables are handled:
182
174
 
213
205
  uint64_t preload_buff_size;
214
206
  uint32_t read_buff_size;
215
207
  uint32_t read_rnd_buff_size;
216
 
  bool replicate_query;
217
208
  size_t sortbuff_size;
218
209
  uint32_t thread_handling;
219
210
  uint32_t tx_isolation;
317
308
public:
318
309
  // Plugin storage in Session.
319
310
  typedef boost::unordered_map<std::string, util::Storable *, util::insensitive_hash, util::insensitive_equal_to> PropertyMap;
320
 
  typedef Session* Ptr;
321
 
  typedef boost::shared_ptr<Session> shared_ptr;
322
311
 
323
312
  /*
324
313
    MARK_COLUMNS_NONE:  Means mark_used_colums is not set and no indicator to
376
365
  {
377
366
    return mem_root;
378
367
  }
379
 
 
380
 
  uint64_t xa_id;
381
 
 
382
 
  uint64_t getXaId()
383
 
  {
384
 
    return xa_id;
385
 
  }
386
 
 
387
 
  void setXaId(uint64_t in_xa_id)
388
 
  {
389
 
    xa_id= in_xa_id; 
390
 
  }
391
 
 
392
368
  /**
393
369
   * Uniquely identifies each statement object in thread scope; change during
394
370
   * statement lifetime.
403
379
    return lex;
404
380
  }
405
381
  /** query associated with this statement */
406
 
  typedef boost::shared_ptr<const std::string> QueryString;
407
 
private:
408
 
  boost::shared_ptr<std::string> query;
409
 
 
410
 
  // Never allow for a modification of this outside of the class. c_str()
411
 
  // requires under some setup non const, you must copy the QueryString in
412
 
  // order to use it.
413
 
public:
414
 
  QueryString getQueryString() const
415
 
  {
416
 
    return query;
417
 
  }
418
 
 
419
 
  void resetQueryString()
420
 
  {
421
 
    query.reset();
422
 
    _state.reset();
423
 
  }
424
 
 
425
 
  /*
426
 
    We need to copy the lock on the string in order to make sure we have a stable string.
427
 
    Once this is done we can use it to build a const char* which can be handed off for
428
 
    a method to use (Innodb is currently the only engine using this).
429
 
  */
430
 
  const char *getQueryStringCopy(size_t &length)
431
 
  {
432
 
    QueryString tmp_string(getQueryString());
433
 
 
434
 
    assert(tmp_string);
435
 
    if (not tmp_string)
436
 
    {
437
 
      length= 0;
438
 
      return 0;
439
 
    }
440
 
 
441
 
    length= tmp_string->length();
442
 
    char *to_return= strmake(tmp_string->c_str(), tmp_string->length());
443
 
    return to_return;
444
 
  }
445
 
 
446
 
  class State {
447
 
    std::vector <char> _query;
448
 
 
449
 
  public:
450
 
    typedef boost::shared_ptr<State> const_shared_ptr;
451
 
 
452
 
    State(const char *in_packet, size_t in_packet_length)
453
 
    {
454
 
      if (in_packet_length)
455
 
      {
456
 
        size_t minimum= std::min(in_packet_length, static_cast<size_t>(PROCESS_LIST_WIDTH));
457
 
        _query.resize(minimum + 1);
458
 
        memcpy(&_query[0], in_packet, minimum);
459
 
      }
460
 
      else
461
 
      {
462
 
        _query.resize(0);
463
 
      }
464
 
    }
465
 
 
466
 
    const char *query() const
467
 
    {
468
 
      if (_query.size())
469
 
        return &_query[0];
470
 
 
471
 
      return "";
472
 
    }
473
 
 
474
 
    const char *query(size_t &size) const
475
 
    {
476
 
      if (_query.size())
477
 
      {
478
 
        size= _query.size() -1;
479
 
        return &_query[0];
480
 
      }
481
 
 
482
 
      size= 0;
483
 
      return "";
484
 
    }
485
 
  protected:
486
 
    friend class Session;
487
 
    typedef boost::shared_ptr<State> shared_ptr;
488
 
  };
489
 
private:
490
 
  State::shared_ptr  _state; 
491
 
public:
492
 
 
493
 
  State::const_shared_ptr state()
494
 
  {
495
 
    return _state;
496
 
  }
 
382
  std::string query;
497
383
 
498
384
  /**
499
385
    Name of the current (default) database.
507
393
    the Session of that thread); that thread is (and must remain, for now) the
508
394
    only responsible for freeing this member.
509
395
  */
510
 
private:
511
 
  util::string::shared_ptr _schema;
512
 
public:
513
 
 
514
 
  util::string::const_shared_ptr schema() const
515
 
  {
516
 
    if (_schema)
517
 
      return _schema;
518
 
 
519
 
    return util::string::const_shared_ptr(new std::string(""));
520
 
  }
 
396
  std::string db;
521
397
  std::string catalog;
522
398
  /* current cache key */
523
399
  std::string query_cache_key;
531
407
 
532
408
  memory::Root warn_root; /**< Allocation area for warnings and errors */
533
409
  plugin::Client *client; /**< Pointer to client object */
534
 
 
535
 
  void setClient(plugin::Client *client_arg);
536
 
 
537
 
  plugin::Client *getClient()
538
 
  {
539
 
    return client;
540
 
  }
541
 
 
542
410
  plugin::Scheduler *scheduler; /**< Pointer to scheduler object */
543
411
  void *scheduler_arg; /**< Pointer to the optional scheduler argument */
544
 
 
 
412
private:
545
413
  typedef boost::unordered_map< std::string, user_var_entry *, util::insensitive_hash, util::insensitive_equal_to> UserVars;
546
 
private:
547
414
  typedef std::pair< UserVars::iterator, UserVars::iterator > UserVarsRange;
548
415
  UserVars user_vars; /**< Hash of user variables defined during the session's lifetime */
549
416
 
550
417
public:
551
 
 
552
 
  const UserVars &getUserVariables() const
553
 
  {
554
 
    return user_vars;
555
 
  }
556
 
 
557
418
  drizzle_system_variables variables; /**< Mutable local variables local to the session */
558
419
  struct system_status_var status_var; /**< Session-local status counters */
559
420
  THR_LOCK_INFO lock_info; /**< Locking information for this session */
560
421
  THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
561
422
  THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
 
423
private:
 
424
  boost::mutex LOCK_delete; /**< Locked before session is deleted */
 
425
public:
 
426
 
 
427
  void lockForDelete()
 
428
  {
 
429
    LOCK_delete.lock();
 
430
  }
 
431
 
 
432
  void unlockForDelete()
 
433
  {
 
434
    LOCK_delete.unlock();
 
435
  }
 
436
 
 
437
  /**
 
438
   * A peek into the query string for the session. This is a best effort
 
439
   * delivery, there is no guarantee whether the content is meaningful.
 
440
   */
 
441
  char process_list_info[PROCESS_LIST_WIDTH+1];
562
442
 
563
443
  /**
564
444
   * A pointer to the stack frame of the scheduler thread
567
447
  char *thread_stack;
568
448
 
569
449
private:
570
 
  identifier::User::shared_ptr security_ctx;
 
450
  SecurityContext security_ctx;
571
451
 
572
452
  int32_t scoreboard_index;
573
453
 
576
456
    assert(this->dbug_sentry == Session_SENTRY_MAGIC);
577
457
  }
578
458
public:
579
 
  identifier::User::const_shared_ptr user() const
 
459
  const SecurityContext& getSecurityContext() const
580
460
  {
581
 
    if (security_ctx)
582
 
      return security_ctx;
583
 
 
584
 
    return identifier::User::const_shared_ptr();
 
461
    return security_ctx;
585
462
  }
586
463
 
587
 
  void setUser(identifier::User::shared_ptr arg)
 
464
  SecurityContext& getSecurityContext()
588
465
  {
589
 
    security_ctx= arg;
 
466
    return security_ctx;
590
467
  }
591
468
 
592
469
  int32_t getScoreboardIndex()
602
479
  /**
603
480
   * Is this session viewable by the current user?
604
481
   */
605
 
  bool isViewable() const;
 
482
  bool isViewable() const
 
483
  {
 
484
    return plugin::Authorization::isAuthorized(current_session->getSecurityContext(),
 
485
                                               this,
 
486
                                               false);
 
487
  }
606
488
 
607
489
  /**
608
490
    Used in error messages to tell user in what part of MySQL we found an
618
500
  */
619
501
  uint32_t dbug_sentry; /**< watch for memory corruption */
620
502
private:
621
 
  boost::thread::id boost_thread_id;
622
 
  boost_thread_shared_ptr _thread;
623
 
  boost::this_thread::disable_interruption *interrupt;
624
 
 
625
503
  internal::st_my_thread_var *mysys_var;
626
504
public:
627
505
 
628
 
  boost_thread_shared_ptr &getThread()
629
 
  {
630
 
    return _thread;
631
 
  }
632
 
 
633
 
  void pushInterrupt(boost::this_thread::disable_interruption *interrupt_arg)
634
 
  {
635
 
    interrupt= interrupt_arg;
636
 
  }
637
 
 
638
 
  boost::this_thread::disable_interruption &getThreadInterupt()
639
 
  {
640
 
    assert(interrupt);
641
 
    return *interrupt;
642
 
  }
643
 
 
644
506
  internal::st_my_thread_var *getThreadVar()
645
507
  {
646
508
    return mysys_var;
647
509
  }
648
510
 
 
511
  void resetThreadVar()
 
512
  {
 
513
    mysys_var= NULL;
 
514
  }
649
515
  /**
650
516
   * Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
651
517
   * first byte of the packet in executeStatement()
733
599
  Field *dup_field;
734
600
  sigset_t signals;
735
601
 
736
 
  // As of right now we do not allow a concurrent execute to launch itself
737
 
private:
738
 
  bool concurrent_execute_allowed;
739
 
public:
740
 
 
741
 
  void setConcurrentExecute(bool arg)
742
 
  {
743
 
    concurrent_execute_allowed= arg;
744
 
  }
745
 
 
746
 
  bool isConcurrentExecuteAllowed() const
747
 
  {
748
 
    return concurrent_execute_allowed;
749
 
  }
750
 
 
751
602
  /* Tells if LAST_INSERT_ID(#) was called for the current statement */
752
603
  bool arg_of_last_insert_id_function;
753
 
 
754
604
  /*
755
605
    ALL OVER THIS FILE, "insert_id" means "*automatically generated* value for
756
606
    insertion into an auto_increment column".
854
704
  uint32_t row_count;
855
705
  session_id_t thread_id;
856
706
  uint32_t tmp_table;
857
 
  enum global_read_lock_t
858
 
  {
859
 
    NONE= 0,
860
 
    GOT_GLOBAL_READ_LOCK= 1,
861
 
    MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT= 2
862
 
  };
863
 
private:
864
 
  global_read_lock_t _global_read_lock;
865
 
 
866
 
public:
867
 
 
868
 
  global_read_lock_t isGlobalReadLock() const
869
 
  {
870
 
    return _global_read_lock;
871
 
  }
872
 
 
873
 
  void setGlobalReadLock(global_read_lock_t arg)
874
 
  {
875
 
    _global_read_lock= arg;
876
 
  }
877
 
 
878
 
  DrizzleLock *lockTables(Table **tables, uint32_t count, uint32_t flags, bool *need_reopen);
879
 
  bool lockGlobalReadLock();
880
 
  bool lock_table_names(TableList *table_list);
881
 
  bool lock_table_names_exclusively(TableList *table_list);
882
 
  bool makeGlobalReadLockBlockCommit();
883
 
  bool abortLockForThread(Table *table);
884
 
  bool wait_if_global_read_lock(bool abort_on_refresh, bool is_not_commit);
885
 
  int lock_table_name(TableList *table_list);
886
 
  void abortLock(Table *table);
887
 
  void removeLock(Table *table);
888
 
  void unlockReadTables(DrizzleLock *sql_lock);
889
 
  void unlockSomeTables(Table **table, uint32_t count);
890
 
  void unlockTables(DrizzleLock *sql_lock);
891
 
  void startWaitingGlobalReadLock();
892
 
  void unlockGlobalReadLock();
893
 
 
894
 
private:
895
 
  int unlock_external(Table **table, uint32_t count);
896
 
  int lock_external(Table **tables, uint32_t count);
897
 
  bool wait_for_locked_table_names(TableList *table_list);
898
 
  DrizzleLock *get_lock_data(Table **table_ptr, uint32_t count,
899
 
                             bool should_lock, Table **write_lock_used);
900
 
public:
901
 
 
 
707
  uint32_t global_read_lock;
902
708
  uint32_t server_status;
903
709
  uint32_t open_options;
904
710
  uint32_t select_number; /**< number of select (used for EXPLAIN) */
906
712
  enum_tx_isolation session_tx_isolation;
907
713
  enum_check_fields count_cuted_fields;
908
714
 
909
 
  enum killed_state_t
 
715
  enum killed_state
910
716
  {
911
717
    NOT_KILLED,
912
718
    KILL_BAD_DATA,
914
720
    KILL_QUERY,
915
721
    KILLED_NO_VALUE /* means none of the above states apply */
916
722
  };
917
 
private:
918
 
  killed_state_t volatile _killed;
919
 
 
920
 
public:
921
 
 
922
 
  void setKilled(killed_state_t arg)
923
 
  {
924
 
    _killed= arg;
925
 
  }
926
 
 
927
 
  killed_state_t getKilled()
928
 
  {
929
 
    return _killed;
930
 
  }
931
 
 
932
 
  volatile killed_state_t *getKilledPtr() // Do not use this method, it is here for historical convience.
933
 
  {
934
 
    return &_killed;
935
 
  }
936
 
 
937
 
  bool is_admin_connection;
 
723
  killed_state volatile killed;
 
724
 
938
725
  bool some_tables_deleted;
939
726
  bool no_errors;
940
727
  bool password;
1023
810
  }
1024
811
 
1025
812
  /** Returns the current query ID */
1026
 
  query_id_t getQueryId()  const
 
813
  inline query_id_t getQueryId()  const
1027
814
  {
1028
815
    return query_id;
1029
816
  }
1041
828
    return warn_query_id;
1042
829
  }
1043
830
 
 
831
  /** Returns the current query text */
 
832
  inline const std::string &getQueryString()  const
 
833
  {
 
834
    return query;
 
835
  }
 
836
 
 
837
  /** Returns the length of the current query text */
 
838
  inline size_t getQueryLength() const
 
839
  {
 
840
    if (! query.empty())
 
841
      return query.length();
 
842
    else
 
843
      return 0;
 
844
  }
 
845
 
1044
846
  /** Accessor method returning the session's ID. */
1045
847
  inline session_id_t getSessionId()  const
1046
848
  {
1133
935
   */
1134
936
  void cleanup_after_query();
1135
937
  bool storeGlobals();
1136
 
  void awake(Session::killed_state_t state_to_set);
 
938
  void awake(Session::killed_state state_to_set);
1137
939
  /**
1138
940
   * Pulls thread-specific variables into Session state.
1139
941
   *
1216
1018
  /**
1217
1019
   * Schedule a session to be run on the default scheduler.
1218
1020
   */
1219
 
  static bool schedule(Session::shared_ptr&);
1220
 
 
1221
 
  static void unlink(Session::shared_ptr&);
 
1021
  bool schedule();
1222
1022
 
1223
1023
  /*
1224
1024
    For enter_cond() / exit_cond() to work the mutex must be got before
1231
1031
  inline time_t query_start() { return start_time; }
1232
1032
  inline void set_time()
1233
1033
  {
1234
 
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1235
 
    boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1236
 
    start_utime= utime_after_lock= (mytime-epoch).total_microseconds();
1237
 
 
1238
1034
    if (user_time)
1239
1035
    {
1240
1036
      start_time= user_time;
1241
 
      connect_microseconds= start_utime;
 
1037
      connect_microseconds= start_utime= utime_after_lock= my_micro_time();
1242
1038
    }
1243
 
    else 
1244
 
      start_time= (mytime-epoch).total_seconds();
 
1039
    else
 
1040
      start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
1245
1041
  }
1246
1042
  inline void   set_current_time()    { start_time= time(NULL); }
1247
1043
  inline void   set_time(time_t t)
1248
1044
  {
1249
1045
    start_time= user_time= t;
1250
 
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1251
 
    boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1252
 
    uint64_t t_mark= (mytime-epoch).total_microseconds();
1253
 
 
1254
 
    start_utime= utime_after_lock= t_mark;
1255
 
  }
1256
 
  void set_time_after_lock()  { 
1257
 
     boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1258
 
     boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1259
 
     utime_after_lock= (mytime-epoch).total_microseconds();
1260
 
  }
 
1046
    start_utime= utime_after_lock= my_micro_time();
 
1047
  }
 
1048
  void set_time_after_lock()  { utime_after_lock= my_micro_time(); }
1261
1049
  /**
1262
1050
   * Returns the current micro-timestamp
1263
1051
   */
1264
1052
  inline uint64_t getCurrentTimestamp()  
1265
1053
  { 
1266
 
    boost::posix_time::ptime mytime(boost::posix_time::microsec_clock::local_time());
1267
 
    boost::posix_time::ptime epoch(boost::gregorian::date(1970,1,1));
1268
 
    uint64_t t_mark= (mytime-epoch).total_microseconds();
1269
 
 
1270
 
    return t_mark; 
 
1054
    return my_micro_time(); 
1271
1055
  }
1272
1056
  inline uint64_t found_rows(void)
1273
1057
  {
1293
1077
    @todo: To silence an error, one should use Internal_error_handler
1294
1078
    mechanism. In future this function will be removed.
1295
1079
  */
1296
 
  inline void clear_error(bool full= false)
 
1080
  inline void clear_error()
1297
1081
  {
1298
1082
    if (main_da.is_error())
1299
1083
      main_da.reset_diagnostics_area();
1300
 
 
1301
 
    if (full)
1302
 
    {
1303
 
      drizzle_reset_errors(this, true);
1304
 
    }
1305
 
  }
1306
 
 
1307
 
  void clearDiagnostics()
1308
 
  {
1309
 
    main_da.reset_diagnostics_area();
 
1084
    return;
1310
1085
  }
1311
1086
 
1312
1087
  /**
1350
1125
  void end_statement();
1351
1126
  inline int killed_errno() const
1352
1127
  {
1353
 
    killed_state_t killed_val; /* to cache the volatile 'killed' */
1354
 
    return (killed_val= _killed) != KILL_BAD_DATA ? killed_val : 0;
 
1128
    killed_state killed_val; /* to cache the volatile 'killed' */
 
1129
    return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0;
1355
1130
  }
1356
1131
  void send_kill_message() const;
1357
1132
  /* return true if we will abort query if we make a warning now */
1380
1155
    database usually involves other actions, like switching other database
1381
1156
    attributes including security context. In the future, this operation
1382
1157
    will be made private and more convenient interface will be provided.
 
1158
 
 
1159
    @return Operation status
 
1160
      @retval false Success
 
1161
      @retval true  Out-of-memory error
1383
1162
  */
1384
 
  void set_db(const std::string &new_db);
 
1163
  bool set_db(const std::string &new_db);
1385
1164
 
1386
1165
  /*
1387
1166
    Copy the current database to the argument. Use the current arena to
1620
1399
   * set to query_id of original query.
1621
1400
   */
1622
1401
  void mark_used_tables_as_free_for_reuse(Table *table);
 
1402
  /**
 
1403
    Mark all temporary tables which were used by the current statement or
 
1404
    substatement as free for reuse, but only if the query_id can be cleared.
 
1405
 
 
1406
    @param session thread context
 
1407
 
 
1408
    @remark For temp tables associated with a open SQL HANDLER the query_id
 
1409
            is not reset until the HANDLER is closed.
 
1410
  */
 
1411
  void mark_temp_tables_as_free_for_reuse();
1623
1412
 
1624
1413
public:
1625
1414
 
1672
1461
  void close_old_data_files(bool morph_locks= false,
1673
1462
                            bool send_refresh= false);
1674
1463
  void close_open_tables();
1675
 
  void close_data_files_and_morph_locks(const TableIdentifier &identifier);
 
1464
  void close_data_files_and_morph_locks(TableIdentifier &identifier);
1676
1465
 
1677
1466
private:
1678
1467
  bool free_cached_table();
1709
1498
  Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1710
1499
 
1711
1500
  void unlink_open_table(Table *find);
1712
 
  void drop_open_table(Table *table, const TableIdentifier &identifier);
 
1501
  void drop_open_table(Table *table, TableIdentifier &identifier);
1713
1502
  void close_cached_table(Table *table);
1714
1503
 
1715
1504
  /* Create a lock in the cache */
1716
1505
  table::Placeholder *table_cache_insert_placeholder(const TableIdentifier &identifier);
1717
 
  bool lock_table_name_if_not_cached(const TableIdentifier &identifier, Table **table);
 
1506
  bool lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table);
1718
1507
 
1719
1508
  typedef boost::unordered_map<std::string, message::Table, util::insensitive_hash, util::insensitive_equal_to> TableMessageCache;
1720
 
 
1721
 
  class TableMessages
1722
 
  {
1723
 
    TableMessageCache table_message_cache;
1724
 
 
1725
 
  public:
1726
 
    bool storeTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1727
 
    bool removeTableMessage(const TableIdentifier &identifier);
1728
 
    bool getTableMessage(const TableIdentifier &identifier, message::Table &table_message);
1729
 
    bool doesTableMessageExist(const TableIdentifier &identifier);
1730
 
    bool renameTableMessage(const TableIdentifier &from, const TableIdentifier &to);
1731
 
 
1732
 
  };
 
1509
  TableMessageCache table_message_cache;
 
1510
 
 
1511
  bool storeTableMessage(const TableIdentifier &identifier, message::Table &table_message);
 
1512
  bool removeTableMessage(const TableIdentifier &identifier);
 
1513
  bool getTableMessage(const TableIdentifier &identifier, message::Table &table_message);
 
1514
  bool doesTableMessageExist(const TableIdentifier &identifier);
 
1515
  bool renameTableMessage(const TableIdentifier &from, const TableIdentifier &to);
 
1516
 
 
1517
  /* Work with temporary tables */
 
1518
  Table *find_temporary_table(const TableIdentifier &identifier);
 
1519
 
 
1520
  void doGetTableNames(CachedDirectory &directory,
 
1521
                       const SchemaIdentifier &schema_identifier,
 
1522
                       std::set<std::string>& set_of_names);
 
1523
  void doGetTableNames(const SchemaIdentifier &schema_identifier,
 
1524
                       std::set<std::string>& set_of_names);
 
1525
 
 
1526
  void doGetTableIdentifiers(CachedDirectory &directory,
 
1527
                             const SchemaIdentifier &schema_identifier,
 
1528
                             TableIdentifiers &set_of_identifiers);
 
1529
  void doGetTableIdentifiers(const SchemaIdentifier &schema_identifier,
 
1530
                             TableIdentifiers &set_of_identifiers);
 
1531
 
 
1532
  int doGetTableDefinition(const drizzled::TableIdentifier &identifier,
 
1533
                           message::Table &table_proto);
 
1534
  bool doDoesTableExist(const drizzled::TableIdentifier &identifier);
 
1535
 
 
1536
  void close_temporary_tables();
 
1537
  void close_temporary_table(Table *table);
 
1538
  // The method below just handles the de-allocation of the table. In
 
1539
  // a better memory type world, this would not be needed.
1733
1540
private:
1734
 
  TableMessages _table_message_cache;
1735
 
 
 
1541
  void nukeTable(Table *table);
1736
1542
public:
1737
 
  TableMessages &getMessageCache()
1738
 
  {
1739
 
    return _table_message_cache;
1740
 
  }
 
1543
 
 
1544
  void dumpTemporaryTableNames(const char *id);
 
1545
  int drop_temporary_table(const drizzled::TableIdentifier &identifier);
 
1546
  bool rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier);
 
1547
  bool rm_temporary_table(TableIdentifier &identifier, bool best_effort= false);
 
1548
  Table *open_temporary_table(TableIdentifier &identifier,
 
1549
                              bool link_in_list= true);
1741
1550
 
1742
1551
  /* Reopen operations */
1743
1552
  bool reopen_tables(bool get_locks, bool mark_share_as_old);
1747
1556
  int setup_conds(TableList *leaves, COND **conds);
1748
1557
  int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1749
1558
 
 
1559
  Table *create_virtual_tmp_table(List<CreateField> &field_list);
 
1560
  
1750
1561
  drizzled::util::Storable *getProperty(const std::string &arg)
1751
1562
  {
1752
1563
    return life_properties[arg];
1773
1584
    if (variables.storage_engine)
1774
1585
      return variables.storage_engine;
1775
1586
    return global_system_variables.storage_engine;
1776
 
  }
 
1587
  };
 
1588
 
 
1589
  static void unlink(Session *session);
1777
1590
 
1778
1591
  void get_xid(DRIZZLE_XID *xid); // Innodb only
1779
1592
 
1836
1649
 * A structure used to describe sort information
1837
1650
 * for a field or item used in ORDER BY.
1838
1651
 */
1839
 
class SortField 
 
1652
struct SortField 
1840
1653
{
1841
 
public:
1842
1654
  Field *field; /**< Field to sort */
1843
1655
  Item  *item; /**< Item if not sorting fields */
1844
1656
  size_t length; /**< Length of sort field */
1890
1702
static const std::bitset<CF_BIT_SIZE> CF_SHOW_TABLE_COMMAND(1 << CF_BIT_SHOW_TABLE_COMMAND);
1891
1703
static const std::bitset<CF_BIT_SIZE> CF_WRITE_LOGS_COMMAND(1 << CF_BIT_WRITE_LOGS_COMMAND);
1892
1704
 
1893
 
namespace display  {
1894
 
const std::string &type(drizzled::Session::global_read_lock_t type);
1895
 
size_t max_string_length(drizzled::Session::global_read_lock_t type);
1896
 
} /* namespace display */
1897
 
 
1898
1705
} /* namespace drizzled */
1899
1706
 
1900
1707
#endif /* DRIZZLED_SESSION_H */