~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Brian Aker
  • Date: 2011-11-04 21:06:16 UTC
  • mto: This revision was merged to the branch mainline in revision 2450.
  • Revision ID: brian@tangent.org-20111104210616-2at42agch94dkwb0
Additional fixes for libdrizzle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
348
348
                              const char *db_name,
349
349
                              const char *table_name)
350
350
{
351
 
  for (; table; table= table->*link)
 
351
  for (; table; table= table->*link )
352
352
  {
353
 
    if ((table->table == 0 || table->table->getShare()->getType() == message::Table::STANDARD)
354
 
        && not system_charset_info->strcasecmp(table->getSchemaName(), db_name)
355
 
        && not system_charset_info->strcasecmp(table->getTableName(), table_name))
 
353
    if ((table->table == 0 || table->table->getShare()->getType() == message::Table::STANDARD) and
 
354
        my_strcasecmp(system_charset_info, table->getSchemaName(), db_name) == 0 and
 
355
        my_strcasecmp(system_charset_info, table->getTableName(), table_name) == 0)
356
356
    {
357
357
      break;
358
358
    }
433
433
  {
434
434
    if ((! (res= find_table_in_global_list(table_list, d_name, t_name))) ||
435
435
        ((!res->table || res->table != table->table) &&
436
 
         (!check_alias || !(files_charset_info->strcasecmp(t_alias, res->alias))) &&
 
436
         (!check_alias || !(my_strcasecmp(files_charset_info, t_alias, res->alias))) &&
437
437
         res->select_lex && !res->select_lex->exclude_from_table_unique_test))
438
438
      break;
439
439
    /*
1792
1792
                           const char *name, uint32_t , Item **,
1793
1793
                           bool, TableList **actual_table)
1794
1794
{
1795
 
  List<Natural_join_column>::iterator field_it(table_ref->join_columns->begin());
 
1795
  List<Natural_join_column>::iterator
 
1796
    field_it(table_ref->join_columns->begin());
1796
1797
  Natural_join_column *nj_col, *curr_nj_col;
1797
1798
  Field *found_field;
1798
1799
 
1799
1800
  assert(table_ref->is_natural_join && table_ref->join_columns);
1800
1801
  assert(*actual_table == NULL);
1801
1802
 
1802
 
  for (nj_col= NULL, curr_nj_col= field_it++; curr_nj_col; curr_nj_col= field_it++)
 
1803
  for (nj_col= NULL, curr_nj_col= field_it++; curr_nj_col;
 
1804
       curr_nj_col= field_it++)
1803
1805
  {
1804
 
    if (!system_charset_info->strcasecmp(curr_nj_col->name(), name))
 
1806
    if (!my_strcasecmp(system_charset_info, curr_nj_col->name(), name))
1805
1807
    {
1806
1808
      if (nj_col)
1807
1809
      {
1852
1854
  uint32_t cached_field_index= *cached_field_index_ptr;
1853
1855
 
1854
1856
  /* We assume here that table->field < NO_CACHED_FIELD_INDEX = UINT_MAX */
1855
 
  if (cached_field_index < table->getShare()->sizeFields() 
1856
 
    && not system_charset_info->strcasecmp(table->getField(cached_field_index)->field_name, name))
 
1857
  if (cached_field_index < table->getShare()->sizeFields() &&
 
1858
      !my_strcasecmp(system_charset_info,
 
1859
                     table->getField(cached_field_index)->field_name, name))
1857
1860
  {
1858
1861
    field_ptr= table->getFields() + cached_field_index;
1859
1862
  }
1872
1875
  else
1873
1876
  {
1874
1877
    if (!(field_ptr= table->getFields()))
1875
 
      return NULL;
 
1878
      return((Field *)0);
1876
1879
    for (; *field_ptr; ++field_ptr)
1877
 
      if (not system_charset_info->strcasecmp((*field_ptr)->field_name, name))
 
1880
      if (!my_strcasecmp(system_charset_info, (*field_ptr)->field_name, name))
1878
1881
        break;
1879
1882
  }
1880
1883
 
1886
1889
  else
1887
1890
  {
1888
1891
    if (!allow_rowid ||
1889
 
        system_charset_info->strcasecmp(name, "_rowid") ||
 
1892
        my_strcasecmp(system_charset_info, name, "_rowid") ||
1890
1893
        table->getShare()->rowid_field_offset == 0)
1891
 
      return NULL;
 
1894
      return((Field*) 0);
1892
1895
    field= table->getField(table->getShare()->rowid_field_offset-1);
1893
1896
  }
1894
1897
 
1978
1981
        to search.
1979
1982
      */
1980
1983
      table_name && table_name[0] &&
1981
 
      (table_alias_charset->strcasecmp(table_list->alias, table_name) ||
 
1984
      (my_strcasecmp(table_alias_charset, table_list->alias, table_name) ||
1982
1985
       (db_name && db_name[0] && table_list->getSchemaName() && table_list->getSchemaName()[0] &&
1983
1986
        strcmp(db_name, table_list->getSchemaName()))))
1984
1987
    return 0;
2177
2180
      'name' of the item which may be used in the select list
2178
2181
    */
2179
2182
    strncpy(name_buff, db, sizeof(name_buff)-1);
2180
 
    files_charset_info->casedn_str(name_buff);
 
2183
    my_casedn_str(files_charset_info, name_buff);
2181
2184
    db= name_buff;
2182
2185
  }
2183
2186
 
2362
2365
          item is not fix_field()'ed yet.
2363
2366
        */
2364
2367
        if (item_field->field_name && item_field->table_name &&
2365
 
            not system_charset_info->strcasecmp(item_field->field_name, field_name) &&
2366
 
            not table_alias_charset->strcasecmp(item_field->table_name, table_name) &&
2367
 
            (!db_name || (item_field->db_name && !strcmp(item_field->db_name, db_name))))
 
2368
            !my_strcasecmp(system_charset_info, item_field->field_name,
 
2369
                           field_name) &&
 
2370
            !my_strcasecmp(table_alias_charset, item_field->table_name,
 
2371
                           table_name) &&
 
2372
            (!db_name || (item_field->db_name &&
 
2373
                          !strcmp(item_field->db_name, db_name))))
2368
2374
        {
2369
2375
          if (found_unaliased)
2370
2376
          {
2389
2395
      }
2390
2396
      else
2391
2397
      {
2392
 
        int fname_cmp= system_charset_info->strcasecmp(item_field->field_name, field_name);
2393
 
        if (not system_charset_info->strcasecmp(item_field->name, field_name))
 
2398
        int fname_cmp= my_strcasecmp(system_charset_info,
 
2399
                                     item_field->field_name,
 
2400
                                     field_name);
 
2401
        if (!my_strcasecmp(system_charset_info,
 
2402
                           item_field->name,field_name))
2394
2403
        {
2395
2404
          /*
2396
2405
            If table name was not given we should scan through aliases
2410
2419
          }
2411
2420
          found= li.ref();
2412
2421
          *counter= i;
2413
 
          *resolution= fname_cmp ? RESOLVED_AGAINST_ALIAS : RESOLVED_WITH_NO_ALIAS;
 
2422
          *resolution= fname_cmp ? RESOLVED_AGAINST_ALIAS:
 
2423
            RESOLVED_WITH_NO_ALIAS;
2414
2424
        }
2415
2425
        else if (!fname_cmp)
2416
2426
        {
2434
2444
    else if (!table_name)
2435
2445
    {
2436
2446
      if (is_ref_by_name && find->name && item->name &&
2437
 
          not system_charset_info->strcasecmp(item->name,find->name))
 
2447
          !my_strcasecmp(system_charset_info,item->name,find->name))
2438
2448
      {
2439
2449
        found= li.ref();
2440
2450
        *counter= i;
2507
2517
  {
2508
2518
    if (find_length != curr_str->length())
2509
2519
      continue;
2510
 
    if (not system_charset_info->strcasecmp(find, curr_str->ptr()))
 
2520
    if (!my_strcasecmp(system_charset_info, find, curr_str->ptr()))
2511
2521
      return true;
2512
2522
  }
2513
2523
  return false;
2632
2642
        here. These columns must be checked only on unqualified reference
2633
2643
        by name (e.g. in SELECT list).
2634
2644
      */
2635
 
      if (!system_charset_info->strcasecmp(field_name_1, cur_field_name_2))
 
2645
      if (!my_strcasecmp(system_charset_info, field_name_1, cur_field_name_2))
2636
2646
      {
2637
2647
        if (cur_nj_col_2->is_common ||
2638
2648
            (found && (!using_fields || is_using_column_1)))
2830
2840
          my_error(ER_BAD_FIELD_ERROR, MYF(0), using_field_name_ptr, session->where());
2831
2841
          return true;
2832
2842
        }
2833
 
        if (!system_charset_info->strcasecmp(common_field->name(), using_field_name_ptr))
 
2843
        if (!my_strcasecmp(system_charset_info, common_field->name(), using_field_name_ptr))
2834
2844
          break;                                // Found match
2835
2845
      }
2836
2846
    }
3382
3392
      'name' of the item which may be used in the select list
3383
3393
    */
3384
3394
    strncpy(name_buff, db_name, sizeof(name_buff)-1);
3385
 
    files_charset_info->casedn_str(name_buff);
 
3395
    my_casedn_str(files_charset_info, name_buff);
3386
3396
    db_name= name_buff;
3387
3397
  }
3388
3398
 
3405
3415
 
3406
3416
    assert(tables->is_leaf_for_name_resolution());
3407
3417
 
3408
 
    if ((table_name && table_alias_charset->strcasecmp(table_name, tables->alias)) ||
3409
 
        (db_name && system_charset_info->strcasecmp(tables->getSchemaName(),db_name)))
 
3418
    if ((table_name && my_strcasecmp(table_alias_charset, table_name, tables->alias)) ||
 
3419
        (db_name && my_strcasecmp(system_charset_info, tables->getSchemaName(),db_name)))
3410
3420
      continue;
3411
3421
 
3412
3422
    /*