~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.cc

Remove PLUGIN and MODULES.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "drizzled/server_includes.h"
 
20
#include "config.h"
21
21
#include "drizzled/sql_select.h"
22
22
#include "drizzled/error.h"
23
23
#include "drizzled/show.h"
30
30
#include "drizzled/sql_base.h"
31
31
#include "drizzled/util/convert.h"
32
32
#include "drizzled/plugin/client.h"
 
33
#include "drizzled/time_functions.h"
33
34
 
34
35
#include "drizzled/field/str.h"
35
36
#include "drizzled/field/num.h"
46
47
#include "drizzled/field/timestamp.h"
47
48
#include "drizzled/field/datetime.h"
48
49
#include "drizzled/field/varstring.h"
 
50
#include "drizzled/internal/m_string.h"
49
51
 
50
52
#include <math.h>
51
53
#include <algorithm>
 
54
#include <float.h>
52
55
 
53
56
using namespace std;
54
57
using namespace drizzled;
316
319
  session->free_list= this;
317
320
}
318
321
 
 
322
uint32_t Item::float_length(uint32_t decimals_par) const
 
323
{
 
324
  return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;
 
325
}
 
326
 
319
327
uint32_t Item::decimal_precision() const
320
328
{
321
329
  Item_result restype= result_type();
419
427
                            str + length - orig_len);
420
428
    }
421
429
  }
422
 
  name= sql_strmake(str, length);
 
430
  name= memory::sql_strmake(str, length);
423
431
}
424
432
 
425
433
bool Item::eq(const Item *item, bool) const
604
612
  return false;
605
613
}
606
614
 
607
 
bool Item::reset_query_id_processor(unsigned char *)
608
 
{
609
 
  return false;
610
 
}
611
 
 
612
615
bool Item::register_field_in_read_map(unsigned char *)
613
616
{
614
617
  return false;
1271
1274
  return error;
1272
1275
}
1273
1276
 
 
1277
/**
 
1278
  Check if an item is a constant one and can be cached.
 
1279
 
 
1280
  @param arg [out] TRUE <=> Cache this item.
 
1281
 
 
1282
  @return TRUE  Go deeper in item tree.
 
1283
  @return FALSE Don't go deeper in item tree.
 
1284
*/
 
1285
 
 
1286
bool Item::cache_const_expr_analyzer(unsigned char **arg)
 
1287
{
 
1288
  bool *cache_flag= (bool*)*arg;
 
1289
  if (!*cache_flag)
 
1290
  {
 
1291
    Item *item= real_item();
 
1292
    /*
 
1293
      Cache constant items unless it's a basic constant, constant field or
 
1294
      a subselect (they use their own cache).
 
1295
    */
 
1296
    if (const_item() &&
 
1297
        !(item->basic_const_item() || item->type() == Item::FIELD_ITEM ||
 
1298
          item->type() == SUBSELECT_ITEM ||
 
1299
           /*
 
1300
             Do not cache GET_USER_VAR() function as its const_item() may
 
1301
             return TRUE for the current thread but it still may change
 
1302
             during the execution.
 
1303
           */
 
1304
          (item->type() == Item::FUNC_ITEM &&
 
1305
           ((Item_func*)item)->functype() == Item_func::GUSERVAR_FUNC)))
 
1306
      *cache_flag= true;
 
1307
    return true;
 
1308
  }
 
1309
  return false;
 
1310
}
 
1311
 
 
1312
/**
 
1313
  Cache item if needed.
 
1314
 
 
1315
  @param arg   TRUE <=> Cache this item.
 
1316
 
 
1317
  @return cache if cache needed.
 
1318
  @return this otherwise.
 
1319
*/
 
1320
 
 
1321
Item* Item::cache_const_expr_transformer(unsigned char *arg)
 
1322
{
 
1323
  if (*(bool*)arg)
 
1324
  {
 
1325
    *((bool*)arg)= false;
 
1326
    Item_cache *cache= Item_cache::get_cache(this);
 
1327
    if (!cache)
 
1328
      return NULL;
 
1329
    cache->setup(this);
 
1330
    cache->store(this);
 
1331
    return cache;
 
1332
  }
 
1333
  return this;
 
1334
}
 
1335
 
1274
1336
bool Item::send(plugin::Client *client, String *buffer)
1275
1337
{
1276
1338
  bool result= false;
1354
1416
    return; /* Can't be better */
1355
1417
  Item_result res_type=item_cmp_type(comp_item->result_type(),
1356
1418
                                     item->result_type());
1357
 
  char *name=item->name; /* Alloced by sql_alloc */
 
1419
  char *name=item->name; /* Alloced by memory::sql_alloc */
1358
1420
 
1359
1421
  switch (res_type) {
1360
1422
  case STRING_RESULT:
1367
1429
    else
1368
1430
    {
1369
1431
      uint32_t length= result->length();
1370
 
      char *tmp_str= sql_strmake(result->ptr(), length);
 
1432
      char *tmp_str= memory::sql_strmake(result->ptr(), length);
1371
1433
      new_item= new Item_string(name, tmp_str, length, result->charset());
1372
1434
    }
1373
1435
    break;
1712
1774
  }
1713
1775
}
1714
1776
 
1715
 
#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION
1716
 
template class List<Item>;
1717
 
template class List_iterator<Item>;
1718
 
template class List_iterator_fast<Item>;
1719
 
template class List_iterator_fast<Item_field>;
1720
 
template class List<List_item>;
1721
 
#endif