~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/math/round.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:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
 
20
#include "config.h"
21
21
 
22
22
#include <math.h>
23
23
#include <limits.h>
25
25
#include <limits>
26
26
#include <algorithm>
27
27
 
28
 
#include <drizzled/function/math/round.h>
29
 
#include <drizzled/util/test.h>
 
28
#include "drizzled/function/math/round.h"
30
29
 
31
30
namespace drizzled
32
31
{
100
99
 
101
100
    precision-= decimals_delta - length_increase;
102
101
    decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
103
 
    max_length= class_decimal_precision_to_length(precision, decimals,
 
102
    max_length= my_decimal_precision_to_length(precision, decimals,
104
103
                                               unsigned_flag);
105
104
    break;
106
105
  }
203
202
 
204
203
  if (truncate)
205
204
    value= (unsigned_flag) ?
206
 
      (int64_t)(((uint64_t) value / tmp) * tmp) : (value / tmp) * tmp;
 
205
      ((uint64_t) value / tmp) * tmp : (value / tmp) * tmp;
207
206
  else
208
207
    value= (unsigned_flag || value >= 0) ?
209
 
      (int64_t)(my_unsigned_round((uint64_t) value, tmp)) :
 
208
      my_unsigned_round((uint64_t) value, tmp) :
210
209
      -(int64_t) my_unsigned_round((uint64_t) -value, tmp);
211
210
  return value;
212
211
}
213
212
 
214
213
 
215
 
type::Decimal *Item_func_round::decimal_op(type::Decimal *decimal_value)
 
214
my_decimal *Item_func_round::decimal_op(my_decimal *decimal_value)
216
215
{
217
 
  type::Decimal val, *value= args[0]->val_decimal(&val);
 
216
  my_decimal val, *value= args[0]->val_decimal(&val);
218
217
  int64_t dec= args[1]->val_int();
219
218
 
220
219
  if (dec >= 0 || args[1]->unsigned_flag)
223
222
    dec= INT_MIN;
224
223
 
225
224
  if (!(null_value= (args[0]->null_value || args[1]->null_value ||
226
 
                     class_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
 
225
                     my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
227
226
                                      truncate, decimal_value) > 1)))
228
227
  {
229
228
    decimal_value->frac= decimals;