~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

Merged trunk and mysql-protocol-password-udf changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
592
592
{
593
593
  for (Table *table= temporary_tables ; table ; table= table->next)
594
594
  {
595
 
    if (not db_name.compare(table->s->db.str))
 
595
    if (not db_name.compare(table->s->getSchemaName()))
596
596
    {
597
597
      set_of_names.insert(table->s->table_name.str);
598
598
    }
599
599
  }
600
600
}
601
601
 
602
 
int Session::doGetTableDefinition(const char *,
603
 
                                  const char *db_arg,
604
 
                                  const char *table_name_arg,
605
 
                                  const bool ,
606
 
                                  message::Table *table_proto)
607
 
{
608
 
  for (Table *table= temporary_tables ; table ; table= table->next)
609
 
  {
610
 
    if (table->s->tmp_table == TEMP_TABLE)
611
 
    {
612
 
      if (not strcmp(db_arg, table->s->db.str))
613
 
      {
614
 
        if (not strcmp(table_name_arg, table->s->table_name.str))
615
 
        {
616
 
          if (table_proto)
617
 
            table_proto->CopyFrom(*(table->s->getTableProto()));
 
602
bool Session::doDoesTableExist(TableIdentifier &identifier)
 
603
{
 
604
  for (Table *table= temporary_tables ; table ; table= table->next)
 
605
  {
 
606
    if (table->s->tmp_table == TEMP_TABLE)
 
607
    {
 
608
      if (not strcmp(identifier.getSchemaName().c_str(), table->s->getSchemaName()))
 
609
      {
 
610
        if (not strcmp(identifier.getTableName().c_str(), table->s->table_name.str))
 
611
        {
 
612
          return true;
 
613
        }
 
614
      }
 
615
    }
 
616
  }
 
617
 
 
618
  return false;
 
619
}
 
620
 
 
621
int Session::doGetTableDefinition(TableIdentifier &identifier,
 
622
                                  message::Table &table_proto)
 
623
{
 
624
  for (Table *table= temporary_tables ; table ; table= table->next)
 
625
  {
 
626
    if (table->s->tmp_table == TEMP_TABLE)
 
627
    {
 
628
      if (not strcmp(identifier.getSchemaName().c_str(), table->s->getSchemaName()))
 
629
      {
 
630
        if (not strcmp(identifier.getTableName().c_str(), table->s->table_name.str))
 
631
        {
 
632
          table_proto.CopyFrom(*(table->s->getTableProto()));
618
633
 
619
634
          return EEXIST;
620
635
        }
1002
1017
  @retval  true   Error occured (OOM)
1003
1018
  @retval  false  Success. 'table' parameter set according to above rules.
1004
1019
*/
 
1020
bool Session::lock_table_name_if_not_cached(TableIdentifier &identifier, Table **table)
 
1021
{
 
1022
  return lock_table_name_if_not_cached(identifier.getSchemaName().c_str(), identifier.getTableName().c_str(), table);
 
1023
}
1005
1024
 
1006
1025
bool Session::lock_table_name_if_not_cached(const char *new_db,
1007
1026
                                            const char *table_name, Table **table)
1411
1430
    errmsg_printf(ERRMSG_LVL_ERROR, _("Table %s had a open data Cursor in reopen_table"),
1412
1431
                  table->alias);
1413
1432
#endif
1414
 
  table_list.db=         table->s->db.str;
 
1433
  table_list.db=         const_cast<char *>(table->s->getSchemaName());
1415
1434
  table_list.table_name= table->s->table_name.str;
1416
1435
  table_list.table=      table;
1417
1436
 
1508
1527
  for (table= open_tables; table ; table=table->next)
1509
1528
  {
1510
1529
    if (!strcmp(table->s->table_name.str, new_table_name) &&
1511
 
        !strcmp(table->s->db.str, new_db))
 
1530
        !strcmp(table->s->getSchemaName(), new_db))
1512
1531
    {
1513
1532
      table->open_placeholder= true;
1514
1533
      close_handle_and_leave_table_as_lock(table);
1824
1843
  {
1825
1844
    next=table->next;
1826
1845
    if (!strcmp(table->s->table_name.str, table_name) &&
1827
 
        !strcmp(table->s->db.str, db))
 
1846
        !strcmp(table->s->getSchemaName(), db))
1828
1847
    {
1829
1848
      mysql_lock_remove(session, table);
1830
1849
 
1870
1889
  for (table= session->open_tables; table ; table= table->next)
1871
1890
  {
1872
1891
    if (!strcmp(table->s->table_name.str, table_name) &&
1873
 
        !strcmp(table->s->db.str, db))
 
1892
        !strcmp(table->s->getSchemaName(), db))
1874
1893
    {
1875
1894
      /* If MERGE child, forward lock handling to parent. */
1876
1895
      mysql_lock_abort(session, table);
2252
2271
  uint32_t key_length, path_length;
2253
2272
  TableList table_list;
2254
2273
 
2255
 
  table_list.db=         (char*) identifier.getDBName();
2256
 
  table_list.table_name= (char*) identifier.getTableName();
 
2274
  table_list.db=         (char*) identifier.getDBName().c_str();
 
2275
  table_list.table_name= (char*) identifier.getTableName().c_str();
2257
2276
  /* Create the cache_key for temporary tables */
2258
2277
  key_length= table_list.create_table_def_key(cache_key);
2259
 
  path_length= strlen(identifier.getPath());
 
2278
  path_length= identifier.getPath().length();
2260
2279
 
2261
2280
  if (!(new_tmp_table= (Table*) malloc(sizeof(*new_tmp_table) + sizeof(*share) +
2262
2281
                                       path_length + 1 + key_length)))
2264
2283
 
2265
2284
  share= (TableShare*) (new_tmp_table+1);
2266
2285
  tmp_path= (char*) (share+1);
2267
 
  saved_cache_key= strcpy(tmp_path, identifier.getPath())+path_length+1;
 
2286
  saved_cache_key= strcpy(tmp_path, identifier.getPath().c_str())+path_length+1;
2268
2287
  memcpy(saved_cache_key, cache_key, key_length);
2269
2288
 
2270
2289
  share->init(saved_cache_key, key_length, strchr(saved_cache_key, '\0')+1, tmp_path);
2273
2292
    First open the share, and then open the table from the share we just opened.
2274
2293
  */
2275
2294
  if (open_table_def(*this, share) ||
2276
 
      open_table_from_share(this, share, identifier.getTableName(),
 
2295
      open_table_from_share(this, share, identifier.getTableName().c_str(),
2277
2296
                            (uint32_t) (HA_OPEN_KEYFILE | HA_OPEN_RNDFILE |
2278
2297
                                        HA_GET_INDEX),
2279
2298
                            ha_open_options,
4403
4422
  for (uint32_t idx=0 ; idx < open_cache.records ; idx++)
4404
4423
  {
4405
4424
    Table *table=(Table*) hash_element(&open_cache,idx);
4406
 
    if (not strcmp(table->s->db.str, schema_name.c_str()))
 
4425
    if (not strcmp(table->s->getSchemaName(), schema_name.c_str()))
4407
4426
    {
4408
4427
      table->s->version= 0L;                    /* Free when thread is ready */
4409
4428
      if (not table->in_use)