~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Brian Aker
  • Date: 2010-11-08 20:10:51 UTC
  • mfrom: (1910.2.8 merge)
  • Revision ID: brian@tangent.org-20101108201051-fmplr6oke3c088kf
Encapsulation around locking/kill

Show diffs side-by-side

added added

removed removed

Lines of Context:
718
718
  uint32_t row_count;
719
719
  session_id_t thread_id;
720
720
  uint32_t tmp_table;
721
 
  uint32_t global_read_lock;
 
721
  enum global_read_lock_t
 
722
  {
 
723
    NONE= 0,
 
724
    GOT_GLOBAL_READ_LOCK= 1,
 
725
    MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT= 2
 
726
  };
 
727
private:
 
728
  global_read_lock_t _global_read_lock;
 
729
 
 
730
public:
 
731
 
 
732
  global_read_lock_t isGlobalReadLock() const
 
733
  {
 
734
    return _global_read_lock;
 
735
  }
 
736
 
 
737
  void setGlobalReadLock(global_read_lock_t arg)
 
738
  {
 
739
    _global_read_lock= arg;
 
740
  }
 
741
 
 
742
  DrizzleLock *lockTables(Table **tables, uint32_t count, uint32_t flags, bool *need_reopen);
 
743
  bool lockGlobalReadLock();
 
744
  bool lock_table_names(TableList *table_list);
 
745
  bool lock_table_names_exclusively(TableList *table_list);
 
746
  bool makeGlobalReadLockBlockCommit();
 
747
  bool abortLockForThread(Table *table);
 
748
  bool wait_if_global_read_lock(bool abort_on_refresh, bool is_not_commit);
 
749
  int lock_table_name(TableList *table_list);
 
750
  void abortLock(Table *table);
 
751
  void removeLock(Table *table);
 
752
  void unlockReadTables(DrizzleLock *sql_lock);
 
753
  void unlockSomeTables(Table **table, uint32_t count);
 
754
  void unlockTables(DrizzleLock *sql_lock);
 
755
  void startWaitingGlobalReadLock();
 
756
  void unlockGlobalReadLock();
 
757
 
 
758
private:
 
759
  int unlock_external(Table **table, uint32_t count);
 
760
  int lock_external(Table **tables, uint32_t count);
 
761
  bool wait_for_locked_table_names(TableList *table_list);
 
762
  DrizzleLock *get_lock_data(Table **table_ptr, uint32_t count,
 
763
                             bool should_lock, Table **write_lock_used);
 
764
public:
 
765
 
722
766
  uint32_t server_status;
723
767
  uint32_t open_options;
724
768
  uint32_t select_number; /**< number of select (used for EXPLAIN) */
726
770
  enum_tx_isolation session_tx_isolation;
727
771
  enum_check_fields count_cuted_fields;
728
772
 
729
 
  enum killed_state
 
773
  enum killed_state_t
730
774
  {
731
775
    NOT_KILLED,
732
776
    KILL_BAD_DATA,
734
778
    KILL_QUERY,
735
779
    KILLED_NO_VALUE /* means none of the above states apply */
736
780
  };
737
 
  killed_state volatile killed;
 
781
private:
 
782
  killed_state_t volatile _killed;
 
783
 
 
784
public:
 
785
 
 
786
  void setKilled(killed_state_t arg)
 
787
  {
 
788
    _killed= arg;
 
789
  }
 
790
 
 
791
  killed_state_t getKilled()
 
792
  {
 
793
    return _killed;
 
794
  }
 
795
 
 
796
  volatile killed_state_t *getKilledPtr() // Do not use this method, it is here for historical convience.
 
797
  {
 
798
    return &_killed;
 
799
  }
738
800
 
739
801
  bool some_tables_deleted;
740
802
  bool no_errors;
949
1011
   */
950
1012
  void cleanup_after_query();
951
1013
  bool storeGlobals();
952
 
  void awake(Session::killed_state state_to_set);
 
1014
  void awake(Session::killed_state_t state_to_set);
953
1015
  /**
954
1016
   * Pulls thread-specific variables into Session state.
955
1017
   *
1139
1201
  void end_statement();
1140
1202
  inline int killed_errno() const
1141
1203
  {
1142
 
    killed_state killed_val; /* to cache the volatile 'killed' */
1143
 
    return (killed_val= killed) != KILL_BAD_DATA ? killed_val : 0;
 
1204
    killed_state_t killed_val; /* to cache the volatile 'killed' */
 
1205
    return (killed_val= _killed) != KILL_BAD_DATA ? killed_val : 0;
1144
1206
  }
1145
1207
  void send_kill_message() const;
1146
1208
  /* return true if we will abort query if we make a warning now */