~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 05:57:49 UTC
  • Revision ID: brian@tangent.org-20081006055749-svg700gciuqi0zu1
Remove all of uchar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
79
79
static bool get_best_combination(JOIN *join);
80
80
static store_key *get_store_key(THD *thd,
81
81
                                KEYUSE *keyuse, table_map used_tables,
82
 
                                KEY_PART_INFO *key_part, uchar *key_buff,
 
82
                                KEY_PART_INFO *key_part, unsigned char *key_buff,
83
83
                                uint maybe_null);
84
84
static bool make_simple_join(JOIN *join,Table *tmp_table);
85
85
static void make_outerjoin_info(JOIN *join);
1989
1989
{
1990
1990
  if (!join_tab_save && select_lex->master_unit()->uncacheable)
1991
1991
  {
1992
 
    if (!(join_tab_save= (JOIN_TAB*)thd->memdup((uchar*) join_tab,
 
1992
    if (!(join_tab_save= (JOIN_TAB*)thd->memdup((unsigned char*) join_tab,
1993
1993
                                                sizeof(JOIN_TAB) * tables)))
1994
1994
      return 1;
1995
1995
  }
2719
2719
  if (!(tbl= (TableList*) thd->calloc(ALIGN_SIZE(sizeof(TableList))+
2720
2720
                                       sizeof(nested_join_st))))
2721
2721
    return NULL;
2722
 
  tbl->nested_join= (nested_join_st*) ((uchar*)tbl + 
 
2722
  tbl->nested_join= (nested_join_st*) ((unsigned char*)tbl + 
2723
2723
                                    ALIGN_SIZE(sizeof(TableList)));
2724
2724
  return tbl;
2725
2725
}
4444
4444
          keyuse.null_rejecting= key_field->null_rejecting;
4445
4445
          keyuse.cond_guard= key_field->cond_guard;
4446
4446
          keyuse.sj_pred_no= key_field->sj_pred_no;
4447
 
          insert_dynamic(keyuse_array,(uchar*) &keyuse);
 
4447
          insert_dynamic(keyuse_array,(unsigned char*) &keyuse);
4448
4448
        }
4449
4449
      }
4450
4450
    }
4673
4673
          (qsort_cmp) sort_keyuse);
4674
4674
 
4675
4675
    memset(&key_end, 0, sizeof(key_end)); /* Add for easy testing */
4676
 
    insert_dynamic(keyuse,(uchar*) &key_end);
 
4676
    insert_dynamic(keyuse,(unsigned char*) &key_end);
4677
4677
 
4678
4678
    use=save_pos=dynamic_element(keyuse,0,KEYUSE*);
4679
4679
    prev= &key_end;
4706
4706
      save_pos++;
4707
4707
    }
4708
4708
    i=(uint) (save_pos-(KEYUSE*) keyuse->buffer);
4709
 
    set_dynamic(keyuse,(uchar*) &key_end,i);
 
4709
    set_dynamic(keyuse,(unsigned char*) &key_end,i);
4710
4710
    keyuse->elements=i;
4711
4711
  }
4712
4712
  return false;
4785
4785
  { /* Collect all query fields referenced in the GROUP clause. */
4786
4786
    for (cur_group= join->group_list; cur_group; cur_group= cur_group->next)
4787
4787
      (*cur_group->item)->walk(&Item::collect_item_field_processor, 0,
4788
 
                               (uchar*) &indexed_fields);
 
4788
                               (unsigned char*) &indexed_fields);
4789
4789
  }
4790
4790
  else if (join->select_distinct)
4791
4791
  { /* Collect all query fields referenced in the SELECT clause. */
4794
4794
    Item *item;
4795
4795
    while ((item= select_items_it++))
4796
4796
      item->walk(&Item::collect_item_field_processor, 0,
4797
 
                 (uchar*) &indexed_fields);
 
4797
                 (unsigned char*) &indexed_fields);
4798
4798
  }
4799
4799
  else
4800
4800
    return;
6464
6464
  j->ref.key_parts=keyparts;
6465
6465
  j->ref.key_length=length;
6466
6466
  j->ref.key=(int) key;
6467
 
  if (!(j->ref.key_buff= (uchar*) thd->calloc(ALIGN_SIZE(length)*2)) ||
 
6467
  if (!(j->ref.key_buff= (unsigned char*) thd->calloc(ALIGN_SIZE(length)*2)) ||
6468
6468
      !(j->ref.key_copy= (store_key**) thd->alloc((sizeof(store_key*) *
6469
6469
                                                   (keyparts+1)))) ||
6470
6470
      !(j->ref.items=    (Item**) thd->alloc(sizeof(Item*)*keyparts)) ||
6479
6479
  keyuse=org_keyuse;
6480
6480
 
6481
6481
  store_key **ref_key= j->ref.key_copy;
6482
 
  uchar *key_buff=j->ref.key_buff, *null_ref_key= 0;
 
6482
  unsigned char *key_buff=j->ref.key_buff, *null_ref_key= 0;
6483
6483
  bool keyuse_uses_no_tables= true;
6484
6484
  {
6485
6485
    uint i;
6551
6551
 
6552
6552
static store_key *
6553
6553
get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables,
6554
 
              KEY_PART_INFO *key_part, uchar *key_buff, uint maybe_null)
 
6554
              KEY_PART_INFO *key_part, unsigned char *key_buff, uint maybe_null)
6555
6555
{
6556
6556
  if (!((~used_tables) & keyuse->used_tables))          // if const item
6557
6557
  {
7039
7039
          tab->type == JT_EQ_REF)
7040
7040
      {
7041
7041
        SQL_SELECT *sel= tab->select= ((SQL_SELECT*)
7042
 
                                       thd->memdup((uchar*) select,
 
7042
                                       thd->memdup((unsigned char*) select,
7043
7043
                                                   sizeof(*select)));
7044
7044
        if (!sel)
7045
7045
          return(1);                    // End of memory
7186
7186
                                         current_map, 0)))
7187
7187
            {
7188
7188
              tab->cache.select=(SQL_SELECT*)
7189
 
                thd->memdup((uchar*) sel, sizeof(SQL_SELECT));
 
7189
                thd->memdup((unsigned char*) sel, sizeof(SQL_SELECT));
7190
7190
              tab->cache.select->cond=tmp;
7191
7191
              tab->cache.select->read_tables=join->const_table_map;
7192
7192
            }
7666
7666
    sorted= 0;                                  // only first must be sorted
7667
7667
    if (tab->insideout_match_tab)
7668
7668
    {
7669
 
      if (!(tab->insideout_buf= (uchar*)join->thd->alloc(tab->table->key_info
 
7669
      if (!(tab->insideout_buf= (unsigned char*)join->thd->alloc(tab->table->key_info
7670
7670
                                                         [tab->index].
7671
7671
                                                         key_length)))
7672
7672
        return true;
8997
8997
      as soon the field is not of a string type or the field reference is
8998
8998
      an argument of a comparison predicate. 
8999
8999
    */ 
9000
 
    uchar *is_subst_valid= (uchar *) 1;
 
9000
    unsigned char *is_subst_valid= (unsigned char *) 1;
9001
9001
    cond= cond->compile(&Item::subst_argument_checker,
9002
9002
                        &is_subst_valid, 
9003
9003
                        &Item::equal_fields_propagator,
9004
 
                        (uchar *) inherited);
 
9004
                        (unsigned char *) inherited);
9005
9005
    cond->update_used_tables();
9006
9006
  }
9007
9007
  return cond;
10922
10922
  int error;
10923
10923
  SJ_TMP_TABLE::TAB *tab= sjtbl->tabs;
10924
10924
  SJ_TMP_TABLE::TAB *tab_end= sjtbl->tabs_end;
10925
 
  uchar *ptr= sjtbl->tmp_table->record[0] + 1;
10926
 
  uchar *nulls_ptr= ptr;
 
10925
  unsigned char *ptr= sjtbl->tmp_table->record[0] + 1;
 
10926
  unsigned char *nulls_ptr= ptr;
10927
10927
  
10928
10928
  /* Put the the rowids tuple into table->record[0]: */
10929
10929
 
10930
10930
  // 1. Store the length 
10931
10931
  if (((Field_varstring*)(sjtbl->tmp_table->field[0]))->length_bytes == 1)
10932
10932
  {
10933
 
    *ptr= (uchar)(sjtbl->rowid_len + sjtbl->null_bytes);
 
10933
    *ptr= (unsigned char)(sjtbl->rowid_len + sjtbl->null_bytes);
10934
10934
    ptr++;
10935
10935
  }
10936
10936
  else
11426
11426
    else
11427
11427
    {
11428
11428
      error=table->file->index_read_idx_map(table->record[0],tab->ref.key,
11429
 
                                            (uchar*) tab->ref.key_buff,
 
11429
                                            (unsigned char*) tab->ref.key_buff,
11430
11430
                                            make_prev_keypart_map(tab->ref.key_parts),
11431
11431
                                            HA_READ_KEY_EXACT);
11432
11432
    }
12054
12054
        if (item->maybe_null)
12055
12055
        {
12056
12056
          Field *field=item->get_tmp_table_field();
12057
 
          field->ptr[-1]= (uchar) (field->is_null() ? 1 : 0);
 
12057
          field->ptr[-1]= (unsigned char) (field->is_null() ? 1 : 0);
12058
12058
        }
12059
12059
      }
12060
12060
    }
13489
13489
{
13490
13490
  handler *file=table->file;
13491
13491
  char *org_record,*new_record;
13492
 
  uchar *record;
 
13492
  unsigned char *record;
13493
13493
  int error;
13494
13494
  ulong reclength= table->s->reclength-offset;
13495
13495
 
13581
13581
                                      ulong key_length,
13582
13582
                                      Item *having)
13583
13583
{
13584
 
  uchar *key_buffer, *key_pos, *record=table->record[0];
 
13584
  unsigned char *key_buffer, *key_pos, *record=table->record[0];
13585
13585
  int error;
13586
13586
  handler *file= table->file;
13587
13587
  ulong extra_length= ALIGN_SIZE(key_length)-key_length;
13622
13622
  key_pos=key_buffer;
13623
13623
  for (;;)
13624
13624
  {
13625
 
    uchar *org_key_pos;
 
13625
    unsigned char *org_key_pos;
13626
13626
    if (thd->killed)
13627
13627
    {
13628
13628
      thd->send_kill_message();
13758
13758
 
13759
13759
                  sizeof(CACHE_FIELD*))))
13760
13760
  {
13761
 
    free((uchar*) cache->buff);         /* purecov: inspected */
 
13761
    free((unsigned char*) cache->buff);         /* purecov: inspected */
13762
13762
    cache->buff=0;                              /* purecov: inspected */
13763
13763
    return(1);                          /* purecov: inspected */
13764
13764
  }
13804
13804
    /* If outer join table, copy null_row flag */
13805
13805
    if (tables[i].table->maybe_null)
13806
13806
    {
13807
 
      copy->str= (uchar*) &tables[i].table->null_row;
 
13807
      copy->str= (unsigned char*) &tables[i].table->null_row;
13808
13808
      copy->length=sizeof(tables[i].table->null_row);
13809
13809
      copy->strip=0;
13810
13810
      copy->blob_field=0;
13836
13836
  cache->blobs=blobs;
13837
13837
  *blob_ptr=0;                                  /* End sequentel */
13838
13838
  size=cmax(thd->variables.join_buff_size, (ulong)cache->length);
13839
 
  if (!(cache->buff=(uchar*) my_malloc(size,MYF(0))))
 
13839
  if (!(cache->buff=(unsigned char*) my_malloc(size,MYF(0))))
13840
13840
    return(1);                          /* Don't use cache */ /* purecov: inspected */
13841
13841
  cache->end=cache->buff+size;
13842
13842
  reset_cache_write(cache);
13862
13862
store_record_in_cache(JOIN_CACHE *cache)
13863
13863
{
13864
13864
  uint length;
13865
 
  uchar *pos;
 
13865
  unsigned char *pos;
13866
13866
  CACHE_FIELD *copy,*end_field;
13867
13867
  bool last_record;
13868
13868
 
13904
13904
 
13905
13905
      if (copy->strip)
13906
13906
      {
13907
 
        uchar *str,*end;
 
13907
        unsigned char *str,*end;
13908
13908
        for (str=copy->str,end= str+copy->length;
13909
13909
             end > str && end[-1] == ' ' ;
13910
13910
             end--) ;
13944
13944
static void
13945
13945
read_cached_record(JOIN_TAB *tab)
13946
13946
{
13947
 
  uchar *pos;
 
13947
  unsigned char *pos;
13948
13948
  uint length;
13949
13949
  bool last_record;
13950
13950
  CACHE_FIELD *copy,*end_field;
14746
14746
  for (i= 0; (pos= li++); i++)
14747
14747
  {
14748
14748
    Field *field;
14749
 
    uchar *tmp;
 
14749
    unsigned char *tmp;
14750
14750
    Item *real_pos= pos->real_item();
14751
14751
    if (real_pos->type() == Item::FIELD_ITEM)
14752
14752
    {
14791
14791
          another extra byte to not get warnings from purify in
14792
14792
          Field_varstring::val_int
14793
14793
        */
14794
 
        if (!(tmp= (uchar*) sql_alloc(field->pack_length()+2)))
 
14794
        if (!(tmp= (unsigned char*) sql_alloc(field->pack_length()+2)))
14795
14795
          goto err;
14796
14796
        if (copy)
14797
14797
        {
16337
16337
  if (key_name.length)
16338
16338
  {
16339
16339
    if (thd && !my_strnncoll(system_charset_info,
16340
 
                             (const uchar *)key_name.str, key_name.length, 
16341
 
                             (const uchar *)primary_key_name, 
 
16340
                             (const unsigned char *)key_name.str, key_name.length, 
 
16341
                             (const unsigned char *)primary_key_name, 
16342
16342
                             strlen(primary_key_name)))
16343
16343
      str->append(primary_key_name);
16344
16344
    else