~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_cache.c

code clean up to moving functions into drizzled/functions directory - Item_num_op and Item_numhybrid

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <mysys/mysys_err.h>
22
22
#include <mysys/iocache.h>
23
23
 
 
24
        /*
 
25
          Remove an open tempfile so that it doesn't survive
 
26
          if we crash;  If the operating system doesn't support
 
27
          this, just remember the file name for later removal
 
28
        */
 
29
 
 
30
static bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)),
 
31
                                     const char *name)
 
32
{
 
33
#if O_TEMPORARY == 0
 
34
#if !defined(CANT_DELETE_OPEN_FILES)
 
35
  /* The following should always succeed */
 
36
  (void) my_delete(name,MYF(MY_WME | ME_NOINPUT));
 
37
#else
 
38
  int length;
 
39
  if (!(cache->file_name=
 
40
        (char*) my_malloc((length=strlen(name)+1),MYF(MY_WME))))
 
41
  {
 
42
    my_close(cache->file,MYF(0));
 
43
    cache->file = -1;
 
44
    errno=my_errno=ENOMEM;
 
45
    return 1;
 
46
  }
 
47
  memcpy(cache->file_name,name,length);
 
48
#endif
 
49
#endif /* O_TEMPORARY == 0 */
 
50
  return 0;
 
51
}
24
52
 
25
53
        /*
26
54
        ** Open tempfile cached by IO_CACHE
55
83
  char name_buff[FN_REFLEN];
56
84
  int error=1;
57
85
  if ((cache->file=create_temp_file(name_buff, cache->dir, cache->prefix,
58
 
                                    (O_RDWR | O_TRUNC),
 
86
                                    (O_RDWR | O_BINARY | O_TRUNC |
 
87
                                     O_TEMPORARY | O_SHORT_LIVED),
59
88
                                    MYF(MY_WME))) >= 0)
60
89
  {
61
90
    error=0;
62
 
    my_delete(name_buff,MYF(MY_WME | ME_NOINPUT));
 
91
    cache_remove_open_tmp(cache, name_buff);
63
92
  }
64
93
  return(error);
65
94
}