~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.h

  • Committer: Lee Bieber
  • Date: 2011-03-16 18:11:33 UTC
  • mfrom: (2239.2.2 build)
  • Revision ID: kalebral@gmail.com-20110316181133-zr1uj612rz7s32s0
Merge Patrick - Added some randgen test cases
Merge Olaf - refactor includes

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
#include <algorithm>
23
23
#include <bitset>
24
24
#include <boost/make_shared.hpp>
 
25
#include <boost/scoped_ptr.hpp>
25
26
#include <boost/thread/condition_variable.hpp>
26
27
#include <boost/thread/mutex.hpp>
27
28
#include <boost/thread/shared_mutex.hpp>
32
33
#include <sys/resource.h>
33
34
#include <sys/time.h>
34
35
 
35
 
#include <drizzled/catalog/instance.h>
36
 
#include <drizzled/catalog/local.h>
37
 
#include <drizzled/copy_info.h>
38
 
#include <drizzled/cursor.h>
39
 
#include <drizzled/diagnostics_area.h>
 
36
#include <drizzled/global_charset_info.h>
 
37
#include <drizzled/base.h>
 
38
#include <drizzled/discrete_interval.h>
40
39
#include <drizzled/error.h>
41
 
#include <drizzled/file_exchange.h>
42
 
#include <drizzled/ha_data.h>
43
 
#include <drizzled/identifier.h>
44
 
#include <drizzled/named_savepoint.h>
45
40
#include <drizzled/open_tables_state.h>
46
 
#include <drizzled/plugin.h>
47
 
#include <drizzled/plugin/authorization.h>
48
41
#include <drizzled/pthread_globals.h>
49
42
#include <drizzled/query_id.h>
50
 
#include <drizzled/resource_context.h>
51
43
#include <drizzled/session/property_map.h>
52
 
#include <drizzled/session/state.h>
53
44
#include <drizzled/session/table_messages.h>
54
45
#include <drizzled/session/transactions.h>
 
46
#include <drizzled/sql_list.h>
55
47
#include <drizzled/sql_error.h>
56
48
#include <drizzled/sql_locale.h>
57
49
#include <drizzled/statistics_variables.h>
58
50
#include <drizzled/system_variables.h>
59
 
#include <drizzled/system_variables.h>
60
 
#include <drizzled/table_ident.h>
61
51
#include <drizzled/transaction_context.h>
62
52
#include <drizzled/util/storable.h>
63
53
#include <drizzled/var.h>
73
63
namespace plugin
74
64
{
75
65
        class Client;
 
66
        class EventObserverList;
 
67
  class MonitoredInTransaction;
76
68
        class Scheduler;
77
 
        class EventObserverList;
78
69
}
79
70
 
80
71
namespace message
86
77
 
87
78
namespace internal { struct st_my_thread_var; }
88
79
 
 
80
namespace session 
 
81
 
82
  class State; 
 
83
  class TableMessages;
 
84
}
 
85
 
89
86
namespace table 
90
87
91
88
  class Placeholder; 
92
89
  class Singular; 
93
90
}
94
91
 
 
92
typedef class Item COND;
 
93
 
95
94
class CopyField;
 
95
class CreateField;
 
96
class Diagnostics_area;
96
97
class DrizzleXid;
 
98
class Field;
97
99
class Internal_error_handler;
 
100
class Item;
 
101
class LEX;
98
102
class Lex_input_stream;
 
103
class ResourceContext;
99
104
class TableShareInstance;
100
105
class Table_ident;
101
106
class Time_zone;
102
107
class select_result;
103
108
class user_var_entry;
 
109
struct Ha_data;
104
110
 
105
111
extern char internal_table_name[2];
106
112
extern char empty_c_string[1];
208
214
  }
209
215
 
210
216
public:
 
217
  Diagnostics_area& main_da();
211
218
  const LEX& lex() const;
212
219
  LEX& lex();
213
220
  enum_sql_command getSqlCommand() const;
254
261
  }
255
262
 
256
263
private:
257
 
  session::State::shared_ptr  _state;
 
264
  boost::shared_ptr<session::State> _state;
258
265
 
259
266
public:
260
267
 
261
 
  session::State::const_shared_ptr state()
 
268
  const boost::shared_ptr<session::State>& state()
262
269
  {
263
270
    return _state;
264
271
  }
332
339
  }
333
340
 
334
341
  drizzle_system_variables variables; /**< Mutable local variables local to the session */
335
 
 
336
 
  enum_tx_isolation getTxIsolation()
337
 
  {
338
 
    return (enum_tx_isolation)variables.tx_isolation;
339
 
  }
340
 
 
341
 
  system_status_var status_var; /**< Session-local status counters */
 
342
  enum_tx_isolation getTxIsolation();
 
343
  system_status_var status_var;
 
344
 
 
345
  system_status_var status_var0; /**< Session-local status counters */
342
346
  THR_LOCK_INFO lock_info; /**< Locking information for this session */
343
347
  THR_LOCK_OWNER main_lock_id; /**< To use for conventional queries */
344
348
  THR_LOCK_OWNER *lock_id; /**< If not main_lock_id, points to the lock_id of a cursor. */
613
617
  List<DRIZZLE_ERROR> warn_list;
614
618
  uint32_t warn_count[(uint32_t) DRIZZLE_ERROR::WARN_LEVEL_END];
615
619
  uint32_t total_warn_count;
616
 
  Diagnostics_area main_da;
617
620
 
618
621
  ulong col_access;
619
622
 
1041
1044
    utime_after_lock= (boost::posix_time::microsec_clock::universal_time() - _epoch).total_microseconds();
1042
1045
  }
1043
1046
 
1044
 
  void set_end_timer()
1045
 
  {
1046
 
    _end_timer= boost::posix_time::microsec_clock::universal_time();
1047
 
    status_var.execution_time_nsec+=(_end_timer - _start_timer).total_microseconds();
1048
 
  }
 
1047
  void set_end_timer();
1049
1048
 
1050
1049
  uint64_t getElapsedTime() const
1051
1050
  {
1099
1098
 
1100
1099
  int send_explain_fields(select_result *result);
1101
1100
 
1102
 
  /**
1103
 
    Clear the current error, if any.
1104
 
    We do not clear is_fatal_error or is_fatal_sub_stmt_error since we
1105
 
    assume this is never called if the fatal error is set.
1106
 
    @todo: To silence an error, one should use Internal_error_handler
1107
 
    mechanism. In future this function will be removed.
1108
 
  */
1109
 
  inline void clear_error(bool full= false)
1110
 
  {
1111
 
    if (main_da.is_error())
1112
 
      main_da.reset_diagnostics_area();
1113
 
 
1114
 
    if (full)
1115
 
    {
1116
 
      drizzle_reset_errors(this, true);
1117
 
    }
1118
 
  }
1119
 
 
1120
 
  void clearDiagnostics()
1121
 
  {
1122
 
    main_da.reset_diagnostics_area();
1123
 
  }
1124
 
 
1125
 
  /**
1126
 
    Mark the current error as fatal. Warning: this does not
1127
 
    set any error, it sets a property of the error, so must be
1128
 
    followed or prefixed with my_error().
1129
 
  */
1130
 
  inline void fatal_error()
1131
 
  {
1132
 
    assert(main_da.is_error());
1133
 
    is_fatal_error= true;
1134
 
  }
1135
 
  /**
1136
 
    true if there is an error in the error stack.
1137
 
 
1138
 
    Please use this method instead of direct access to
1139
 
    net.report_error.
1140
 
 
1141
 
    If true, the current (sub)-statement should be aborted.
1142
 
    The main difference between this member and is_fatal_error
1143
 
    is that a fatal error can not be handled by a stored
1144
 
    procedure continue handler, whereas a normal error can.
1145
 
 
1146
 
    To raise this flag, use my_error().
1147
 
  */
1148
 
  inline bool is_error() const { return main_da.is_error(); }
 
1101
  void clear_error(bool full= false);
 
1102
  void clearDiagnostics();
 
1103
  void fatal_error();
 
1104
  bool is_error() const;
 
1105
 
1149
1106
  inline const CHARSET_INFO *charset() { return default_charset_info; }
1150
1107
 
1151
1108
  /**
1409
1366
  void mark_used_tables_as_free_for_reuse(Table *table);
1410
1367
 
1411
1368
public:
1412
 
 
1413
 
  /** A short cut for session->main_da.set_ok_status(). */
1414
 
  inline void my_ok(ha_rows affected_rows= 0, ha_rows found_rows_arg= 0,
1415
 
                    uint64_t passed_id= 0, const char *message= NULL)
1416
 
  {
1417
 
    main_da.set_ok_status(this, affected_rows, found_rows_arg, passed_id, message);
1418
 
  }
1419
 
 
1420
 
 
1421
 
  /** A short cut for session->main_da.set_eof_status(). */
1422
 
 
1423
 
  inline void my_eof()
1424
 
  {
1425
 
    main_da.set_eof_status(this);
1426
 
  }
1427
 
 
 
1369
  void my_ok(ha_rows affected_rows= 0, ha_rows found_rows_arg= 0, uint64_t passed_id= 0, const char *message= NULL);
 
1370
  void my_eof();
1428
1371
  bool add_item_to_list(Item *item);
1429
1372
  bool add_value_to_list(Item *value);
1430
1373
  bool add_order_to_list(Item *item, bool asc);
1483
1426
  table::Placeholder *table_cache_insert_placeholder(const identifier::Table &identifier);
1484
1427
  bool lock_table_name_if_not_cached(const identifier::Table &identifier, Table **table);
1485
1428
 
1486
 
  session::TableMessages &getMessageCache()
1487
 
  {
1488
 
    return _table_message_cache;
1489
 
  }
 
1429
  session::TableMessages &getMessageCache();
1490
1430
 
1491
1431
  /* Reopen operations */
1492
1432
  bool reopen_tables();
1515
1455
    @return
1516
1456
    pointer to plugin::StorageEngine
1517
1457
  */
1518
 
  plugin::StorageEngine *getDefaultStorageEngine()
1519
 
  {
1520
 
    if (variables.storage_engine)
1521
 
      return variables.storage_engine;
1522
 
    return global_system_variables.storage_engine;
1523
 
  }
1524
 
 
 
1458
  plugin::StorageEngine *getDefaultStorageEngine();
1525
1459
  void get_xid(DrizzleXid *xid); // Innodb only
1526
1460
 
1527
1461
  table::Singular *getInstanceTable();
1558
1492
    return not getrusage(RUSAGE_THREAD, &usage);
1559
1493
  }
1560
1494
 
1561
 
  session::TableMessages _table_message_cache;
1562
1495
  boost::scoped_ptr<impl_c> impl_;
1563
1496
  catalog::Instance::shared_ptr _catalog;
1564
1497