~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rename.c

  • Committer: Monty
  • Date: 2008-11-07 05:51:15 UTC
  • mto: This revision was merged to the branch mainline in revision 579.
  • Revision ID: mordred@palanthas.inaugust.com-20081107055115-0275gvq62buzls77
Fixed a decimal sign thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/*
17
17
  Rename a table
18
18
*/
19
19
 
20
 
#include "heap_priv.h"
21
 
#include <string.h>
22
 
#include <cstdlib>
 
20
#include "heapdef.h"
23
21
 
24
22
int heap_rename(const char *old_name, const char *new_name)
25
23
{
26
 
  HP_SHARE *info;
 
24
  register HP_SHARE *info;
 
25
  char *name_buff;
27
26
 
28
 
  THR_LOCK_heap.lock();
 
27
  pthread_mutex_lock(&THR_LOCK_heap);
29
28
  if ((info = hp_find_named_heap(old_name)))
30
29
  {
31
 
    info->name.clear();
32
 
    info->name.append(new_name);
 
30
    if (!(name_buff=(char*) my_strdup(new_name,MYF(MY_WME))))
 
31
    {
 
32
      pthread_mutex_unlock(&THR_LOCK_heap);
 
33
      return(my_errno);
 
34
    }
 
35
    free(info->name);
 
36
    info->name=name_buff;
33
37
  }
34
 
  THR_LOCK_heap.unlock();
 
38
  pthread_mutex_unlock(&THR_LOCK_heap);
35
39
  return(0);
36
40
}