~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • 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:
23
23
 
24
24
#include <config.h>
25
25
 
 
26
#include <boost/checked_delete.hpp>
 
27
#include <boost/filesystem.hpp>
26
28
#include <drizzled/copy_field.h>
27
29
#include <drizzled/data_home.h>
 
30
#include <drizzled/diagnostics_area.h>
28
31
#include <drizzled/display.h>
29
32
#include <drizzled/drizzled.h>
30
33
#include <drizzled/error.h>
31
34
#include <drizzled/gettext.h>
 
35
#include <drizzled/ha_data.h>
32
36
#include <drizzled/identifier.h>
33
37
#include <drizzled/internal/iocache.h>
34
38
#include <drizzled/internal/thread_var.h>
37
41
#include <drizzled/item/empty_string.h>
38
42
#include <drizzled/item/float.h>
39
43
#include <drizzled/item/return_int.h>
 
44
#include <drizzled/item/subselect.h>
40
45
#include <drizzled/lock.h>
41
46
#include <drizzled/plugin/authentication.h>
42
47
#include <drizzled/plugin/authorization.h>
50
55
#include <drizzled/pthread_globals.h>
51
56
#include <drizzled/query_id.h>
52
57
#include <drizzled/refresh_version.h>
 
58
#include <drizzled/schema.h>
53
59
#include <drizzled/select_dump.h>
54
60
#include <drizzled/select_exists_subselect.h>
55
61
#include <drizzled/select_export.h>
59
65
#include <drizzled/select_to_file.h>
60
66
#include <drizzled/session.h>
61
67
#include <drizzled/session/cache.h>
 
68
#include <drizzled/session/property_map.h>
 
69
#include <drizzled/session/state.h>
 
70
#include <drizzled/session/table_messages.h>
62
71
#include <drizzled/show.h>
63
72
#include <drizzled/sql_base.h>
 
73
#include <drizzled/sql_lex.h>
 
74
#include <drizzled/statement.h>
64
75
#include <drizzled/table/singular.h>
65
76
#include <drizzled/table_proto.h>
66
77
#include <drizzled/tmp_table_param.h>
67
78
#include <drizzled/transaction_services.h>
68
79
#include <drizzled/user_var_entry.h>
 
80
#include <drizzled/util/backtrace.h>
 
81
#include <drizzled/util/find_ptr.h>
69
82
#include <drizzled/util/functors.h>
70
 
#include <drizzled/util/find_ptr.h>
71
83
#include <plugin/myisam/myisam.h>
72
 
#include <drizzled/item/subselect.h>
73
 
#include <drizzled/statement.h>
74
 
#include <drizzled/sql_lex.h>
75
 
#include <drizzled/ha_data.h>
76
 
#include <drizzled/diagnostics_area.h>
77
 
#include <drizzled/session/state.h>
78
84
 
79
85
#include <algorithm>
80
86
#include <climits>
81
87
#include <fcntl.h>
82
88
#include <sys/stat.h>
83
89
 
84
 
#include <boost/filesystem.hpp>
85
 
#include <boost/checked_delete.hpp>
86
 
 
87
 
#include <drizzled/util/backtrace.h>
88
 
 
89
 
#include <drizzled/schema.h>
90
 
 
91
90
using namespace std;
92
91
 
93
 
namespace fs=boost::filesystem;
94
 
namespace drizzled
95
 
{
 
92
namespace fs= boost::filesystem;
 
93
 
 
94
namespace drizzled {
96
95
 
97
96
/*
98
97
  The following is used to initialise Table_ident with a internal
124
123
{
125
124
  char filename[FN_REFLEN];
126
125
  int fd = internal::create_temp_file(filename, drizzle_tmpdir.c_str(), prefix, MYF(MY_WME));
127
 
  if (fd >= 0) {
 
126
  if (fd >= 0)
128
127
    unlink(filename);
129
 
  }
130
 
 
131
128
  return fd;
132
129
}
133
130
 
136
133
  return static_cast<void **>(&ha_data[monitored->getId()].ha_ptr);
137
134
}
138
135
 
139
 
ResourceContext *Session::getResourceContext(const plugin::MonitoredInTransaction *monitored,
140
 
                                             size_t index)
 
136
ResourceContext& Session::getResourceContext(const plugin::MonitoredInTransaction& monitored, size_t index)
141
137
{
142
 
  return &ha_data[monitored->getId()].resource_context[index];
 
138
  return ha_data[monitored.getId()].resource_context[index];
143
139
}
144
140
 
145
141
int64_t session_test_options(const Session *session, int64_t test_options)
150
146
class Session::impl_c
151
147
{
152
148
public:
 
149
  typedef session::PropertyMap properties_t;
 
150
 
153
151
  Diagnostics_area diagnostics;
154
152
  /**
155
153
    The lex to hold the parsed tree of conventional (non-prepared) queries.
158
156
    the same lex. (@see mysql_parse for details).
159
157
  */
160
158
  LEX lex;
 
159
  properties_t properties;
161
160
  session::TableMessages table_message_cache;
162
161
};
163
162
 
166
165
  mem_root(&main_mem_root),
167
166
  query(new std::string),
168
167
  _schema(new std::string),
169
 
  client(client_arg),
170
168
  scheduler(NULL),
171
169
  scheduler_arg(NULL),
172
170
  lock_id(&main_lock_id),
173
171
  thread_stack(NULL),
174
 
  security_ctx(identifier::User::make_shared()),
175
172
  _where(Session::DEFAULT_WHERE),
176
 
  dbug_sentry(Session_SENTRY_MAGIC),
177
173
  mysys_var(0),
178
174
  command(COM_CONNECT),
179
175
  file_id(0),
218
214
  xa_id(0),
219
215
  concurrent_execute_allowed(true),
220
216
  tablespace_op(false),
221
 
  use_usage(false)
 
217
  use_usage(false),
 
218
  security_ctx(identifier::User::make_shared()),
 
219
  client(client_arg)
222
220
{
223
221
  client->setSession(this);
224
222
 
322
320
 
323
321
bool Session::add_value_to_list(Item *value)
324
322
{
325
 
  return lex().value_list.push_back(value);
 
323
        lex().value_list.push_back(value);
 
324
  return false;
326
325
}
327
326
 
328
327
bool Session::add_order_to_list(Item *item, bool asc)
400
399
 
401
400
/* Do operations that may take a long time */
402
401
 
403
 
void Session::cleanup(void)
 
402
void Session::cleanup()
404
403
{
405
404
  assert(cleanup_done == false);
406
405
 
438
437
 
439
438
Session::~Session()
440
439
{
441
 
  this->checkSentry();
442
 
 
443
440
  if (client and client->isConnected())
444
441
  {
445
442
    assert(security_ctx);
470
467
 
471
468
  warn_root.free_root(MYF(0));
472
469
  mysys_var=0;                                  // Safety (shouldn't be needed)
473
 
  dbug_sentry= Session_SENTRY_GONE;
474
470
 
475
471
  main_mem_root.free_root(MYF(0));
476
472
  currentMemRoot().release();
496
492
  if ((state_to_set == Session::KILL_QUERY) and (command == COM_SLEEP))
497
493
    return;
498
494
 
499
 
  this->checkSentry();
500
 
 
501
495
  setKilled(state_to_set);
502
496
  scheduler->killSession(this);
503
497
 
913
907
    Reset rand_used so that detection of calls to rand() will save random
914
908
    seeds if needed by the slave.
915
909
  */
916
 
  {
917
 
    /* Forget those values, for next binlogger: */
918
 
    auto_inc_intervals_in_cur_stmt_for_binlog.empty();
919
 
  }
920
910
  if (first_successful_insert_id_in_cur_stmt > 0)
921
911
  {
922
912
    /* set what LAST_INSERT_ID() will return */
1750
1740
{
1751
1741
  free_list= 0;
1752
1742
  select_number= 1;
1753
 
  /*
1754
 
    Those two lines below are theoretically unneeded as
1755
 
    Session::cleanup_after_query() should take care of this already.
1756
 
  */
1757
 
  auto_inc_intervals_in_cur_stmt_for_binlog.empty();
1758
1743
 
1759
1744
  is_fatal_error= false;
1760
1745
  server_status&= ~ (SERVER_MORE_RESULTS_EXISTS |
2204
2189
  return (enum_tx_isolation)variables.tx_isolation;
2205
2190
}
2206
2191
 
2207
 
namespace display  {
2208
 
 
2209
 
static const std::string NONE= "NONE";
2210
 
static const std::string GOT_GLOBAL_READ_LOCK= "HAS GLOBAL READ LOCK";
2211
 
static const std::string MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT= "HAS GLOBAL READ LOCK WITH BLOCKING COMMIT";
2212
 
 
2213
 
const std::string &type(drizzled::Session::global_read_lock_t type)
2214
 
{
2215
 
  switch (type) {
 
2192
drizzled::util::Storable* Session::getProperty0(const std::string& arg)
 
2193
{
 
2194
  return impl_->properties.getProperty(arg);
 
2195
}
 
2196
 
 
2197
void Session::setProperty0(const std::string& arg, drizzled::util::Storable* value)
 
2198
{
 
2199
  impl_->properties.setProperty(arg, value);
 
2200
}
 
2201
 
 
2202
const std::string& display::type(drizzled::Session::global_read_lock_t type)
 
2203
{
 
2204
  static const std::string NONE= "NONE";
 
2205
  static const std::string GOT_GLOBAL_READ_LOCK= "HAS GLOBAL READ LOCK";
 
2206
  static const std::string MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT= "HAS GLOBAL READ LOCK WITH BLOCKING COMMIT";
 
2207
 
 
2208
  switch (type) 
 
2209
  {
2216
2210
    default:
2217
2211
    case Session::NONE:
2218
2212
      return NONE;
2223
2217
  }
2224
2218
}
2225
2219
 
2226
 
size_t max_string_length(drizzled::Session::global_read_lock_t)
 
2220
size_t display::max_string_length(drizzled::Session::global_read_lock_t)
2227
2221
{
2228
 
  return MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT.size();
 
2222
  return display::type(Session::MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT).size();
2229
2223
}
2230
2224
 
2231
 
} /* namespace display */
2232
 
 
2233
2225
} /* namespace drizzled */