~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/strfunc.cc

This patch completes the first step in the splitting of
the XA resource manager API from the storage engine API,
as outlined in the specification here:

http://drizzle.org/wiki/XaStorageEngine

* Splits plugin::StorageEngine into a base StorageEngine
  class and two derived classes, TransactionalStorageEngine
  and XaStorageEngine.  XaStorageEngine derives from
  TransactionalStorageEngine and creates the XA Resource
  Manager API for storage engines.

  - The methods moved from StorageEngine to TransactionalStorageEngine
    include releaseTemporaryLatches(), startConsistentSnapshot(), 
    commit(), rollback(), setSavepoint(), releaseSavepoint(),
    rollbackToSavepoint() and hasTwoPhaseCommit()
  - The methods moved from StorageEngine to XaStorageEngine
    include recover(), commitXid(), rollbackXid(), and prepare()

* Places all static "EngineVector"s into their proper
  namespaces (typedefs belong in header files, not implementation files)
  and places all static methods corresponding
  to either only transactional engines or only XA engines
  into their respective files in /drizzled/plugin/

* Modifies the InnoDB "handler" files to extend plugin::XaStorageEngine
  and not plugin::StorageEngine

The next step, as outlined in the wiki spec page above, is to isolate
the XA Resource Manager API into its own plugin class and modify
plugin::XaStorageEngine to implement plugin::XaResourceManager via
composition.  This is necessary to enable building plugins which can
participate in an XA transaction *without having to have that plugin
implement the entire storage engine API*

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/* Some useful string utility functions used by the MySQL server */
17
 
#include <config.h>
 
17
#include "config.h"
18
18
 
19
 
#include <drizzled/strfunc.h>
20
 
#include <drizzled/typelib.h>
21
 
#include <drizzled/charset_info.h>
22
 
#include <drizzled/global_charset_info.h>
 
19
#include "drizzled/strfunc.h"
 
20
#include "drizzled/typelib.h"
 
21
#include "drizzled/charset_info.h"
 
22
#include "drizzled/global_charset_info.h"
23
23
 
24
24
namespace drizzled
25
25
{
45
45
 
46
46
static const char field_separator=',';
47
47
 
48
 
uint64_t st_typelib::find_set(const char *str, uint32_t length,
 
48
uint64_t find_set(TYPELIB *lib, const char *str, uint32_t length,
49
49
                  const CHARSET_INFO * const cs,
50
 
                  char **err_pos, uint32_t *err_len, bool *set_warning) const
 
50
                  char **err_pos, uint32_t *err_len, bool *set_warning)
51
51
{
52
52
  const CHARSET_INFO * const strip= cs ? cs : &my_charset_utf8_general_ci;
53
53
  const char *end= str + strip->cset->lengthsp(strip, str, length);
65
65
      for (; pos != end && *pos != field_separator; pos++) 
66
66
      {}
67
67
      var_len= (uint32_t) (pos - start);
68
 
      uint32_t find= cs ? find_type2(start, var_len, cs) : find_type(start, var_len, false);
 
68
      uint32_t find= cs ? find_type2(lib, start, var_len, cs) :
 
69
                      find_type(lib, start, var_len, (bool) 0);
69
70
      if (!find)
70
71
      {
71
72
        *err_pos= (char*) start;
99
100
  > 0 position in TYPELIB->type_names +1
100
101
*/
101
102
 
102
 
uint32_t st_typelib::find_type(const char *find, uint32_t length, bool part_match) const
 
103
uint32_t find_type(const TYPELIB *lib, const char *find, uint32_t length,
 
104
               bool part_match)
103
105
{
104
106
  uint32_t found_count=0, found_pos=0;
105
107
  const char *end= find+length;
106
108
  const char *i;
107
109
  const char *j;
108
 
  for (uint32_t pos= 0 ; (j= type_names[pos++]) ; )
 
110
  for (uint32_t pos=0 ; (j=lib->type_names[pos++]) ; )
109
111
  {
110
112
    for (i=find ; i != end &&
111
113
           my_toupper(system_charset_info,*i) ==
139
141
    >0  Offset+1 in typelib for matched string
140
142
*/
141
143
 
142
 
uint32_t st_typelib::find_type2(const char *x, uint32_t length, const CHARSET_INFO *cs) const
 
144
uint32_t find_type2(const TYPELIB *typelib, const char *x, uint32_t length,
 
145
                const CHARSET_INFO * const cs)
143
146
{
144
 
  if (!count)
145
 
    return 0;
 
147
  int pos;
146
148
  const char *j;
147
 
  for (int pos=0 ; (j= type_names[pos]) ; pos++)
 
149
 
 
150
  if (!typelib->count)
 
151
  {
 
152
    return(0);
 
153
  }
 
154
 
 
155
  for (pos=0 ; (j=typelib->type_names[pos]) ; pos++)
148
156
  {
149
157
    if (!my_strnncoll(cs, (const unsigned char*) x, length,
150
 
                          (const unsigned char*) j, type_lengths[pos]))
151
 
      return pos + 1;
 
158
                          (const unsigned char*) j, typelib->type_lengths[pos]))
 
159
      return(pos+1);
152
160
  }
153
 
  return 0;
 
161
  return(0);
154
162
} /* find_type */
155
163
 
156
164
} /* namespace drizzled */