~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_base.cc

  • Committer: Toru Maesaka
  • Date: 2008-12-03 07:42:39 UTC
  • mto: (656.1.5 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: dev@torum.net-20081203074239-4qwr4u7prq7uqxet
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
uint32_t create_table_def_key(Session *session, char *key, TableList *table_list,
134
134
                          bool tmp_table)
135
135
{
136
 
  uint32_t key_length= (uint) (my_stpcpy(my_stpcpy(key, table_list->db)+1,
137
 
                                  table_list->table_name)-key)+1;
 
136
  uint32_t key_length;
 
137
  char *key_pos= key;
 
138
  key_pos= strcpy(key_pos, table_list->db) + strlen(table_list->db);
 
139
  key_pos= strcpy(key_pos+1, table_list->table_name) + 
 
140
                  strlen(table_list->table_name);
 
141
  key_length= (uint32_t)(key_pos-key)+1;
 
142
 
138
143
  if (tmp_table)
139
144
  {
140
145
    int4store(key + key_length, session->server_id);
591
596
      open_list=0;                              // Out of memory
592
597
      break;
593
598
    }
594
 
    my_stpcpy((*start_list)->table=
595
 
           my_stpcpy(((*start_list)->db= (char*) ((*start_list)+1)),
596
 
                  share->db.str)+1,
597
 
           share->table_name.str);
 
599
    strcpy((*start_list)->table=
 
600
           strcpy(((*start_list)->db= (char*) ((*start_list)+1)),
 
601
           share->db.str)+share->db.length+1,
 
602
           share->table_name.str);
598
603
    (*start_list)->in_use= entry->in_use ? 1 : 0;
599
604
    (*start_list)->locked= entry->locked_by_name ? 1 : 0;
600
605
    start_list= &(*start_list)->next;
1969
1974
                                   const char *table_name, Table **table)
1970
1975
{
1971
1976
  char key[MAX_DBKEY_LENGTH];
 
1977
  char *key_pos= key;
1972
1978
  uint32_t key_length;
1973
1979
 
1974
 
  key_length= (uint)(my_stpcpy(my_stpcpy(key, db) + 1, table_name) - key) + 1;
 
1980
  key_pos= strcpy(key_pos, db) + strlen(db);
 
1981
  key_pos= strcpy(key_pos+1, table_name) + strlen(table_name);
 
1982
  key_length= (uint32_t) (key_pos-key)+1;
 
1983
 
1975
1984
  pthread_mutex_lock(&LOCK_open);
1976
1985
 
1977
1986
  if (hash_search(&open_cache, (unsigned char *)key, key_length))
2509
2518
 
2510
2519
Table *find_locked_table(Session *session, const char *db,const char *table_name)
2511
2520
{
2512
 
  char  key[MAX_DBKEY_LENGTH];
2513
 
  uint32_t key_length=(uint) (my_stpcpy(my_stpcpy(key,db)+1,table_name)-key)+1;
 
2521
  char key[MAX_DBKEY_LENGTH];
 
2522
  char *key_pos= key;
 
2523
  uint32_t key_length;
 
2524
 
 
2525
  key_pos= strcpy(key_pos, db) + strlen(db);
 
2526
  key_pos= strcpy(key_pos+1, table_name) + strlen(table_name);
 
2527
  key_length= (uint32_t)(key_pos-key)+1;
2514
2528
 
2515
2529
  for (Table *table=session->open_tables; table ; table=table->next)
2516
2530
  {
3233
3247
      if ((query= (char*) my_malloc(query_buf_size,MYF(MY_WME))))
3234
3248
      {
3235
3249
        /* this DELETE FROM is needed even with row-based binlogging */
3236
 
        end = strxmov(my_stpcpy(query, "DELETE FROM `"),
 
3250
        end = strxmov(strcpy(query, "DELETE FROM `")+13,
3237
3251
                      share->db.str,"`.`",share->table_name.str,"`", NULL);
3238
3252
        session->binlog_query(Session::STMT_QUERY_TYPE,
3239
3253
                          query, (ulong)(end-query), false, false);
3771
3785
  Table *tmp_table;
3772
3786
  TABLE_SHARE *share;
3773
3787
  char cache_key[MAX_DBKEY_LENGTH], *saved_cache_key, *tmp_path;
3774
 
  uint32_t key_length;
 
3788
  uint32_t key_length, path_length;
3775
3789
  TableList table_list;
3776
3790
 
3777
3791
  table_list.db=         (char*) db;
3778
3792
  table_list.table_name= (char*) table_name;
3779
3793
  /* Create the cache_key for temporary tables */
3780
3794
  key_length= create_table_def_key(session, cache_key, &table_list, 1);
 
3795
  path_length= strlen(path);
3781
3796
 
3782
3797
  if (!(tmp_table= (Table*) my_malloc(sizeof(*tmp_table) + sizeof(*share) +
3783
 
                                      strlen(path)+1 + key_length,
 
3798
                                      path_length + 1 + key_length,
3784
3799
                                      MYF(MY_WME))))
3785
3800
    return(0);                          /* purecov: inspected */
3786
3801
 
3787
3802
  share= (TABLE_SHARE*) (tmp_table+1);
3788
3803
  tmp_path= (char*) (share+1);
3789
 
  saved_cache_key= my_stpcpy(tmp_path, path)+1;
 
3804
  saved_cache_key= strcpy(tmp_path, path)+path_length+1;
3790
3805
  memcpy(saved_cache_key, cache_key, key_length);
3791
3806
 
3792
3807
  init_tmp_table_share(session, share, saved_cache_key, key_length,
3846
3861
 
3847
3862
  delete_table_proto_file(path);
3848
3863
 
3849
 
  my_stpcpy(ext= strchr(path, '\0'), reg_ext);
 
3864
  strcpy(ext= strchr(path, '\0'), reg_ext);
3850
3865
  if (my_delete(path,MYF(0)))
3851
3866
    error=1; /* purecov: inspected */
3852
3867
  *ext= 0;                              // remove extension
6316
6331
                             uint32_t flags)
6317
6332
{
6318
6333
  char key[MAX_DBKEY_LENGTH];
 
6334
  char *key_pos= key;
6319
6335
  uint32_t key_length;
6320
6336
  Table *table;
6321
6337
  TABLE_SHARE *share;
6322
6338
  bool result= 0, signalled= 0;
6323
6339
 
6324
 
  key_length=(uint) (my_stpcpy(my_stpcpy(key,db)+1,table_name)-key)+1;
 
6340
  key_pos= strcpy(key_pos, db) + strlen(db);
 
6341
  key_pos= strcpy(key_pos+1, table_name) + strlen(table_name);
 
6342
  key_length= (uint32_t) (key_pos-key)+1;
 
6343
 
6325
6344
  for (;;)
6326
6345
  {
6327
6346
    HASH_SEARCH_STATE state;