~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item.cc

  • Committer: Dennis Schoen
  • Date: 2009-12-08 14:39:01 UTC
  • mto: This revision was merged to the branch mainline in revision 1248.
  • Revision ID: dennis@blogma.de-20091208143901-lffbxjeegzq1jzfw
add Item functions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1272
1272
  return error;
1273
1273
}
1274
1274
 
 
1275
/**
 
1276
  Check if an item is a constant one and can be cached.
 
1277
 
 
1278
  @param arg [out] TRUE <=> Cache this item.
 
1279
 
 
1280
  @return TRUE  Go deeper in item tree.
 
1281
  @return FALSE Don't go deeper in item tree.
 
1282
*/
 
1283
 
 
1284
bool Item::cache_const_expr_analyzer(unsigned char **arg)
 
1285
{
 
1286
  bool *cache_flag= (bool*)*arg;
 
1287
  if (!*cache_flag)
 
1288
  {
 
1289
    Item *item= real_item();
 
1290
    /*
 
1291
      Cache constant items unless it's a basic constant, constant field or
 
1292
      a subselect (they use their own cache).
 
1293
    */
 
1294
    if (const_item() &&
 
1295
        !(item->basic_const_item() || item->type() == Item::FIELD_ITEM ||
 
1296
          item->type() == SUBSELECT_ITEM ||
 
1297
           /*
 
1298
             Do not cache GET_USER_VAR() function as its const_item() may
 
1299
             return TRUE for the current thread but it still may change
 
1300
             during the execution.
 
1301
           */
 
1302
          (item->type() == Item::FUNC_ITEM &&
 
1303
           ((Item_func*)item)->functype() == Item_func::GUSERVAR_FUNC)))
 
1304
      *cache_flag= true;
 
1305
    return true;
 
1306
  }
 
1307
  return false;
 
1308
}
 
1309
 
 
1310
/**
 
1311
  Cache item if needed.
 
1312
 
 
1313
  @param arg   TRUE <=> Cache this item.
 
1314
 
 
1315
  @return cache if cache needed.
 
1316
  @return this otherwise.
 
1317
*/
 
1318
 
 
1319
Item* Item::cache_const_expr_transformer(unsigned char *arg)
 
1320
{
 
1321
  if (*(bool*)arg)
 
1322
  {
 
1323
    *((bool*)arg)= false;
 
1324
    Item_cache *cache= Item_cache::get_cache(this);
 
1325
    if (!cache)
 
1326
      return NULL;
 
1327
    cache->setup(this);
 
1328
    cache->store(this);
 
1329
    return cache;
 
1330
  }
 
1331
  return this;
 
1332
}
 
1333
 
1275
1334
bool Item::send(plugin::Client *client, String *buffer)
1276
1335
{
1277
1336
  bool result= false;