~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_cache.cc

  • Committer: Stewart Smith
  • Date: 2008-11-21 16:06:07 UTC
  • mto: This revision was merged to the branch mainline in revision 593.
  • Revision ID: stewart@flamingspork.com-20081121160607-n6gdlt013spuo54r
remove mysql_frm_type
and fix engines to return correct value from delete_table when table doesn't exist.
(it should be ENOENT).

Also fix up some tests that manipulated frm files by hand. These tests are no longer valid and will need to be rewritten in the not too distant future.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/* Open a temporary file and cache it with io_cache. Delete it on close */
17
17
 
18
 
#include "config.h"
19
 
 
20
 
#include "drizzled/internal/my_sys.h"
21
 
#include "drizzled/internal/m_string.h"
22
 
#include "drizzled/internal/my_static.h"
23
 
#include "drizzled/internal/iocache.h"
24
 
#include "drizzled/error.h"
25
 
 
26
 
namespace drizzled
27
 
{
28
 
namespace internal
29
 
{
 
18
#include "mysys_priv.h"
 
19
#include <mystrings/m_string.h>
 
20
#include <mysys/my_static.h>
 
21
#include <mysys/mysys_err.h>
 
22
#include <mysys/iocache.h>
 
23
 
30
24
 
31
25
        /*
32
26
        ** Open tempfile cached by IO_CACHE
33
27
        ** Should be used when no seeks are done (only reinit_io_buff)
34
 
        ** Return false if cache is inited ok
 
28
        ** Return 0 if cache is inited ok
35
29
        ** The actual file is created when the IO_CACHE buffer gets filled
36
30
        ** If dir is not given, use TMPDIR.
37
31
        */
39
33
bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix,
40
34
                         size_t cache_size, myf cache_myflags)
41
35
{
42
 
  cache->dir=    dir ? strdup(dir) : (char*) 0;
43
 
  cache->prefix= (prefix ? strdup(prefix) :
 
36
  cache->dir=    dir ? my_strdup(dir,MYF(cache_myflags & MY_WME)) : (char*) 0;
 
37
  cache->prefix= (prefix ? my_strdup(prefix,MYF(cache_myflags & MY_WME)) :
44
38
                 (char*) 0);
45
 
  if ((cache->dir == NULL) || (cache->prefix == NULL))
46
 
    return true;
47
39
  cache->file_name=0;
48
40
  cache->buffer=0;                              /* Mark that not open */
49
41
  if (!init_io_cache(cache,-1,cache_size,WRITE_CACHE,0L,0,
50
42
                     MYF(cache_myflags | MY_NABP)))
51
43
  {
52
 
    return false;
 
44
    return(0);
53
45
  }
54
46
  free(cache->dir);
55
47
  free(cache->prefix);
56
 
  return true;
 
48
  return(1);
57
49
}
58
50
 
59
51
        /* Create the temporary file */
62
54
{
63
55
  char name_buff[FN_REFLEN];
64
56
  int error=1;
65
 
  if ((cache->file=create_temp_file(name_buff, cache->dir, cache->prefix, MYF(MY_WME))) >= 0)
 
57
  if ((cache->file=create_temp_file(name_buff, cache->dir, cache->prefix,
 
58
                                    (O_RDWR | O_TRUNC),
 
59
                                    MYF(MY_WME))) >= 0)
66
60
  {
67
61
    error=0;
68
62
    my_delete(name_buff,MYF(MY_WME | ME_NOINPUT));
75
69
{
76
70
  if (my_b_inited(cache))
77
71
  {
78
 
    int file=cache->file;
 
72
    File file=cache->file;
79
73
    cache->file= -1;                            /* Don't flush data */
80
74
    (void) end_io_cache(cache);
81
75
    if (file >= 0)
94
88
  }
95
89
  return;
96
90
}
97
 
 
98
 
} /* namespace internal */
99
 
} /* namespace drizzled */