~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Lee Bieber
  • Date: 2011-03-23 00:09:31 UTC
  • mfrom: (2241.3.9 refactor3)
  • mto: This revision was merged to the branch mainline in revision 2246.
  • Revision ID: kalebral@gmail.com-20110323000931-t13v9s8a91en53de
Merge Olaf - more code refactoring

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include <drizzled/error.h>
39
39
#include <drizzled/open_tables_state.h>
40
40
#include <drizzled/pthread_globals.h>
41
 
#include <drizzled/session/transactions.h>
42
41
#include <drizzled/sql_list.h>
43
42
#include <drizzled/sql_error.h>
44
43
#include <drizzled/sql_locale.h>
45
 
#include <drizzled/statistics_variables.h>
46
 
#include <drizzled/system_variables.h>
47
44
#include <drizzled/visibility.h>
48
45
#include <drizzled/util/find_ptr.h>
49
46
#include <drizzled/util/string.h>
72
69
73
70
  class State; 
74
71
  class TableMessages;
 
72
  class Transactions;
75
73
}
76
74
 
77
75
namespace table 
99
97
class Table_ident;
100
98
class Time_zone;
101
99
class select_result;
 
100
class system_status_var;
102
101
class user_var_entry;
103
102
struct Ha_data;
104
103
 
105
104
typedef Item COND;
 
105
typedef uint64_t my_xid;
106
106
 
107
107
extern char internal_table_name[2];
108
108
extern char empty_c_string[1];
109
109
extern const char **errmesg;
 
110
extern uint32_t server_id;
110
111
 
111
112
#define TC_HEURISTIC_RECOVER_COMMIT   1
112
113
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
136
137
 
137
138
class DRIZZLED_API Session : public Open_tables_state
138
139
{
 
140
private:
 
141
  class impl_c;
 
142
 
 
143
  boost::scoped_ptr<impl_c> impl_;
139
144
public:
140
145
  // Plugin storage in Session.
141
146
  typedef boost::shared_ptr<Session> shared_ptr;
161
166
                        that it needs to update this field in write_row
162
167
                        and update_row.
163
168
  */
164
 
  enum enum_mark_columns mark_used_columns;
 
169
  enum_mark_columns mark_used_columns;
165
170
  inline void* calloc(size_t size)
166
171
  {
167
172
    void *ptr= mem_root->alloc_root(size);
275
280
    the Session of that thread); that thread is (and must remain, for now) the
276
281
    only responsible for freeing this member.
277
282
  */
278
 
private:
279
 
  util::string::shared_ptr _schema;
280
 
 
281
283
public:
282
284
 
283
285
  util::string::const_shared_ptr schema() const
284
286
  {
285
 
    if (_schema)
286
 
      return _schema;
287
 
 
288
 
    return util::string::const_shared_ptr(new std::string);
 
287
    return _schema ? _schema : util::string::const_shared_ptr(new std::string);
289
288
  }
290
289
 
291
290
  /* current cache key */
322
321
    return user_vars;
323
322
  }
324
323
 
325
 
  drizzle_system_variables variables; /**< Mutable local variables local to the session */
 
324
  drizzle_system_variables& variables; /**< Mutable local variables local to the session */
326
325
  enum_tx_isolation getTxIsolation();
327
 
  system_status_var status_var;
 
326
  system_status_var& status_var;
328
327
 
329
328
  THR_LOCK_INFO lock_info; /**< Locking information for this session */
330
329
  THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
473
472
  void **getEngineData(const plugin::MonitoredInTransaction *monitored);
474
473
  ResourceContext& getResourceContext(const plugin::MonitoredInTransaction&, size_t index= 0);
475
474
 
476
 
  session::Transactions transaction;
 
475
  session::Transactions& transaction;
477
476
 
478
477
  Field *dup_field;
479
478
  sigset_t signals;
582
581
  uint32_t warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_END];
583
582
  uint32_t total_warn_count;
584
583
 
585
 
  ulong col_access;
586
 
 
587
 
  /* Statement id is thread-wide. This counter is used to generate ids */
588
 
  uint32_t statement_id_counter;
589
 
  uint32_t rand_saved_seed1;
590
 
  uint32_t rand_saved_seed2;
591
584
  /**
592
585
    Row counter, mainly for errors and warnings. Not increased in
593
586
    create_sort_index(); may differ from examined_row_count.
594
587
  */
595
588
  uint32_t row_count;
596
589
 
597
 
  uint32_t getRowCount() const
598
 
  {
599
 
    return row_count;
600
 
  }
601
 
 
602
590
  session_id_t thread_id;
603
591
  uint32_t tmp_table;
604
592
  enum global_read_lock_t
753
741
  /** Place to store various things */
754
742
  void *session_marker;
755
743
 
756
 
  /** Keeps a copy of the previous table around in case we are just slamming on particular table */
757
 
  Table *cached_table;
758
 
 
759
744
  /**
760
745
    Points to info-string that we show in SHOW PROCESSLIST
761
746
    You are supposed to call Session_SET_PROC_INFO only if you have coded
812
797
  }
813
798
 
814
799
  /** Returns the current transaction ID for the session's current statement */
815
 
  inline my_xid getTransactionId()
816
 
  {
817
 
    return transaction.xid_state.xid.quick_get_my_xid();
818
 
  }
 
800
  my_xid getTransactionId();
 
801
 
819
802
  /**
820
803
    There is BUG#19630 where statement-based replication of stored
821
804
    functions/triggers with two auto_increment columns breaks.
1414
1397
  plugin::StorageEngine *getDefaultStorageEngine();
1415
1398
  void get_xid(DrizzleXid *xid); // Innodb only
1416
1399
 
1417
 
  table::Singular *getInstanceTable();
1418
 
  table::Singular *getInstanceTable(List<CreateField> &field_list);
 
1400
  table::Singular& getInstanceTable();
 
1401
  table::Singular& getInstanceTable(std::list<CreateField>&);
1419
1402
 
1420
1403
  void setUsage(bool arg)
1421
1404
  {
1439
1422
 
1440
1423
  bool arg_of_last_insert_id_function; // Tells if LAST_INSERT_ID(#) was called for the current statement
1441
1424
private:
1442
 
        class impl_c;
1443
 
 
1444
1425
  bool free_cached_table(boost::mutex::scoped_lock &scopedLock);
1445
1426
  drizzled::util::Storable* getProperty0(const std::string&);
1446
1427
  void setProperty0(const std::string&, drizzled::util::Storable*);
1451
1432
    return not getrusage(RUSAGE_THREAD, &usage);
1452
1433
  }
1453
1434
 
1454
 
  boost::scoped_ptr<impl_c> impl_;
1455
1435
  catalog::Instance::shared_ptr _catalog;
1456
1436
 
1457
1437
  /** Pointers to memory managed by the ReplicationServices component */
1471
1451
  bool concurrent_execute_allowed;
1472
1452
  bool tablespace_op; /**< This is true in DISCARD/IMPORT TABLESPACE */
1473
1453
  bool use_usage;
1474
 
  std::vector<table::Singular *> temporary_shares;
1475
1454
  rusage usage;
1476
1455
  identifier::User::shared_ptr security_ctx;
1477
1456
  int32_t scoreboard_index;
1478
1457
  plugin::Client *client;
 
1458
  util::string::shared_ptr _schema;
1479
1459
};
1480
1460
 
1481
1461
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape