~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2010-11-30 00:29:39 UTC
  • mto: (1965.2.2 build)
  • mto: This revision was merged to the branch mainline in revision 1966.
  • Revision ID: brian@tangent.org-20101130002939-8bzz3xpa0aapbq2w
Fix sleep() so that a kill command will kill it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include "config.h"
25
25
#include "drizzled/session.h"
26
 
#include "drizzled/session/cache.h"
 
26
#include "drizzled/session_list.h"
27
27
#include <sys/stat.h>
28
28
#include "drizzled/error.h"
29
29
#include "drizzled/gettext.h"
41
41
#include "drizzled/plugin/authentication.h"
42
42
#include "drizzled/plugin/logging.h"
43
43
#include "drizzled/plugin/transactional_storage_engine.h"
44
 
#include "drizzled/plugin/query_rewrite.h"
45
44
#include "drizzled/probes.h"
46
45
#include "drizzled/table_proto.h"
47
46
#include "drizzled/db.h"
49
48
#include "drizzled/transaction_services.h"
50
49
#include "drizzled/drizzled.h"
51
50
 
52
 
#include "drizzled/identifier.h"
53
 
 
54
51
#include "drizzled/table/instance.h"
55
52
 
56
53
#include "plugin/myisam/myisam.h"
88
85
{
89
86
  return length == other.length &&
90
87
         field_name.length == other.field_name.length &&
91
 
    !my_strcasecmp(system_charset_info, field_name.str, other.field_name.str);
 
88
         !strcmp(field_name.str, other.field_name.str);
92
89
}
93
90
 
94
91
Open_tables_state::Open_tables_state(uint64_t version_arg) :
167
164
  xa_id(0),
168
165
  lex(&main_lex),
169
166
  query(new std::string),
170
 
  _schema(new std::string("")),
171
167
  catalog("LOCAL"),
172
168
  client(client_arg),
173
169
  scheduler(NULL),
174
170
  scheduler_arg(NULL),
175
171
  lock_id(&main_lock_id),
176
 
  thread_stack(NULL),
177
 
  security_ctx(identifier::User::make_shared()),
178
172
  user_time(0),
179
173
  ha_data(plugin::num_trx_monitored_objects),
180
174
  concurrent_execute_allowed(true),
207
201
    will be re-initialized in init_for_queries().
208
202
  */
209
203
  memory::init_sql_alloc(&main_mem_root, memory::ROOT_MIN_BLOCK_SIZE, 0);
 
204
  thread_stack= NULL;
210
205
  count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
211
206
  col_access= 0;
212
207
  tmp_table= 0;
381
376
 
382
377
  if (client->isConnected())
383
378
  {
384
 
    assert(security_ctx);
385
379
    if (global_system_variables.log_warnings)
386
 
    {
387
 
      errmsg_printf(ERRMSG_LVL_WARN, ER(ER_FORCING_CLOSE),
388
 
                    internal::my_progname,
389
 
                    thread_id,
390
 
                    security_ctx->username().c_str());
391
 
    }
392
 
 
 
380
        errmsg_printf(ERRMSG_LVL_WARN, ER(ER_FORCING_CLOSE),internal::my_progname,
 
381
                      thread_id,
 
382
                      (getSecurityContext().getUser().c_str() ?
 
383
                       getSecurityContext().getUser().c_str() : ""));
393
384
    disconnect(0, false);
394
385
  }
395
386
 
429
420
 
430
421
void Session::awake(Session::killed_state_t state_to_set)
431
422
{
432
 
  if ((state_to_set == Session::KILL_QUERY) and (command == COM_SLEEP))
433
 
    return;
434
 
 
435
423
  this->checkSentry();
436
424
 
437
425
  setKilled(state_to_set);
612
600
*/
613
601
bool Session::isViewable() const
614
602
{
615
 
  return plugin::Authorization::isAuthorized(current_session->user(),
 
603
  return plugin::Authorization::isAuthorized(current_session->getSecurityContext(),
616
604
                                             this,
617
605
                                             false);
618
606
}
658
646
                        const std::string &in_db)
659
647
{
660
648
  bool is_authenticated=
661
 
    plugin::Authentication::isAuthenticated(user(), passwd_str);
 
649
    plugin::Authentication::isAuthenticated(getSecurityContext(),
 
650
                                            passwd_str);
662
651
 
663
652
  if (is_authenticated != true)
664
653
  {
734
723
    in_packet_length--;
735
724
  }
736
725
 
737
 
  std::string *new_query= new std::string(in_packet, in_packet + in_packet_length);
738
 
  // We can not be entirely sure _schema has a value
739
 
  if (_schema)
740
 
  {
741
 
    plugin::QueryRewriter::rewriteQuery(*_schema, *new_query);
742
 
  }
743
 
  query.reset(new_query);
744
 
  _state.reset(new State(in_packet, in_packet_length));
 
726
  query.reset(new std::string(in_packet, in_packet + in_packet_length));
745
727
 
746
728
  return true;
747
729
}
1052
1034
  if (not to_file.has_root_directory())
1053
1035
  {
1054
1036
    target_path= fs::system_complete(getDataHomeCatalog());
1055
 
    util::string::const_shared_ptr schema(session->schema());
1056
 
    if (schema and not schema->empty())
 
1037
    if (not session->db.empty())
1057
1038
    {
1058
1039
      int count_elements= 0;
1059
1040
      for (fs::path::iterator iter= to_file.begin();
1063
1044
 
1064
1045
      if (count_elements == 1)
1065
1046
      {
1066
 
        target_path /= *schema;
 
1047
        target_path /= session->db;
1067
1048
      }
1068
1049
    }
1069
1050
    target_path /= to_file;
1121
1102
    {
1122
1103
      if (item->max_length >= MAX_BLOB_WIDTH)
1123
1104
      {
1124
 
        blob_flag=1;
1125
 
        break;
 
1105
        blob_flag=1;
 
1106
        break;
1126
1107
      }
1127
 
 
1128
1108
      if (item->result_type() == STRING_RESULT)
1129
1109
        string_results= true;
1130
1110
      else
1567
1547
 
1568
1548
bool Session::copy_db_to(char **p_db, size_t *p_db_length)
1569
1549
{
1570
 
  assert(_schema);
1571
 
  if (_schema and _schema->empty())
1572
 
  {
1573
 
    my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
1574
 
    return true;
1575
 
  }
1576
 
  else if (not _schema)
1577
 
  {
1578
 
    my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
1579
 
    return true;
1580
 
  }
1581
 
  assert(_schema);
1582
 
 
1583
 
  *p_db= strmake(_schema->c_str(), _schema->size());
1584
 
  *p_db_length= _schema->size();
1585
 
 
 
1550
  if (db.empty())
 
1551
  {
 
1552
    my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
 
1553
    return true;
 
1554
  }
 
1555
  *p_db= strmake(db.c_str(), db.length());
 
1556
  *p_db_length= db.length();
1586
1557
  return false;
1587
1558
}
1588
1559
 
1622
1593
}
1623
1594
 
1624
1595
 
1625
 
void Session::set_db(const std::string &new_db)
 
1596
bool Session::set_db(const std::string &new_db)
1626
1597
{
1627
1598
  /* Do not reallocate memory if current chunk is big enough. */
1628
1599
  if (new_db.length())
1629
 
  {
1630
 
    _schema.reset(new std::string(new_db));
1631
 
  }
 
1600
    db= new_db;
1632
1601
  else
1633
 
  {
1634
 
    _schema.reset(new std::string(""));
1635
 
  }
 
1602
    db.clear();
 
1603
 
 
1604
  return false;
1636
1605
}
1637
1606
 
1638
1607
 
1666
1635
  {
1667
1636
    if (not getKilled() && variables.log_warnings > 1)
1668
1637
    {
 
1638
      SecurityContext *sctx= &security_ctx;
 
1639
 
1669
1640
      errmsg_printf(ERRMSG_LVL_WARN, ER(ER_NEW_ABORTING_CONNECTION)
1670
1641
                  , thread_id
1671
 
                  , (_schema->empty() ? "unconnected" : _schema->c_str())
1672
 
                  , security_ctx->username().empty() == false ? security_ctx->username().c_str() : "unauthenticated"
1673
 
                  , security_ctx->address().c_str()
 
1642
                  , (db.empty() ? "unconnected" : db.c_str())
 
1643
                  , sctx->getUser().empty() == false ? sctx->getUser().c_str() : "unauthenticated"
 
1644
                  , sctx->getIp().c_str()
1674
1645
                  , (main_da.is_error() ? main_da.message() : ER(ER_UNKNOWN_ERROR)));
1675
1646
    }
1676
1647
  }
2041
2012
      cerr << "\t\t Proto " << proto->schema() << " " << proto->name() << "\n";
2042
2013
    }
2043
2014
    else
2044
 
    {
2045
2015
      cerr << "\tTabl;e Name " << table->getShare()->getSchemaName() << "." << table->getShare()->getTableName() << " : " << answer << "\n";
2046
 
    }
2047
2016
  }
2048
2017
}
2049
2018