~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Andrew Hutchings
  • Date: 2010-11-01 22:04:06 UTC
  • mfrom: (1897 merge)
  • mto: This revision was merged to the branch mainline in revision 1907.
  • Revision ID: andrew@linuxjedi.co.uk-20101101220406-nj6i29uzja17u1hn
Merge trunk into branch

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
 
213
206
  uint64_t preload_buff_size;
214
207
  uint32_t read_buff_size;
215
208
  uint32_t read_rnd_buff_size;
216
 
  bool replicate_query;
217
209
  size_t sortbuff_size;
218
210
  uint32_t thread_handling;
219
211
  uint32_t tx_isolation;
317
309
public:
318
310
  // Plugin storage in Session.
319
311
  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
312
 
323
313
  /*
324
314
    MARK_COLUMNS_NONE:  Means mark_used_colums is not set and no indicator to
376
366
  {
377
367
    return mem_root;
378
368
  }
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
369
  /**
393
370
   * Uniquely identifies each statement object in thread scope; change during
394
371
   * statement lifetime.
403
380
    return lex;
404
381
  }
405
382
  /** 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
 
  }
 
383
  std::string query;
497
384
 
498
385
  /**
499
386
    Name of the current (default) database.
507
394
    the Session of that thread); that thread is (and must remain, for now) the
508
395
    only responsible for freeing this member.
509
396
  */
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
 
  }
 
397
  std::string db;
521
398
  std::string catalog;
522
399
  /* current cache key */
523
400
  std::string query_cache_key;
531
408
 
532
409
  memory::Root warn_root; /**< Allocation area for warnings and errors */
533
410
  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
411
  plugin::Scheduler *scheduler; /**< Pointer to scheduler object */
543
412
  void *scheduler_arg; /**< Pointer to the optional scheduler argument */
544
 
 
 
413
private:
545
414
  typedef boost::unordered_map< std::string, user_var_entry *, util::insensitive_hash, util::insensitive_equal_to> UserVars;
546
 
private:
547
415
  typedef std::pair< UserVars::iterator, UserVars::iterator > UserVarsRange;
548
416
  UserVars user_vars; /**< Hash of user variables defined during the session's lifetime */
549
417
 
550
418
public:
551
 
 
552
 
  const UserVars &getUserVariables() const
553
 
  {
554
 
    return user_vars;
555
 
  }
556
 
 
557
419
  drizzle_system_variables variables; /**< Mutable local variables local to the session */
558
420
  struct system_status_var status_var; /**< Session-local status counters */
559
421
  THR_LOCK_INFO lock_info; /**< Locking information for this session */
560
422
  THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
561
423
  THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
 
424
private:
 
425
  boost::mutex LOCK_delete; /**< Locked before session is deleted */
 
426
public:
 
427
 
 
428
  void lockForDelete()
 
429
  {
 
430
    LOCK_delete.lock();
 
431
  }
 
432
 
 
433
  void unlockForDelete()
 
434
  {
 
435
    LOCK_delete.unlock();
 
436
  }
 
437
 
 
438
  /**
 
439
   * A peek into the query string for the session. This is a best effort
 
440
   * delivery, there is no guarantee whether the content is meaningful.
 
441
   */
 
442
  char process_list_info[PROCESS_LIST_WIDTH+1];
562
443
 
563
444
  /**
564
445
   * A pointer to the stack frame of the scheduler thread
567
448
  char *thread_stack;
568
449
 
569
450
private:
570
 
  identifier::User::shared_ptr security_ctx;
 
451
  SecurityContext security_ctx;
571
452
 
572
453
  int32_t scoreboard_index;
573
454
 
576
457
    assert(this->dbug_sentry == Session_SENTRY_MAGIC);
577
458
  }
578
459
public:
579
 
  identifier::User::const_shared_ptr user() const
 
460
  const SecurityContext& getSecurityContext() const
580
461
  {
581
 
    if (security_ctx)
582
 
      return security_ctx;
583
 
 
584
 
    return identifier::User::const_shared_ptr();
 
462
    return security_ctx;
585
463
  }
586
464
 
587
 
  void setUser(identifier::User::shared_ptr arg)
 
465
  SecurityContext& getSecurityContext()
588
466
  {
589
 
    security_ctx= arg;
 
467
    return security_ctx;
590
468
  }
591
469
 
592
470
  int32_t getScoreboardIndex()
602
480
  /**
603
481
   * Is this session viewable by the current user?
604
482
   */
605
 
  bool isViewable() const;
 
483
  bool isViewable() const
 
484
  {
 
485
    return plugin::Authorization::isAuthorized(current_session->getSecurityContext(),
 
486
                                               this,
 
487
                                               false);
 
488
  }
606
489
 
607
490
  /**
608
491
    Used in error messages to tell user in what part of MySQL we found an
618
501
  */
619
502
  uint32_t dbug_sentry; /**< watch for memory corruption */
620
503
private:
621
 
  boost::thread::id boost_thread_id;
622
 
  boost_thread_shared_ptr _thread;
623
 
  boost::this_thread::disable_interruption *interrupt;
624
 
 
625
504
  internal::st_my_thread_var *mysys_var;
626
505
public:
627
506
 
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
507
  internal::st_my_thread_var *getThreadVar()
645
508
  {
646
509
    return mysys_var;
647
510
  }
648
511
 
 
512
  void resetThreadVar()
 
513
  {
 
514
    mysys_var= NULL;
 
515
  }
649
516
  /**
650
517
   * Type of current query: COM_STMT_PREPARE, COM_QUERY, etc. Set from
651
518
   * first byte of the packet in executeStatement()
733
600
  Field *dup_field;
734
601
  sigset_t signals;
735
602
 
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
603
  /* Tells if LAST_INSERT_ID(#) was called for the current statement */
752
604
  bool arg_of_last_insert_id_function;
753
 
 
754
605
  /*
755
606
    ALL OVER THIS FILE, "insert_id" means "*automatically generated* value for
756
607
    insertion into an auto_increment column".
854
705
  uint32_t row_count;
855
706
  session_id_t thread_id;
856
707
  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
 
 
 
708
  uint32_t global_read_lock;
902
709
  uint32_t server_status;
903
710
  uint32_t open_options;
904
711
  uint32_t select_number; /**< number of select (used for EXPLAIN) */
906
713
  enum_tx_isolation session_tx_isolation;
907
714
  enum_check_fields count_cuted_fields;
908
715
 
909
 
  enum killed_state_t
 
716
  enum killed_state
910
717
  {
911
718
    NOT_KILLED,
912
719
    KILL_BAD_DATA,
914
721
    KILL_QUERY,
915
722
    KILLED_NO_VALUE /* means none of the above states apply */
916
723
  };
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;
 
724
  killed_state volatile killed;
 
725
 
938
726
  bool some_tables_deleted;
939
727
  bool no_errors;
940
728
  bool password;
1023
811
  }
1024
812
 
1025
813
  /** Returns the current query ID */
1026
 
  query_id_t getQueryId()  const
 
814
  inline query_id_t getQueryId()  const
1027
815
  {
1028
816
    return query_id;
1029
817
  }
1041
829
    return warn_query_id;
1042
830
  }
1043
831
 
 
832
  /** Returns the current query text */
 
833
  inline const std::string &getQueryString()  const
 
834
  {
 
835
    return query;
 
836
  }
 
837
 
 
838
  /** Returns the length of the current query text */
 
839
  inline size_t getQueryLength() const
 
840
  {
 
841
    if (! query.empty())
 
842
      return query.length();
 
843
    else
 
844
      return 0;
 
845
  }
 
846
 
1044
847
  /** Accessor method returning the session's ID. */
1045
848
  inline session_id_t getSessionId()  const
1046
849
  {
1133
936
   */
1134
937
  void cleanup_after_query();
1135
938
  bool storeGlobals();
1136
 
  void awake(Session::killed_state_t state_to_set);
 
939
  void awake(Session::killed_state state_to_set);
1137
940
  /**
1138
941
   * Pulls thread-specific variables into Session state.
1139
942
   *
1216
1019
  /**
1217
1020
   * Schedule a session to be run on the default scheduler.
1218
1021
   */
1219
 
  static bool schedule(Session::shared_ptr&);
1220
 
 
1221
 
  static void unlink(Session::shared_ptr&);
 
1022
  bool schedule();
1222
1023
 
1223
1024
  /*
1224
1025
    For enter_cond() / exit_cond() to work the mutex must be got before
1231
1032
  inline time_t query_start() { return start_time; }
1232
1033
  inline void set_time()
1233
1034
  {
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
1035
    if (user_time)
1239
1036
    {
1240
1037
      start_time= user_time;
1241
 
      connect_microseconds= start_utime;
 
1038
      connect_microseconds= start_utime= utime_after_lock= my_micro_time();
1242
1039
    }
1243
 
    else 
1244
 
      start_time= (mytime-epoch).total_seconds();
 
1040
    else
 
1041
      start_utime= utime_after_lock= my_micro_time_and_time(&start_time);
1245
1042
  }
1246
1043
  inline void   set_current_time()    { start_time= time(NULL); }
1247
1044
  inline void   set_time(time_t t)
1248
1045
  {
1249
1046
    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
 
  }
 
1047
    start_utime= utime_after_lock= my_micro_time();
 
1048
  }
 
1049
  void set_time_after_lock()  { utime_after_lock= my_micro_time(); }
1261
1050
  /**
1262
1051
   * Returns the current micro-timestamp
1263
1052
   */
1264
1053
  inline uint64_t getCurrentTimestamp()  
1265
1054
  { 
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; 
 
1055
    return my_micro_time(); 
1271
1056
  }
1272
1057
  inline uint64_t found_rows(void)
1273
1058
  {
1293
1078
    @todo: To silence an error, one should use Internal_error_handler
1294
1079
    mechanism. In future this function will be removed.
1295
1080
  */
1296
 
  inline void clear_error(bool full= false)
 
1081
  inline void clear_error()
1297
1082
  {
1298
1083
    if (main_da.is_error())
1299
1084
      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();
 
1085
    return;
1310
1086
  }
1311
1087
 
1312
1088
  /**
1350
1126
  void end_statement();
1351
1127
  inline int killed_errno() const
1352
1128
  {
1353
 
    killed_state_t killed_val; /* to cache the volatile 'killed' */
1354
 
    return (killed_val= _killed) != KILL_BAD_DATA ? killed_val : 0;
 
1129
    killed_state killed_val; /* to cache the volatile 'killed' */
 
1130
    return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0;
1355
1131
  }
1356
1132
  void send_kill_message() const;
1357
1133
  /* return true if we will abort query if we make a warning now */
1380
1156
    database usually involves other actions, like switching other database
1381
1157
    attributes including security context. In the future, this operation
1382
1158
    will be made private and more convenient interface will be provided.
 
1159
 
 
1160
    @return Operation status
 
1161
      @retval false Success
 
1162
      @retval true  Out-of-memory error
1383
1163
  */
1384
 
  void set_db(const std::string &new_db);
 
1164
  bool set_db(const std::string &new_db);
1385
1165
 
1386
1166
  /*
1387
1167
    Copy the current database to the argument. Use the current arena to
1620
1400
   * set to query_id of original query.
1621
1401
   */
1622
1402
  void mark_used_tables_as_free_for_reuse(Table *table);
 
1403
  /**
 
1404
    Mark all temporary tables which were used by the current statement or
 
1405
    substatement as free for reuse, but only if the query_id can be cleared.
 
1406
 
 
1407
    @param session thread context
 
1408
 
 
1409
    @remark For temp tables associated with a open SQL HANDLER the query_id
 
1410
            is not reset until the HANDLER is closed.
 
1411
  */
 
1412
  void mark_temp_tables_as_free_for_reuse();
1623
1413
 
1624
1414
public:
1625
1415
 
1672
1462
  void close_old_data_files(bool morph_locks= false,
1673
1463
                            bool send_refresh= false);
1674
1464
  void close_open_tables();
1675
 
  void close_data_files_and_morph_locks(const TableIdentifier &identifier);
 
1465
  void close_data_files_and_morph_locks(TableIdentifier &identifier);
1676
1466
 
1677
1467
private:
1678
1468
  bool free_cached_table();
1709
1499
  Table *openTable(TableList *table_list, bool *refresh, uint32_t flags= 0);
1710
1500
 
1711
1501
  void unlink_open_table(Table *find);
1712
 
  void drop_open_table(Table *table, const TableIdentifier &identifier);
 
1502
  void drop_open_table(Table *table, TableIdentifier &identifier);
1713
1503
  void close_cached_table(Table *table);
1714
1504
 
1715
1505
  /* Create a lock in the cache */
1716
1506
  table::Placeholder *table_cache_insert_placeholder(const TableIdentifier &identifier);
1717
 
  bool lock_table_name_if_not_cached(const TableIdentifier &identifier, Table **table);
 
1507
  bool lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table);
1718
1508
 
1719
1509
  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
 
  };
 
1510
  TableMessageCache table_message_cache;
 
1511
 
 
1512
  bool storeTableMessage(const TableIdentifier &identifier, message::Table &table_message);
 
1513
  bool removeTableMessage(const TableIdentifier &identifier);
 
1514
  bool getTableMessage(const TableIdentifier &identifier, message::Table &table_message);
 
1515
  bool doesTableMessageExist(const TableIdentifier &identifier);
 
1516
  bool renameTableMessage(const TableIdentifier &from, const TableIdentifier &to);
 
1517
 
 
1518
  /* Work with temporary tables */
 
1519
  Table *find_temporary_table(const TableIdentifier &identifier);
 
1520
 
 
1521
  void doGetTableNames(CachedDirectory &directory,
 
1522
                       const SchemaIdentifier &schema_identifier,
 
1523
                       std::set<std::string>& set_of_names);
 
1524
  void doGetTableNames(const SchemaIdentifier &schema_identifier,
 
1525
                       std::set<std::string>& set_of_names);
 
1526
 
 
1527
  void doGetTableIdentifiers(CachedDirectory &directory,
 
1528
                             const SchemaIdentifier &schema_identifier,
 
1529
                             TableIdentifiers &set_of_identifiers);
 
1530
  void doGetTableIdentifiers(const SchemaIdentifier &schema_identifier,
 
1531
                             TableIdentifiers &set_of_identifiers);
 
1532
 
 
1533
  int doGetTableDefinition(const drizzled::TableIdentifier &identifier,
 
1534
                           message::Table &table_proto);
 
1535
  bool doDoesTableExist(const drizzled::TableIdentifier &identifier);
 
1536
 
 
1537
  void close_temporary_tables();
 
1538
  void close_temporary_table(Table *table);
 
1539
  // The method below just handles the de-allocation of the table. In
 
1540
  // a better memory type world, this would not be needed.
1733
1541
private:
1734
 
  TableMessages _table_message_cache;
1735
 
 
 
1542
  void nukeTable(Table *table);
1736
1543
public:
1737
 
  TableMessages &getMessageCache()
1738
 
  {
1739
 
    return _table_message_cache;
1740
 
  }
 
1544
 
 
1545
  void dumpTemporaryTableNames(const char *id);
 
1546
  int drop_temporary_table(const drizzled::TableIdentifier &identifier);
 
1547
  bool rm_temporary_table(plugin::StorageEngine *base, TableIdentifier &identifier);
 
1548
  bool rm_temporary_table(TableIdentifier &identifier, bool best_effort= false);
 
1549
  Table *open_temporary_table(TableIdentifier &identifier,
 
1550
                              bool link_in_list= true);
1741
1551
 
1742
1552
  /* Reopen operations */
1743
1553
  bool reopen_tables(bool get_locks, bool mark_share_as_old);
1747
1557
  int setup_conds(TableList *leaves, COND **conds);
1748
1558
  int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1749
1559
 
 
1560
  Table *create_virtual_tmp_table(List<CreateField> &field_list);
 
1561
  
1750
1562
  drizzled::util::Storable *getProperty(const std::string &arg)
1751
1563
  {
1752
1564
    return life_properties[arg];
1775
1587
    return global_system_variables.storage_engine;
1776
1588
  }
1777
1589
 
 
1590
  static void unlink(Session *session);
 
1591
 
1778
1592
  void get_xid(DRIZZLE_XID *xid); // Innodb only
1779
1593
 
1780
1594
  table::Instance *getInstanceTable();
1890
1704
static const std::bitset<CF_BIT_SIZE> CF_SHOW_TABLE_COMMAND(1 << CF_BIT_SHOW_TABLE_COMMAND);
1891
1705
static const std::bitset<CF_BIT_SIZE> CF_WRITE_LOGS_COMMAND(1 << CF_BIT_WRITE_LOGS_COMMAND);
1892
1706
 
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
1707
} /* namespace drizzled */
1899
1708
 
1900
1709
#endif /* DRIZZLED_SESSION_H */