summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorunknown <serg@serg.mylan>2006-05-31 18:49:12 +0200
committerunknown <serg@serg.mylan>2006-05-31 18:49:12 +0200
commit5abb9f0cc9c8678cdd895d9964e030444c7c4298 (patch)
tree9fc61d048fbdc1b179ae930a24dc9f2e2fc1e807 /include
parent0de72ae91f3101ca4e41d3f9e0a960a3babbb56e (diff)
parent8b4581778036c95072438630884ad810b512815a (diff)
downloadmariadb-git-5abb9f0cc9c8678cdd895d9964e030444c7c4298.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-5.1-new
into serg.mylan:/usr/home/serg/Abk/mysql-5.1 include/mysql/plugin.h: Auto merged sql/log_event.h: Auto merged sql/sql_plugin.cc: Auto merged
Diffstat (limited to 'include')
-rw-r--r--include/atomic/nolock.h169
-rw-r--r--include/atomic/rwlock.h161
-rw-r--r--include/atomic/x86-gcc.h56
-rw-r--r--include/atomic/x86-msvc.h85
-rw-r--r--include/my_atomic.h46
-rw-r--r--include/my_global.h13
-rw-r--r--include/mysql/plugin.h47
7 files changed, 562 insertions, 15 deletions
diff --git a/include/atomic/nolock.h b/include/atomic/nolock.h
new file mode 100644
index 00000000000..cf21a94c7de
--- /dev/null
+++ b/include/atomic/nolock.h
@@ -0,0 +1,169 @@
+/* Copyright (C) 2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#if defined(__i386__) || defined(_M_IX86)
+#ifdef MY_ATOMIC_MODE_DUMMY
+# define LOCK ""
+#else
+# define LOCK "lock "
+#endif
+#ifdef __GNUC__
+#include "x86-gcc.h"
+#elif defined(_MSC_VER)
+#include "x86-msvc.h"
+#endif
+#endif
+
+#ifdef make_atomic_add_body8
+
+#ifdef HAVE_INLINE
+
+#define make_atomic_add(S) \
+static inline uint ## S _my_atomic_add ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v) \
+{ \
+ make_atomic_add_body ## S; \
+ return v; \
+}
+
+#define make_atomic_swap(S) \
+static inline uint ## S _my_atomic_swap ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v) \
+{ \
+ make_atomic_swap_body ## S; \
+ return v; \
+}
+
+#define make_atomic_cas(S) \
+static inline uint _my_atomic_cas ## S(my_atomic_ ## S ## _t *a,\
+ uint ## S *cmp, uint ## S set) \
+{ \
+ uint8 ret; \
+ make_atomic_cas_body ## S; \
+ return ret; \
+}
+
+#define make_atomic_load(S) \
+static inline uint ## S _my_atomic_load ## S( \
+ my_atomic_ ## S ## _t *a) \
+{ \
+ uint ## S ret; \
+ make_atomic_load_body ## S; \
+ return ret; \
+}
+
+#define make_atomic_store(S) \
+static inline void _my_atomic_store ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v) \
+{ \
+ make_atomic_store_body ## S; \
+}
+
+#else /* no inline functions */
+
+#define make_atomic_add(S) \
+extern uint ## S _my_atomic_add ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v);
+
+#define make_atomic_swap(S) \
+extern uint ## S _my_atomic_swap ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v);
+
+#define make_atomic_cas(S) \
+extern uint _my_atomic_cas ## S(my_atomic_ ## S ## _t *a, \
+ uint ## S *cmp, uint ## S set);
+
+#define make_atomic_load(S) \
+extern uint ## S _my_atomic_load ## S( \
+ my_atomic_ ## S ## _t *a);
+
+#define make_atomic_store(S) \
+extern void _my_atomic_store ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v);
+
+#endif
+
+make_atomic_add( 8)
+make_atomic_add(16)
+make_atomic_add(32)
+
+make_atomic_cas( 8)
+make_atomic_cas(16)
+make_atomic_cas(32)
+
+make_atomic_load( 8)
+make_atomic_load(16)
+make_atomic_load(32)
+
+make_atomic_store( 8)
+make_atomic_store(16)
+make_atomic_store(32)
+
+make_atomic_swap( 8)
+make_atomic_swap(16)
+make_atomic_swap(32)
+
+#undef make_atomic_add_body8
+#undef make_atomic_cas_body8
+#undef make_atomic_load_body8
+#undef make_atomic_store_body8
+#undef make_atomic_swap_body8
+#undef make_atomic_add_body16
+#undef make_atomic_cas_body16
+#undef make_atomic_load_body16
+#undef make_atomic_store_body16
+#undef make_atomic_swap_body16
+#undef make_atomic_add_body32
+#undef make_atomic_cas_body32
+#undef make_atomic_load_body32
+#undef make_atomic_store_body32
+#undef make_atomic_swap_body32
+#undef make_atomic_add
+#undef make_atomic_cas
+#undef make_atomic_load
+#undef make_atomic_store
+#undef make_atomic_swap
+
+#define my_atomic_add8(a,v,L) _my_atomic_add8(a,v)
+#define my_atomic_add16(a,v,L) _my_atomic_add16(a,v)
+#define my_atomic_add32(a,v,L) _my_atomic_add32(a,v)
+
+#define my_atomic_cas8(a,c,v,L) _my_atomic_cas8(a,c,v)
+#define my_atomic_cas16(a,c,v,L) _my_atomic_cas16(a,c,v)
+#define my_atomic_cas32(a,c,v,L) _my_atomic_cas32(a,c,v)
+
+#define my_atomic_load8(a,L) _my_atomic_load8(a)
+#define my_atomic_load16(a,L) _my_atomic_load16(a)
+#define my_atomic_load32(a,L) _my_atomic_load32(a)
+
+#define my_atomic_store8(a,v,L) _my_atomic_store8(a,v)
+#define my_atomic_store16(a,v,L) _my_atomic_store16(a,v)
+#define my_atomic_store32(a,v,L) _my_atomic_store32(a,v)
+
+#define my_atomic_swap8(a,v,L) _my_atomic_swap8(a,v)
+#define my_atomic_swap16(a,v,L) _my_atomic_swap16(a,v)
+#define my_atomic_swap32(a,v,L) _my_atomic_swap32(a,v)
+
+#define my_atomic_rwlock_t typedef int
+#define my_atomic_rwlock_destroy(name)
+#define my_atomic_rwlock_init(name)
+#define my_atomic_rwlock_rdlock(name)
+#define my_atomic_rwlock_wrlock(name)
+#define my_atomic_rwlock_rdunlock(name)
+#define my_atomic_rwlock_wrunlock(name)
+
+#endif
+
diff --git a/include/atomic/rwlock.h b/include/atomic/rwlock.h
new file mode 100644
index 00000000000..ca5be29ab9b
--- /dev/null
+++ b/include/atomic/rwlock.h
@@ -0,0 +1,161 @@
+/* Copyright (C) 2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+typedef struct {pthread_rwlock_t rw;} my_atomic_rwlock_t;
+
+#ifdef MY_ATOMIC_EXTRA_DEBUG
+#define CHECK_RW if (rw) if (a->rw) assert(rw == a->rw); else a->rw=rw;
+#else
+#define CHECK_RW
+#endif
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+/*
+ the following can never be enabled by ./configure, one need to put #define in
+ a source to trigger the following warning. The resulting code will be broken,
+ it only makes sense to do it to see now test_atomic detects broken
+ implementations (another way is to run a UP build on an SMP box).
+*/
+#warning MY_ATOMIC_MODE_DUMMY and MY_ATOMIC_MODE_RWLOCKS are incompatible
+#define my_atomic_rwlock_destroy(name)
+#define my_atomic_rwlock_init(name)
+#define my_atomic_rwlock_rdlock(name)
+#define my_atomic_rwlock_wrlock(name)
+#define my_atomic_rwlock_rdunlock(name)
+#define my_atomic_rwlock_wrunlock(name)
+#else
+#define my_atomic_rwlock_destroy(name) pthread_rwlock_destroy(& (name)->rw)
+#define my_atomic_rwlock_init(name) pthread_rwlock_init(& (name)->rw, 0)
+#define my_atomic_rwlock_rdlock(name) pthread_rwlock_rdlock(& (name)->rw)
+#define my_atomic_rwlock_wrlock(name) pthread_rwlock_wrlock(& (name)->rw)
+#define my_atomic_rwlock_rdunlock(name) pthread_rwlock_unlock(& (name)->rw)
+#define my_atomic_rwlock_wrunlock(name) pthread_rwlock_unlock(& (name)->rw)
+#endif
+
+#ifdef HAVE_INLINE
+
+#define make_atomic_add(S) \
+static inline uint ## S my_atomic_add ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw) \
+{ \
+ uint ## S ret; \
+ CHECK_RW; \
+ if (rw) my_atomic_rwlock_wrlock(rw); \
+ ret= a->val; \
+ a->val+= v; \
+ if (rw) my_atomic_rwlock_wrunlock(rw); \
+ return ret; \
+}
+
+#define make_atomic_swap(S) \
+static inline uint ## S my_atomic_swap ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw) \
+{ \
+ uint ## S ret; \
+ CHECK_RW; \
+ if (rw) my_atomic_rwlock_wrlock(rw); \
+ ret= a->val; \
+ a->val= v; \
+ if (rw) my_atomic_rwlock_wrunlock(rw); \
+ return ret; \
+}
+
+#define make_atomic_cas(S) \
+static inline uint my_atomic_cas ## S(my_atomic_ ## S ## _t *a, \
+ uint ## S *cmp, uint ## S set, my_atomic_rwlock_t *rw) \
+{ \
+ uint ret; \
+ CHECK_RW; \
+ if (rw) my_atomic_rwlock_wrlock(rw); \
+ if (ret= (a->val == *cmp)) a->val= set; else *cmp=a->val; \
+ if (rw) my_atomic_rwlock_wrunlock(rw); \
+ return ret; \
+}
+
+#define make_atomic_load(S) \
+static inline uint ## S my_atomic_load ## S( \
+ my_atomic_ ## S ## _t *a, my_atomic_rwlock_t *rw) \
+{ \
+ uint ## S ret; \
+ CHECK_RW; \
+ if (rw) my_atomic_rwlock_wrlock(rw); \
+ ret= a->val; \
+ if (rw) my_atomic_rwlock_wrunlock(rw); \
+ return ret; \
+}
+
+#define make_atomic_store(S) \
+static inline void my_atomic_store ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw) \
+{ \
+ CHECK_RW; \
+ if (rw) my_atomic_rwlock_rdlock(rw); \
+ (a)->val= (v); \
+ if (rw) my_atomic_rwlock_rdunlock(rw); \
+}
+
+#else /* no inline functions */
+
+#define make_atomic_add(S) \
+extern uint ## S my_atomic_add ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw);
+
+#define make_atomic_swap(S) \
+extern uint ## S my_atomic_swap ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw);
+
+#define make_atomic_cas(S) \
+extern uint my_atomic_cas ## S(my_atomic_ ## S ## _t *a, \
+ uint ## S *cmp, uint ## S set, my_atomic_rwlock_t *rw);
+
+#define make_atomic_load(S) \
+extern uint ## S my_atomic_load ## S( \
+ my_atomic_ ## S ## _t *a, my_atomic_rwlock_t *rw);
+
+#define make_atomic_store(S) \
+extern void my_atomic_store ## S( \
+ my_atomic_ ## S ## _t *a, uint ## S v, my_atomic_rwlock_t *rw);
+
+#endif
+
+make_atomic_add( 8)
+make_atomic_add(16)
+make_atomic_add(32)
+make_atomic_add(64)
+make_atomic_cas( 8)
+make_atomic_cas(16)
+make_atomic_cas(32)
+make_atomic_cas(64)
+make_atomic_load( 8)
+make_atomic_load(16)
+make_atomic_load(32)
+make_atomic_load(64)
+make_atomic_store( 8)
+make_atomic_store(16)
+make_atomic_store(32)
+make_atomic_store(64)
+make_atomic_swap( 8)
+make_atomic_swap(16)
+make_atomic_swap(32)
+make_atomic_swap(64)
+#undef make_atomic_add
+#undef make_atomic_cas
+#undef make_atomic_load
+#undef make_atomic_store
+#undef make_atomic_swap
+#undef CHECK_RW
+
+
diff --git a/include/atomic/x86-gcc.h b/include/atomic/x86-gcc.h
new file mode 100644
index 00000000000..b06d80d37e5
--- /dev/null
+++ b/include/atomic/x86-gcc.h
@@ -0,0 +1,56 @@
+/* Copyright (C) 2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ XXX 64-bit atomic operations can be implemented using
+ cmpxchg8b, if necessary
+*/
+
+#define make_atomic_add_body8 \
+ asm volatile (LOCK "xadd %0, %1;" : "+r" (v) , "+m" (a->val))
+#define make_atomic_swap_body8 \
+ asm volatile ("xchg %0, %1;" : "+r" (v) , "+m" (a->val))
+#define make_atomic_cas_body8 \
+ asm volatile (LOCK "cmpxchg %3, %0; setz %2;" \
+ : "+m" (a->val), "+a" (*cmp), "=q" (ret): "r" (set))
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+#define make_atomic_load_body8 ret=a->val
+#define make_atomic_store_body8 a->val=v
+#else
+/*
+ Actually 32-bit reads/writes are always atomic on x86
+ But we add LOCK here anyway to force memory barriers
+*/
+#define make_atomic_load_body8 \
+ ret=0; \
+ asm volatile (LOCK "cmpxchg %2, %0" \
+ : "+m" (a->val), "+a" (ret): "r" (ret))
+#define make_atomic_store_body8 \
+ asm volatile ("xchg %0, %1;" : "+m" (a->val) : "r" (v))
+#endif
+
+#define make_atomic_add_body16 make_atomic_add_body8
+#define make_atomic_add_body32 make_atomic_add_body8
+#define make_atomic_cas_body16 make_atomic_cas_body8
+#define make_atomic_cas_body32 make_atomic_cas_body8
+#define make_atomic_load_body16 make_atomic_load_body8
+#define make_atomic_load_body32 make_atomic_load_body8
+#define make_atomic_store_body16 make_atomic_store_body8
+#define make_atomic_store_body32 make_atomic_store_body8
+#define make_atomic_swap_body16 make_atomic_swap_body8
+#define make_atomic_swap_body32 make_atomic_swap_body8
+
diff --git a/include/atomic/x86-msvc.h b/include/atomic/x86-msvc.h
new file mode 100644
index 00000000000..19645551196
--- /dev/null
+++ b/include/atomic/x86-msvc.h
@@ -0,0 +1,85 @@
+/* Copyright (C) 2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+/*
+ XXX 64-bit atomic operations can be implemented using
+ cmpxchg8b, if necessary
+*/
+
+// Would it be better to use intrinsics ?
+// (InterlockedCompareExchange, InterlockedCompareExchange16
+// InterlockedExchangeAdd, InterlockedExchange)
+
+#define make_atomic_add_body(REG) \
+ _asm { \
+ _asm mov REG, v \
+ _asm LOCK xadd a->val, REG \
+ _asm movzx v, REG \
+ }
+#define make_atomic_cas_body(AREG,REG2) \
+ _asm { \
+ _asm mov AREG, *cmp \
+ _asm mov REG2, set \
+ _asm LOCK cmpxchg a->val, REG2 \
+ _asm mov *cmp, AREG \
+ _asm setz al \
+ _asm movzx ret, al \
+ }
+#define make_atomic_swap_body(REG) \
+ _asm { \
+ _asm mov REG, v \
+ _asm xchg a->val, REG \
+ _asm mov v, REG \
+ }
+
+#ifdef MY_ATOMIC_MODE_DUMMY
+#define make_atomic_load_body(AREG,REG) ret=a->val
+#define make_atomic_store_body(REG) a->val=v
+#else
+/*
+ Actually 32-bit reads/writes are always atomic on x86
+ But we add LOCK here anyway to force memory barriers
+*/
+#define make_atomic_load_body(AREG,REG2) \
+ _asm { \
+ _asm mov AREG, 0 \
+ _asm mov REG2, AREG \
+ _asm LOCK cmpxchg a->val, REG2 \
+ _asm mov ret, AREG \
+ }
+#define make_atomic_store_body(REG) \
+ _asm { \
+ _asm mov REG, v \
+ _asm xchg a->val, REG \
+ }
+#endif
+
+#define make_atomic_add_body8 make_atomic_add_body(al)
+#define make_atomic_add_body16 make_atomic_add_body(ax)
+#define make_atomic_add_body32 make_atomic_add_body(eax)
+#define make_atomic_cas_body8 make_atomic_cas_body(al, bl)
+#define make_atomic_cas_body16 make_atomic_cas_body(ax, bx)
+#define make_atomic_cas_body32 make_atomic_cas_body(eax, ebx)
+#define make_atomic_load_body8 make_atomic_load_body(al, bl)
+#define make_atomic_load_body16 make_atomic_load_body(ax, bx)
+#define make_atomic_load_body32 make_atomic_load_body(eax, ebx)
+#define make_atomic_store_body8 make_atomic_store_body(al)
+#define make_atomic_store_body16 make_atomic_store_body(ax)
+#define make_atomic_store_body32 make_atomic_store_body(eax)
+#define make_atomic_swap_body8 make_atomic_swap_body(al)
+#define make_atomic_swap_body16 make_atomic_swap_body(ax)
+#define make_atomic_swap_body32 make_atomic_swap_body(eax)
+
diff --git a/include/my_atomic.h b/include/my_atomic.h
new file mode 100644
index 00000000000..091edc0f57b
--- /dev/null
+++ b/include/my_atomic.h
@@ -0,0 +1,46 @@
+/* Copyright (C) 2006 MySQL AB
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+
+#ifndef atomic_rwlock_init
+
+#ifdef MY_ATOMIC_EXTRA_DEBUG
+#ifndef MY_ATOMIC_MODE_RWLOCKS
+#error MY_ATOMIC_EXTRA_DEBUG can be only used with MY_ATOMIC_MODE_RWLOCKS
+#endif
+#define LOCK_PTR void *rw;
+#else
+#define LOCK_PTR
+#endif
+
+typedef volatile struct {uint8 val; LOCK_PTR} my_atomic_8_t;
+typedef volatile struct {uint16 val; LOCK_PTR} my_atomic_16_t;
+typedef volatile struct {uint32 val; LOCK_PTR} my_atomic_32_t;
+typedef volatile struct {uint64 val; LOCK_PTR} my_atomic_64_t;
+
+#ifndef MY_ATOMIC_MODE_RWLOCKS
+#include "atomic/nolock.h"
+#endif
+
+#ifndef my_atomic_rwlock_init
+#include "atomic/rwlock.h"
+#endif
+
+#define MY_ATOMIC_OK 0
+#define MY_ATOMIC_NOT_1CPU 1
+extern int my_atomic_initialize();
+
+#endif
+
diff --git a/include/my_global.h b/include/my_global.h
index 100e695a0de..81fa5225c3b 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -181,6 +181,17 @@
#define HOT_DATA
#endif
+/*
+ now let's figure out if inline functions are supported
+ autoconf defines 'inline' to be empty, if not
+*/
+#define inline_test_1(X) X ## 1
+#define inline_test_2(X) inline_test_1(X)
+#if inline_test_2(inline) != 1
+#define HAVE_INLINE
+#endif
+#undef inline_test_2
+#undef inline_test_1
/*
The following macros are used to control inlining a bit more than
@@ -889,6 +900,8 @@ typedef unsigned long ulonglong; /* ulong or unsigned long long */
typedef long longlong;
#endif
#endif
+typedef longlong int64;
+typedef ulonglong uint64;
#if defined(NO_CLIENT_LONG_LONG)
typedef unsigned long my_ulonglong;
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index 926b7e34c5b..0cee54bffde 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -98,9 +98,11 @@ struct st_mysql_plugin
API for Full-text parser plugin. (MYSQL_FTPARSER_PLUGIN)
*/
-#define MYSQL_FTPARSER_INTERFACE_VERSION 0x0000
+#define MYSQL_FTPARSER_INTERFACE_VERSION 0x0100
/* Parsing modes. Set in MYSQL_FTPARSER_PARAM::mode */
+enum enum_ftparser_mode
+{
/*
Fast and simple mode. This mode is used for indexing, and natural
language queries.
@@ -109,7 +111,7 @@ struct st_mysql_plugin
index. Stopwords or too short/long words should not be returned. The
'boolean_info' argument of mysql_add_word() does not have to be set.
*/
-#define MYSQL_FTPARSER_SIMPLE_MODE 0
+ MYSQL_FTPARSER_SIMPLE_MODE= 0,
/*
Parse with stopwords mode. This mode is used in boolean searches for
@@ -120,7 +122,7 @@ struct st_mysql_plugin
or long. The 'boolean_info' argument of mysql_add_word() does not
have to be set.
*/
-#define MYSQL_FTPARSER_WITH_STOPWORDS 1
+ MYSQL_FTPARSER_WITH_STOPWORDS= 1,
/*
Parse in boolean mode. This mode is used to parse a boolean query string.
@@ -133,7 +135,8 @@ struct st_mysql_plugin
MYSQL_FTPARSER_WITH_STOPWORDS mode, no word should be ignored.
Instead, use FT_TOKEN_STOPWORD for the token type of such a word.
*/
-#define MYSQL_FTPARSER_FULL_BOOLEAN_INFO 2
+ MYSQL_FTPARSER_FULL_BOOLEAN_INFO= 2
+};
/*
Token types for boolean mode searching (used for the type member of
@@ -198,6 +201,17 @@ typedef struct st_mysql_ftparser_boolean_info
char *quot;
} MYSQL_FTPARSER_BOOLEAN_INFO;
+/*
+ The following flag means that buffer with a string (document, word)
+ may be overwritten by the caller before the end of the parsing (that is
+ before st_mysql_ftparser::deinit() call). If one needs the string
+ to survive between two successive calls of the parsing function, she
+ needs to save a copy of it. The flag may be set by MySQL before calling
+ st_mysql_ftparser::parse(), or it may be set by a plugin before calling
+ st_mysql_ftparser_param::mysql_parse() or
+ st_mysql_ftparser_param::mysql_add_word().
+*/
+#define MYSQL_FTFLAGS_NEED_COPY 1
/*
An argument of the full-text parser plugin. This structure is
@@ -209,22 +223,20 @@ typedef struct st_mysql_ftparser_boolean_info
to invoke the MySQL default parser. If plugin's role is to extract
textual data from .doc, .pdf or .xml content, it might extract
plaintext from the content, and then pass the text to the default
- MySQL parser to be parsed. When mysql_parser is called, its param
- argument should be given as the mysql_ftparam value.
+ MySQL parser to be parsed.
mysql_add_word: A server callback to add a new word. When parsing
a document, the server sets this to point at a function that adds
the word to MySQL full-text index. When parsing a search query,
this function will add the new word to the list of words to search
- for. When mysql_add_word is called, its param argument should be
- given as the mysql_ftparam value. boolean_info can be NULL for all
- cases except when mode is MYSQL_FTPARSER_FULL_BOOLEAN_INFO.
+ for. The boolean_info argument can be NULL for all cases except
+ when mode is MYSQL_FTPARSER_FULL_BOOLEAN_INFO.
ftparser_state: A generic pointer. The plugin can set it to point
to information to be used internally for its own purposes.
- mysql_ftparam: This is set by the server. It is passed as the first
- argument to the mysql_parse or mysql_add_word callback. The plugin
+ mysql_ftparam: This is set by the server. It is used by MySQL functions
+ called via mysql_parse() and mysql_add_word() callback. The plugin
should not modify it.
cs: Information about the character set of the document or query string.
@@ -233,21 +245,26 @@ typedef struct st_mysql_ftparser_boolean_info
length: Length of the document or query string, in bytes.
+ flags: See MYSQL_FTFLAGS_* constants above.
+
mode: The parsing mode. With boolean operators, with stopwords, or
- nothing. See MYSQL_FTPARSER_* constants above.
+ nothing. See enum_ftparser_mode above.
*/
typedef struct st_mysql_ftparser_param
{
- int (*mysql_parse)(void *param, char *doc, int doc_len);
- int (*mysql_add_word)(void *param, char *word, int word_len,
+ int (*mysql_parse)(struct st_mysql_ftparser_param *,
+ char *doc, int doc_len);
+ int (*mysql_add_word)(struct st_mysql_ftparser_param *,
+ char *word, int word_len,
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info);
void *ftparser_state;
void *mysql_ftparam;
struct charset_info_st *cs;
char *doc;
int length;
- int mode;
+ int flags;
+ enum enum_ftparser_mode mode;
} MYSQL_FTPARSER_PARAM;
/*