Commit 2b319e27 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

addresses #1032

re-port latest handlerton

git-svn-id: file:///svn/mysql/tokudb-engine/src@7732 c7de825b-a66e-492c-adef-691d508d4ae1
parent 42d3404b
...@@ -4,19 +4,24 @@ ...@@ -4,19 +4,24 @@
#define MYSQL_SERVER 1 #define MYSQL_SERVER 1
#include "mysql_priv.h" #include "mysql_priv.h"
extern "C" {
#include "stdint.h"
#include "os.h"
#include "misc.h"
}
#if !defined(HA_END_SPACE_KEY) || HA_END_SPACE_KEY != 0 #if !defined(HA_END_SPACE_KEY) || HA_END_SPACE_KEY != 0
#error #error
#endif #endif
unsigned long my_getphyspages() { unsigned long my_getphyspages() {
return sysconf(_SC_PHYS_PAGES); return (unsigned long)os_get_phys_memory_size();
} }
#include <syscall.h> //#include <syscall.h>
unsigned int my_tid() { unsigned int my_tid() {
return syscall(__NR_gettid); return (unsigned int)os_gettid();
} }
static inline void *thd_data_get(THD *thd, int slot) { static inline void *thd_data_get(THD *thd, int slot) {
...@@ -1269,7 +1274,7 @@ inline HA_TOKU_ISO_LEVEL tx_to_toku_iso(ulong tx_isolation) { ...@@ -1269,7 +1274,7 @@ inline HA_TOKU_ISO_LEVEL tx_to_toku_iso(ulong tx_isolation) {
inline u_int32_t toku_iso_to_txn_flag (HA_TOKU_ISO_LEVEL lvl) { inline u_int32_t toku_iso_to_txn_flag (HA_TOKU_ISO_LEVEL lvl) {
if (lvl == hatoku_iso_read_uncommitted) { if (lvl == hatoku_iso_read_uncommitted) {
return DB_READ_UNCOMMITTED; return 0;//DB_READ_UNCOMMITTED;
} }
else { else {
return 0; return 0;
...@@ -4266,33 +4271,43 @@ static int create_sub_table(const char *table_name, const char *sub_name, DBTYPE ...@@ -4266,33 +4271,43 @@ static int create_sub_table(const char *table_name, const char *sub_name, DBTYPE
TOKUDB_DBUG_RETURN(error); TOKUDB_DBUG_RETURN(error);
} }
static int mkdirpath(char *name, mode_t mode) { static int mkdirpath(char *name, mode_t mode) {
int r = mkdir(name, mode); char* parent = NULL;
if (r == -1 && errno == ENOENT) { int r = os_mkdir(name, mode);
char parent[strlen(name)+1]; if (r == -1 && errno == ENOENT) {
strcpy(parent, name); parent = (char *)my_malloc(strlen(name)+1,MYF(MY_WME));
char *cp = strrchr(parent, '/'); if (parent == NULL) {
if (cp) { r = ENOMEM;
*cp = 0; goto cleanup;
r = mkdir(parent, 0755); }
if (r == 0) strcpy(parent, name);
r = mkdir(name, mode); char *cp = strrchr(parent, '/');
} if (cp) {
} *cp = 0;
return r; r = os_mkdir(parent, 0755);
} if (r == 0)
r = os_mkdir(name, mode);
}
}
cleanup:
my_free(parent, MYF(MY_ALLOW_ZERO_PTR));
return r;
}
extern "C" {
#include <dirent.h> #include <dirent.h>
}
static int rmall(const char *dname) { static int rmall(const char *dname) {
int error = 0; int error = 0;
DIR *d = opendir(dname); DIR *d = opendir(dname);
char* fname = NULL;
if (d) { if (d) {
struct dirent *dirent; struct dirent *dirent;
while ((dirent = readdir(d)) != 0) { while ((dirent = readdir(d)) != 0) {
if (0 == strcmp(dirent->d_name, ".") || 0 == strcmp(dirent->d_name, "..")) if (0 == strcmp(dirent->d_name, ".") || 0 == strcmp(dirent->d_name, ".."))
continue; continue;
char fname[strlen(dname) + 1 + strlen(dirent->d_name) + 1]; fname = (char *)my_malloc(strlen(dname) + 1 + strlen(dirent->d_name) + 1, MYF(MY_WME));
sprintf(fname, "%s/%s", dname, dirent->d_name); sprintf(fname, "%s/%s", dname, dirent->d_name);
if (dirent->d_type == DT_DIR) { if (dirent->d_type == DT_DIR) {
error = rmall(fname); error = rmall(fname);
...@@ -4333,6 +4348,8 @@ static int rmall(const char *dname) { ...@@ -4333,6 +4348,8 @@ static int rmall(const char *dname) {
break; break;
} }
} }
my_free(fname, MYF(MY_ALLOW_ZERO_PTR));
fname = NULL;
} }
} }
closedir(d); closedir(d);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment