~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table.cc

Merged trunk and use-std-unordred.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1546
1546
  cursor= 0;                            /* For easier errorchecking */
1547
1547
  if (free_share)
1548
1548
  {
1549
 
    if (s->tmp_table == STANDARD_TABLE)
 
1549
    if (s->tmp_table == message::Table::STANDARD)
1550
1550
      TableShare::release(s);
1551
1551
    else
1552
1552
      s->free_table_share();
1672
1672
      my_error(ER_NO_SUCH_TABLE, MYF(0), db.str, table_name.str);
1673
1673
    else
1674
1674
    {
1675
 
      sprintf(buff,"%s",normalized_path.str);
 
1675
      snprintf(buff, sizeof(buff), "%s",normalized_path.str);
1676
1676
      my_error((db_errno == EMFILE) ? ER_CANT_OPEN_FILE : ER_FILE_NOT_FOUND,
1677
1677
               errortype, buff, db_errno);
1678
1678
    }
1692
1692
    }
1693
1693
    err_no= (db_errno == ENOENT) ? ER_FILE_NOT_FOUND : (db_errno == EAGAIN) ?
1694
1694
      ER_FILE_USED : ER_CANT_OPEN_FILE;
1695
 
    sprintf(buff,"%s%s", normalized_path.str,datext);
 
1695
    snprintf(buff, sizeof(buff), "%s%s", normalized_path.str,datext);
1696
1696
    my_error(err_no,errortype, buff, db_errno);
1697
1697
    delete cursor;
1698
1698
    break;
1712
1712
    break;
1713
1713
  }
1714
1714
  case 6:
1715
 
    sprintf(buff,"%s", normalized_path.str);
 
1715
    snprintf(buff, sizeof(buff), "%s", normalized_path.str);
1716
1716
    my_printf_error(ER_NOT_FORM_FILE,
1717
1717
                    _("Table '%-.64s' was created with a different version "
1718
1718
                    "of Drizzle and cannot be read"),
1722
1722
    break;
1723
1723
  default:                              /* Better wrong error than none */
1724
1724
  case 4:
1725
 
    sprintf(buff,"%s", normalized_path.str);
 
1725
    snprintf(buff, sizeof(buff), "%s", normalized_path.str);
1726
1726
    my_error(ER_NOT_FORM_FILE, errortype, buff, 0);
1727
1727
    break;
1728
1728
  }
1918
1918
    org_name            Name of database and length
1919
1919
 
1920
1920
  RETURN
1921
 
    0   ok
1922
 
    1   error
 
1921
    false error
 
1922
    true ok
1923
1923
*/
1924
1924
 
1925
 
bool check_db_name(LEX_STRING *org_name)
 
1925
bool check_db_name(SchemaIdentifier &schema_identifier)
1926
1926
{
1927
 
  char *name= org_name->str;
1928
 
  uint32_t name_length= org_name->length;
1929
 
 
1930
 
  if (not plugin::Authorization::isAuthorized(current_session->getSecurityContext(),
1931
 
                                              string(name, name_length)))
 
1927
  if (not plugin::Authorization::isAuthorized(current_session->getSecurityContext(), schema_identifier))
1932
1928
  {
1933
 
    return 1;
 
1929
    return false;
1934
1930
  }
1935
1931
 
1936
 
  if (!name_length || name_length > NAME_LEN || name[name_length - 1] == ' ')
1937
 
    return 1;
1938
 
 
1939
 
  my_casedn_str(files_charset_info, name);
1940
 
 
1941
 
  return check_identifier_name(org_name);
 
1932
  return schema_identifier.isValid();
1942
1933
}
1943
1934
 
1944
1935
/*
3302
3293
    if (db_stat)
3303
3294
      cursor->closeMarkForDelete(s->table_name.str);
3304
3295
 
3305
 
    TableIdentifier identifier(s->table_name.str);
 
3296
    TableIdentifier identifier(s->getSchemaName(), s->table_name.str, s->table_name.str);
3306
3297
    s->db_type()->doDropTable(*session, identifier);
3307
3298
 
3308
3299
    delete cursor;
3417
3408
 
3418
3409
 err1:
3419
3410
  {
3420
 
    TableIdentifier identifier(new_table.s->table_name.str);
 
3411
    TableIdentifier identifier(new_table.s->getSchemaName(), new_table.s->table_name.str, new_table.s->table_name.str);
3421
3412
    new_table.s->db_type()->doDropTable(*session, identifier);
3422
3413
  }
3423
3414
 
3691
3682
  key_length= TableShare::createKey(key, identifier);
3692
3683
  share->set_table_cache_key(key, key_length);
3693
3684
 
 
3685
  message::Table *message= share->getTableProto();
 
3686
 
 
3687
  message->set_name(identifier.getTableName());
 
3688
  message->set_schema(identifier.getSchemaName());
 
3689
 
3694
3690
  return false;
3695
3691
}
3696
3692