~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2011-02-12 10:06:03 UTC
  • mfrom: (2154.2.16 drizzle-build)
  • Revision ID: brian@tangent.org-20110212100603-i5ww0s02p8l4a8q7
Merge in solaris tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 */
23
23
 
24
24
#include "config.h"
 
25
 
 
26
#include <drizzled/copy_field.h>
25
27
#include "drizzled/session.h"
26
28
#include "drizzled/session/cache.h"
27
 
#include <sys/stat.h>
28
29
#include "drizzled/error.h"
29
30
#include "drizzled/gettext.h"
30
31
#include "drizzled/query_id.h"
51
52
 
52
53
#include "drizzled/identifier.h"
53
54
 
 
55
#include <drizzled/refresh_version.h>
 
56
 
54
57
#include "drizzled/table/singular.h"
55
58
 
56
59
#include "plugin/myisam/myisam.h"
62
65
 
63
66
#include "drizzled/display.h"
64
67
 
65
 
#include <fcntl.h>
66
68
#include <algorithm>
67
69
#include <climits>
 
70
#include <fcntl.h>
 
71
#include <sys/stat.h>
68
72
 
69
73
#include <boost/filesystem.hpp>
70
74
#include <boost/checked_delete.hpp>
388
392
 
389
393
  plugin::Logging::postEndDo(this);
390
394
  plugin::EventObserver::deregisterSessionEvents(*this); 
391
 
 
392
 
  for (PropertyMap::iterator iter= life_properties.begin(); iter != life_properties.end(); iter++)
393
 
  {
394
 
    boost::checked_delete((*iter).second);
395
 
  }
396
 
  life_properties.clear();
397
395
}
398
396
 
399
397
void Session::setClient(plugin::Client *client_arg)
715
713
    plugin::QueryRewriter::rewriteQuery(*_schema, *new_query);
716
714
  }
717
715
  query.reset(new_query);
718
 
  _state.reset(new State(in_packet, in_packet_length));
 
716
  _state.reset(new session::State(in_packet, in_packet_length));
719
717
 
720
718
  return true;
721
719
}
873
871
                                     bool allocate_lex_string)
874
872
{
875
873
  if (allocate_lex_string)
876
 
    if (!(lex_str= (LEX_STRING *)alloc(sizeof(LEX_STRING))))
 
874
    if (!(lex_str= (LEX_STRING *)getMemRoot()->allocate(sizeof(LEX_STRING))))
877
875
      return 0;
878
876
  if (!(lex_str->str= mem_root->strmake_root(str, length)))
879
877
    return 0;
2009
2007
  }
2010
2008
}
2011
2009
 
2012
 
bool Session::TableMessages::storeTableMessage(const identifier::Table &identifier, message::Table &table_message)
2013
 
{
2014
 
  table_message_cache.insert(make_pair(identifier.getPath(), table_message));
2015
 
 
2016
 
  return true;
2017
 
}
2018
 
 
2019
 
bool Session::TableMessages::removeTableMessage(const identifier::Table &identifier)
2020
 
{
2021
 
  TableMessageCache::iterator iter;
2022
 
 
2023
 
  iter= table_message_cache.find(identifier.getPath());
2024
 
 
2025
 
  if (iter == table_message_cache.end())
2026
 
    return false;
2027
 
 
2028
 
  table_message_cache.erase(iter);
2029
 
 
2030
 
  return true;
2031
 
}
2032
 
 
2033
 
bool Session::TableMessages::getTableMessage(const identifier::Table &identifier, message::Table &table_message)
2034
 
{
2035
 
  TableMessageCache::iterator iter;
2036
 
 
2037
 
  iter= table_message_cache.find(identifier.getPath());
2038
 
 
2039
 
  if (iter == table_message_cache.end())
2040
 
    return false;
2041
 
 
2042
 
  table_message.CopyFrom(((*iter).second));
2043
 
 
2044
 
  return true;
2045
 
}
2046
 
 
2047
 
bool Session::TableMessages::doesTableMessageExist(const identifier::Table &identifier)
2048
 
{
2049
 
  TableMessageCache::iterator iter;
2050
 
 
2051
 
  iter= table_message_cache.find(identifier.getPath());
2052
 
 
2053
 
  if (iter == table_message_cache.end())
2054
 
  {
2055
 
    return false;
2056
 
  }
2057
 
 
2058
 
  return true;
2059
 
}
2060
 
 
2061
 
bool Session::TableMessages::renameTableMessage(const identifier::Table &from, const identifier::Table &to)
2062
 
{
2063
 
  TableMessageCache::iterator iter;
2064
 
 
2065
 
  table_message_cache[to.getPath()]= table_message_cache[from.getPath()];
2066
 
 
2067
 
  iter= table_message_cache.find(to.getPath());
2068
 
 
2069
 
  if (iter == table_message_cache.end())
2070
 
  {
2071
 
    return false;
2072
 
  }
2073
 
 
2074
 
  (*iter).second.set_schema(to.getSchemaName());
2075
 
  (*iter).second.set_name(to.getTableName());
2076
 
 
2077
 
  return true;
2078
 
}
2079
 
 
2080
2010
table::Singular *Session::getInstanceTable()
2081
2011
{
2082
2012
  temporary_shares.push_back(new table::Singular()); // This will not go into the tableshare cache, so no key is used.