drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
wiredtiger_checkpoint_function.cc
1
2#include <config.h>
3#include <drizzled/plugin/function.h>
4#include <drizzled/item/func.h>
5#include <drizzled/charset.h>
6#include <drizzled/function/str/strfunc.h>
7
8#include <stdint.h>
9#include <string>
10
11#include <wiredtiger.h>
12#include "wiredtiger_checkpoint_function.h"
13#include "wiredtiger_drizzle.h"
14
15using namespace std;
16using namespace drizzled;
17
18extern WiredTigerEngine *wiredtiger_storage_engine;
19
20class WiredTigerCheckpointFunction : public Item_str_func
21{
22public:
23 WiredTigerCheckpointFunction() : Item_str_func() {}
25
26 void fix_length_and_dec()
27 {
28 max_length= 128; /* a decent guess at least... */
29 }
30
31 const char *func_name() const
32 {
33 return "wiredtiger_checkpoint";
34 }
35
37 {
38 return (n == 1);
39 }
40};
41
43{
44 assert(fixed);
45
46 String *arg= args[0]->val_str(str);
47 if (arg == NULL)
48 {
49 null_value= true;
50 return NULL;
51 }
52
53 null_value= false;
54
55 int r;
56 string checkpoint_arg(arg->ptr(), arg->length());
57
58 /* FIXME: likely either check some validity (or have sep funcs for each) */
59 r= wiredtiger_storage_engine->checkpoint(checkpoint_arg);
60
61 const char* result= wiredtiger_strerror(r);
62 size_t result_len= strlen(result);
63
64 str->alloc(result_len);
65 str->set_charset(&my_charset_bin);
66 null_value= false;
67 str->length(result_len);
68
69 memcpy(str->ptr(), result, result_len);
70
71 return str;
72}
73
74void init_wiredtiger_checkpoint_function(drizzled::module::Context &context)
75{
76 context.add(new plugin::Create_function<WiredTigerCheckpointFunction>("wiredtiger_checkpoint"));
77}
bool fixed
Definition item.h:122
bool null_value
Definition item.h:124
TODO: Rename this file - func.h is stupid.
STL namespace.