~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Andrew Hutchings
  • Date: 2010-12-06 19:36:53 UTC
  • mfrom: (1976 staging)
  • mto: This revision was merged to the branch mainline in revision 1991.
  • Revision ID: andrew@linuxjedi.co.uk-20101206193653-l85vryv18jb0yxx8
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include "drizzled/transaction_services.h"
50
50
#include "drizzled/drizzled.h"
51
51
 
52
 
#include "drizzled/identifier.h"
53
 
 
54
52
#include "drizzled/table/instance.h"
55
53
 
56
54
#include "plugin/myisam/myisam.h"
88
86
{
89
87
  return length == other.length &&
90
88
         field_name.length == other.field_name.length &&
91
 
    !my_strcasecmp(system_charset_info, field_name.str, other.field_name.str);
 
89
         !strcmp(field_name.str, other.field_name.str);
92
90
}
93
91
 
94
92
Open_tables_state::Open_tables_state(uint64_t version_arg) :
167
165
  xa_id(0),
168
166
  lex(&main_lex),
169
167
  query(new std::string),
170
 
  _schema(new std::string("")),
171
168
  catalog("LOCAL"),
172
169
  client(client_arg),
173
170
  scheduler(NULL),
174
171
  scheduler_arg(NULL),
175
172
  lock_id(&main_lock_id),
176
 
  thread_stack(NULL),
177
 
  security_ctx(identifier::User::make_shared()),
178
173
  user_time(0),
179
174
  ha_data(plugin::num_trx_monitored_objects),
180
175
  concurrent_execute_allowed(true),
207
202
    will be re-initialized in init_for_queries().
208
203
  */
209
204
  memory::init_sql_alloc(&main_mem_root, memory::ROOT_MIN_BLOCK_SIZE, 0);
 
205
  thread_stack= NULL;
210
206
  count_cuted_fields= CHECK_FIELD_ERROR_FOR_NULL;
211
207
  col_access= 0;
212
208
  tmp_table= 0;
381
377
 
382
378
  if (client->isConnected())
383
379
  {
384
 
    assert(security_ctx);
385
380
    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
 
 
 
381
        errmsg_printf(ERRMSG_LVL_WARN, ER(ER_FORCING_CLOSE),internal::my_progname,
 
382
                      thread_id,
 
383
                      (getSecurityContext().getUser().c_str() ?
 
384
                       getSecurityContext().getUser().c_str() : ""));
393
385
    disconnect(0, false);
394
386
  }
395
387
 
429
421
 
430
422
void Session::awake(Session::killed_state_t state_to_set)
431
423
{
432
 
  if ((state_to_set == Session::KILL_QUERY) and (command == COM_SLEEP))
433
 
    return;
434
 
 
435
424
  this->checkSentry();
436
425
 
437
426
  setKilled(state_to_set);
612
601
*/
613
602
bool Session::isViewable() const
614
603
{
615
 
  return plugin::Authorization::isAuthorized(current_session->user(),
 
604
  return plugin::Authorization::isAuthorized(current_session->getSecurityContext(),
616
605
                                             this,
617
606
                                             false);
618
607
}
658
647
                        const std::string &in_db)
659
648
{
660
649
  bool is_authenticated=
661
 
    plugin::Authentication::isAuthenticated(user(), passwd_str);
 
650
    plugin::Authentication::isAuthenticated(getSecurityContext(),
 
651
                                            passwd_str);
662
652
 
663
653
  if (is_authenticated != true)
664
654
  {
735
725
  }
736
726
 
737
727
  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
 
  }
 
728
  plugin::QueryRewriter::rewriteQuery(getSchema(), *new_query);
743
729
  query.reset(new_query);
744
 
  _state.reset(new State(in_packet, in_packet_length));
745
730
 
746
731
  return true;
747
732
}
1052
1037
  if (not to_file.has_root_directory())
1053
1038
  {
1054
1039
    target_path= fs::system_complete(getDataHomeCatalog());
1055
 
    util::string::const_shared_ptr schema(session->schema());
1056
 
    if (schema and not schema->empty())
 
1040
    if (not session->db.empty())
1057
1041
    {
1058
1042
      int count_elements= 0;
1059
1043
      for (fs::path::iterator iter= to_file.begin();
1063
1047
 
1064
1048
      if (count_elements == 1)
1065
1049
      {
1066
 
        target_path /= *schema;
 
1050
        target_path /= session->db;
1067
1051
      }
1068
1052
    }
1069
1053
    target_path /= to_file;
1121
1105
    {
1122
1106
      if (item->max_length >= MAX_BLOB_WIDTH)
1123
1107
      {
1124
 
        blob_flag=1;
1125
 
        break;
 
1108
        blob_flag=1;
 
1109
        break;
1126
1110
      }
1127
 
 
1128
1111
      if (item->result_type() == STRING_RESULT)
1129
1112
        string_results= true;
1130
1113
      else
1567
1550
 
1568
1551
bool Session::copy_db_to(char **p_db, size_t *p_db_length)
1569
1552
{
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
 
 
 
1553
  if (db.empty())
 
1554
  {
 
1555
    my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
 
1556
    return true;
 
1557
  }
 
1558
  *p_db= strmake(db.c_str(), db.length());
 
1559
  *p_db_length= db.length();
1586
1560
  return false;
1587
1561
}
1588
1562
 
1622
1596
}
1623
1597
 
1624
1598
 
1625
 
void Session::set_db(const std::string &new_db)
 
1599
bool Session::set_db(const std::string &new_db)
1626
1600
{
1627
1601
  /* Do not reallocate memory if current chunk is big enough. */
1628
1602
  if (new_db.length())
1629
 
  {
1630
 
    _schema.reset(new std::string(new_db));
1631
 
  }
 
1603
    db= new_db;
1632
1604
  else
1633
 
  {
1634
 
    _schema.reset(new std::string(""));
1635
 
  }
 
1605
    db.clear();
 
1606
 
 
1607
  return false;
1636
1608
}
1637
1609
 
1638
1610
 
1666
1638
  {
1667
1639
    if (not getKilled() && variables.log_warnings > 1)
1668
1640
    {
 
1641
      SecurityContext *sctx= &security_ctx;
 
1642
 
1669
1643
      errmsg_printf(ERRMSG_LVL_WARN, ER(ER_NEW_ABORTING_CONNECTION)
1670
1644
                  , 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()
 
1645
                  , (db.empty() ? "unconnected" : db.c_str())
 
1646
                  , sctx->getUser().empty() == false ? sctx->getUser().c_str() : "unauthenticated"
 
1647
                  , sctx->getIp().c_str()
1674
1648
                  , (main_da.is_error() ? main_da.message() : ER(ER_UNKNOWN_ERROR)));
1675
1649
    }
1676
1650
  }
2041
2015
      cerr << "\t\t Proto " << proto->schema() << " " << proto->name() << "\n";
2042
2016
    }
2043
2017
    else
2044
 
    {
2045
2018
      cerr << "\tTabl;e Name " << table->getShare()->getSchemaName() << "." << table->getShare()->getTableName() << " : " << answer << "\n";
2046
 
    }
2047
2019
  }
2048
2020
}
2049
2021