~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session.cc

  • Committer: Brian Aker
  • Date: 2010-12-08 18:58:56 UTC
  • mfrom: (1976.5.4 real-trunk)
  • Revision ID: brian@tangent.org-20101208185856-577lkcj42ss9xg7s
MErge in fix for session

Show diffs side-by-side

added added

removed removed

Lines of Context:
165
165
  xa_id(0),
166
166
  lex(&main_lex),
167
167
  query(new std::string),
 
168
  _schema(new std::string("")),
168
169
  catalog("LOCAL"),
169
170
  client(client_arg),
170
171
  scheduler(NULL),
725
726
  }
726
727
 
727
728
  std::string *new_query= new std::string(in_packet, in_packet + in_packet_length);
728
 
  plugin::QueryRewriter::rewriteQuery(getSchema(), *new_query);
 
729
  // We can not be entirely sure _schema has a value
 
730
  if (_schema)
 
731
  {
 
732
    plugin::QueryRewriter::rewriteQuery(*_schema, *new_query);
 
733
  }
729
734
  query.reset(new_query);
 
735
  _state.reset(new State(in_packet, in_packet_length));
730
736
 
731
737
  return true;
732
738
}
1037
1043
  if (not to_file.has_root_directory())
1038
1044
  {
1039
1045
    target_path= fs::system_complete(getDataHomeCatalog());
1040
 
    if (not session->db.empty())
 
1046
    util::string::const_shared_ptr schema(session->schema());
 
1047
    if (schema and not schema->empty())
1041
1048
    {
1042
1049
      int count_elements= 0;
1043
1050
      for (fs::path::iterator iter= to_file.begin();
1047
1054
 
1048
1055
      if (count_elements == 1)
1049
1056
      {
1050
 
        target_path /= session->db;
 
1057
        target_path /= *schema;
1051
1058
      }
1052
1059
    }
1053
1060
    target_path /= to_file;
1550
1557
 
1551
1558
bool Session::copy_db_to(char **p_db, size_t *p_db_length)
1552
1559
{
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();
 
1560
  assert(_schema);
 
1561
  if (_schema and _schema->empty())
 
1562
  {
 
1563
    my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
 
1564
    return true;
 
1565
  }
 
1566
  else if (not _schema)
 
1567
  {
 
1568
    my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
 
1569
    return true;
 
1570
  }
 
1571
  assert(_schema);
 
1572
 
 
1573
  *p_db= strmake(_schema->c_str(), _schema->size());
 
1574
  *p_db_length= _schema->size();
 
1575
 
1560
1576
  return false;
1561
1577
}
1562
1578
 
1596
1612
}
1597
1613
 
1598
1614
 
1599
 
bool Session::set_db(const std::string &new_db)
 
1615
void Session::set_db(const std::string &new_db)
1600
1616
{
1601
1617
  /* Do not reallocate memory if current chunk is big enough. */
1602
1618
  if (new_db.length())
1603
 
    db= new_db;
 
1619
  {
 
1620
    _schema.reset(new std::string(new_db));
 
1621
  }
1604
1622
  else
1605
 
    db.clear();
1606
 
 
1607
 
  return false;
 
1623
  {
 
1624
    _schema.reset(new std::string(""));
 
1625
  }
1608
1626
}
1609
1627
 
1610
1628
 
1642
1660
 
1643
1661
      errmsg_printf(ERRMSG_LVL_WARN, ER(ER_NEW_ABORTING_CONNECTION)
1644
1662
                  , thread_id
1645
 
                  , (db.empty() ? "unconnected" : db.c_str())
 
1663
                  , (_schema->empty() ? "unconnected" : _schema->c_str())
1646
1664
                  , sctx->getUser().empty() == false ? sctx->getUser().c_str() : "unauthenticated"
1647
1665
                  , sctx->getIp().c_str()
1648
1666
                  , (main_da.is_error() ? main_da.message() : ER(ER_UNKNOWN_ERROR)));
2015
2033
      cerr << "\t\t Proto " << proto->schema() << " " << proto->name() << "\n";
2016
2034
    }
2017
2035
    else
 
2036
    {
2018
2037
      cerr << "\tTabl;e Name " << table->getShare()->getSchemaName() << "." << table->getShare()->getTableName() << " : " << answer << "\n";
 
2038
    }
2019
2039
  }
2020
2040
}
2021
2041