~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/ref.cc

  • Committer: Brian Aker
  • Date: 2009-01-24 09:43:35 UTC
  • Revision ID: brian@gir-3.local-20090124094335-6qdtvc35gl5fvivz
Adding in an example singe thread scheduler

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 "config.h"
21
 
 
22
 
#include "drizzled/session.h"
23
 
#include "drizzled/error.h"
24
 
#include "drizzled/show.h"
25
 
#include "drizzled/item/ref.h"
26
 
#include "drizzled/plugin/client.h"
27
 
#include "drizzled/item/sum.h"
28
 
 
29
 
namespace drizzled
30
 
{
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/session.h>
 
23
#include <drizzled/error.h>
 
24
#include <drizzled/show.h>
 
25
#include <drizzled/item/ref.h>
31
26
 
32
27
Item_ref::Item_ref(Name_resolution_context *context_arg,
33
28
                   Item **item, const char *table_name_arg,
113
108
{
114
109
  enum_parsing_place place= NO_MATTER;
115
110
  assert(fixed == 0);
116
 
  Select_Lex *current_sel= session->lex->current_select;
 
111
  SELECT_LEX *current_sel= session->lex->current_select;
117
112
 
118
113
  if (!ref || ref == not_found_item)
119
114
  {
149
144
 
150
145
      do
151
146
      {
152
 
        Select_Lex *select= outer_context->select_lex;
 
147
        SELECT_LEX *select= outer_context->select_lex;
153
148
        Item_subselect *prev_subselect_item=
154
149
          last_checked_context->select_lex->master_unit()->item;
155
150
        last_checked_context= outer_context;
184
179
          condition, so that we can give a better error message -
185
180
          ER_WRONG_FIELD_WITH_GROUP, instead of the less informative
186
181
          ER_BAD_FIELD_ERROR which we produce now.
187
 
 
188
 
          @todo determine if this is valid.
189
182
        */
190
183
        if ((place != IN_HAVING ||
191
184
             (!select->with_sum_func &&
202
195
                                           outer_context->
203
196
                                             last_name_resolution_table,
204
197
                                           reference,
205
 
                                           IGNORE_EXCEPT_NON_UNIQUE, true);
 
198
                                           IGNORE_EXCEPT_NON_UNIQUE,
 
199
                                           true, true);
206
200
          if (! from_field)
207
201
            goto error;
208
202
          if (from_field == view_ref_found)
246
240
              } while (outer_context && outer_context->select_lex &&
247
241
                       cached_table->select_lex != outer_context->select_lex);
248
242
            }
249
 
            prev_subselect_item->used_tables_cache|= from_field->getTable()->map;
 
243
            prev_subselect_item->used_tables_cache|= from_field->table->map;
250
244
            prev_subselect_item->const_item_cache= 0;
251
245
            break;
252
246
          }
375
369
    if ((*ref)->type() != Item::CACHE_ITEM &&
376
370
        !table_name && name && alias_name_used)
377
371
    {
378
 
      str->append_identifier(name, (uint32_t) strlen(name));
 
372
      str->append_identifier(name, (uint) strlen(name));
379
373
    }
380
374
    else
381
375
      (*ref)->print(str, query_type);
385
379
}
386
380
 
387
381
 
388
 
bool Item_ref::send(plugin::Client *client, String *tmp)
 
382
bool Item_ref::send(Protocol *prot, String *tmp)
389
383
{
390
384
  if (result_field)
391
 
    return client->store(result_field);
392
 
  return (*ref)->send(client, tmp);
 
385
    return prot->store(result_field);
 
386
  return (*ref)->send(prot, tmp);
393
387
}
394
388
 
395
389
 
451
445
    switch (result_field->result_type()) {
452
446
    case INT_RESULT:
453
447
      return result_field->val_int() != 0;
454
 
 
455
448
    case DECIMAL_RESULT:
456
 
      {
457
 
        my_decimal decimal_value;
458
 
        my_decimal *val= result_field->val_decimal(&decimal_value);
459
 
        if (val)
460
 
          return !my_decimal_is_zero(val);
461
 
        return 0;
462
 
      }
463
 
 
 
449
    {
 
450
      my_decimal decimal_value;
 
451
      my_decimal *val= result_field->val_decimal(&decimal_value);
 
452
      if (val)
 
453
        return !my_decimal_is_zero(val);
 
454
      return 0;
 
455
    }
464
456
    case REAL_RESULT:
465
457
    case STRING_RESULT:
466
458
      return result_field->val_real() != 0.0;
467
 
 
468
459
    case ROW_RESULT:
 
460
    default:
469
461
      assert(0);
470
462
    }
471
463
  }
472
 
 
473
464
  return val_bool();
474
465
}
475
466
 
546
537
}
547
538
 
548
539
 
549
 
void Item_ref::make_field(SendField *field)
 
540
void Item_ref::make_field(Send_field *field)
550
541
{
551
542
  (*ref)->make_field(field);
552
543
  /* Non-zero in case of a view */
573
564
  return item;
574
565
}
575
566
 
576
 
void Item_ref::fix_after_pullout(Select_Lex *new_parent, Item **)
 
567
void Item_ref::fix_after_pullout(st_select_lex *new_parent, Item **)
577
568
{
578
569
  if (depended_from == new_parent)
579
570
  {
581
572
    depended_from= NULL;
582
573
  }
583
574
}
584
 
 
585
 
} /* namespace drizzled */