~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Lee Bieber
  • Date: 2011-03-22 17:41:09 UTC
  • mfrom: (2241.2.18 refactor2)
  • Revision ID: kalebral@gmail.com-20110322174109-1bsfvv4q1dnfd089
Merge Olaf - more code refactoring

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
 
36
36
#include <drizzled/global_charset_info.h>
37
37
#include <drizzled/base.h>
38
 
#include <drizzled/discrete_interval.h>
39
38
#include <drizzled/error.h>
40
39
#include <drizzled/open_tables_state.h>
41
40
#include <drizzled/pthread_globals.h>
42
 
#include <drizzled/query_id.h>
43
 
#include <drizzled/session/property_map.h>
44
 
#include <drizzled/session/table_messages.h>
45
41
#include <drizzled/session/transactions.h>
46
42
#include <drizzled/sql_list.h>
47
43
#include <drizzled/sql_error.h>
48
44
#include <drizzled/sql_locale.h>
49
45
#include <drizzled/statistics_variables.h>
50
46
#include <drizzled/system_variables.h>
51
 
#include <drizzled/transaction_context.h>
52
 
#include <drizzled/util/storable.h>
53
 
#include <drizzled/var.h>
54
47
#include <drizzled/visibility.h>
55
48
#include <drizzled/util/find_ptr.h>
 
49
#include <drizzled/util/string.h>
56
50
#include <drizzled/type/time.h>
57
 
#include <drizzled/sql_lex.h>
58
 
 
59
 
#define MIN_HANDSHAKE_SIZE      6
60
51
 
61
52
namespace drizzled {
62
53
 
89
80
  class Singular; 
90
81
}
91
82
 
92
 
typedef class Item COND;
 
83
namespace util
 
84
{
 
85
  class Storable;
 
86
}
93
87
 
94
88
class CopyField;
95
89
class CreateField;
108
102
class user_var_entry;
109
103
struct Ha_data;
110
104
 
 
105
typedef Item COND;
 
106
 
111
107
extern char internal_table_name[2];
112
108
extern char empty_c_string[1];
113
109
extern const char **errmesg;
116
112
#define TC_HEURISTIC_RECOVER_ROLLBACK 2
117
113
extern uint32_t tc_heuristic_recover;
118
114
 
119
 
#define Session_SENTRY_MAGIC 0xfeedd1ff
120
 
#define Session_SENTRY_GONE  0xdeadbeef
121
 
 
122
115
extern DRIZZLED_API struct drizzle_system_variables global_system_variables;
123
116
 
124
117
/**
292
285
    if (_schema)
293
286
      return _schema;
294
287
 
295
 
    return util::string::const_shared_ptr(new std::string(""));
 
288
    return util::string::const_shared_ptr(new std::string);
296
289
  }
297
290
 
298
291
  /* current cache key */
306
299
  static const char * const DEFAULT_WHERE;
307
300
 
308
301
  memory::Root warn_root; /**< Allocation area for warnings and errors */
309
 
private:
310
 
  plugin::Client *client; /**< Pointer to client object */
311
 
 
312
302
public:
313
 
 
314
303
  void setClient(plugin::Client *client_arg);
315
304
 
316
 
  plugin::Client *getClient()
317
 
  {
318
 
    return client;
319
 
  }
320
 
 
321
305
  plugin::Client *getClient() const
322
306
  {
323
307
    return client;
342
326
  enum_tx_isolation getTxIsolation();
343
327
  system_status_var status_var;
344
328
 
345
 
  system_status_var status_var0; /**< Session-local status counters */
346
329
  THR_LOCK_INFO lock_info; /**< Locking information for this session */
347
330
  THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
348
331
  THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
353
336
   */
354
337
  char *thread_stack;
355
338
 
356
 
private:
357
 
  identifier::User::shared_ptr security_ctx;
358
 
 
359
 
  int32_t scoreboard_index;
360
 
 
361
 
  inline void checkSentry() const
362
 
  {
363
 
    assert(this->dbug_sentry == Session_SENTRY_MAGIC);
364
 
  }
365
 
 
366
 
public:
367
339
  identifier::User::const_shared_ptr user() const
368
340
  {
369
 
    if (security_ctx)
370
 
      return security_ctx;
371
 
 
372
 
    return identifier::User::const_shared_ptr();
 
341
    return security_ctx ? security_ctx : identifier::User::const_shared_ptr();
373
342
  }
374
343
 
375
344
  void setUser(identifier::User::shared_ptr arg)
416
385
    points to a lock object if the lock is present. See item_func.cc and
417
386
    chapter 'Miscellaneous functions', for functions GET_LOCK, RELEASE_LOCK.
418
387
  */
419
 
  uint32_t dbug_sentry; /**< watch for memory corruption */
420
388
 
421
389
private:
422
390
  boost::thread::id boost_thread_id;
503
471
 
504
472
public:
505
473
  void **getEngineData(const plugin::MonitoredInTransaction *monitored);
506
 
  ResourceContext *getResourceContext(const plugin::MonitoredInTransaction *monitored,
507
 
                                      size_t index= 0);
 
474
  ResourceContext& getResourceContext(const plugin::MonitoredInTransaction&, size_t index= 0);
508
475
 
509
476
  session::Transactions transaction;
510
477
 
569
536
    (first_successful_insert_id_in_cur_stmt == 0), but storing "INSERT_ID=3"
570
537
    in the binlog is still needed; the list's minimum will contain 3.
571
538
  */
572
 
  Discrete_intervals_list auto_inc_intervals_in_cur_stmt_for_binlog;
573
 
  /** Used by replication and SET INSERT_ID */
574
 
  Discrete_intervals_list auto_inc_intervals_forced;
575
539
 
576
540
  uint64_t limit_found_rows;
577
541
  uint64_t options; /**< Bitmap of options */
897
861
  {
898
862
    return first_successful_insert_id_in_prev_stmt;
899
863
  }
900
 
  /**
901
 
    Used by Intvar_log_event::do_apply_event() and by "SET INSERT_ID=#"
902
 
    (mysqlbinlog). We'll soon add a variant which can take many intervals in
903
 
    argument.
904
 
  */
905
 
  inline void force_one_auto_inc_interval(uint64_t next_id)
906
 
  {
907
 
    auto_inc_intervals_forced.empty(); // in case of multiple SET INSERT_ID
908
 
    auto_inc_intervals_forced.append(next_id, UINT64_MAX, 0);
909
 
  }
910
864
 
911
865
  Session(plugin::Client *client_arg, catalog::Instance::shared_ptr catalog);
912
866
  virtual ~Session();
1174
1128
    @param level the error level
1175
1129
    @return true if the error is handled
1176
1130
  */
1177
 
  virtual bool handle_error(drizzled::error_t sql_errno, const char *message,
 
1131
  virtual bool handle_error(error_t sql_errno, const char *message,
1178
1132
                            DRIZZLE_ERROR::enum_warning_level level);
1179
1133
 
1180
1134
  /**
1436
1390
  int setup_conds(TableList *leaves, COND **conds);
1437
1391
  int lock_tables(TableList *tables, uint32_t count, bool *need_reopen);
1438
1392
 
1439
 
  drizzled::util::Storable *getProperty(const std::string &arg)
 
1393
  template <class T>
 
1394
  T* getProperty(const std::string& name)
1440
1395
  {
1441
 
    return life_properties.getProperty(arg);
 
1396
    return static_cast<T*>(getProperty0(name));
1442
1397
  }
1443
1398
 
1444
 
  template<class T>
1445
 
  void setProperty(const std::string &arg, T *value)
 
1399
  template <class T>
 
1400
  T setProperty(const std::string& name, T value)
1446
1401
  {
1447
 
    life_properties.setProperty(arg, value);
 
1402
    setProperty0(name, value);
 
1403
    return value;
1448
1404
  }
1449
1405
 
1450
1406
  /**
1486
1442
        class impl_c;
1487
1443
 
1488
1444
  bool free_cached_table(boost::mutex::scoped_lock &scopedLock);
 
1445
  drizzled::util::Storable* getProperty0(const std::string&);
 
1446
  void setProperty0(const std::string&, drizzled::util::Storable*);
 
1447
 
1489
1448
 
1490
1449
  bool resetUsage()
1491
1450
  {
1512
1471
  bool concurrent_execute_allowed;
1513
1472
  bool tablespace_op; /**< This is true in DISCARD/IMPORT TABLESPACE */
1514
1473
  bool use_usage;
1515
 
  session::PropertyMap life_properties;
1516
1474
  std::vector<table::Singular *> temporary_shares;
1517
1475
  rusage usage;
 
1476
  identifier::User::shared_ptr security_ctx;
 
1477
  int32_t scoreboard_index;
 
1478
  plugin::Client *client;
1518
1479
};
1519
1480
 
1520
1481
#define ESCAPE_CHARS "ntrb0ZN" // keep synchronous with READ_INFO::unescape
1537
1498
static const std::bitset<CF_BIT_SIZE> CF_SHOW_TABLE_COMMAND(1 << CF_BIT_SHOW_TABLE_COMMAND);
1538
1499
static const std::bitset<CF_BIT_SIZE> CF_WRITE_LOGS_COMMAND(1 << CF_BIT_WRITE_LOGS_COMMAND);
1539
1500
 
1540
 
namespace display  {
1541
 
const std::string &type(drizzled::Session::global_read_lock_t type);
1542
 
size_t max_string_length(drizzled::Session::global_read_lock_t type);
1543
 
 
 
1501
namespace display  
 
1502
{
 
1503
  const std::string &type(Session::global_read_lock_t);
 
1504
  size_t max_string_length(Session::global_read_lock_t);
1544
1505
} /* namespace display */
1545
1506
 
1546
1507
} /* namespace drizzled */