~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/ref.cc

Merge Monty - Added inter-plugin dependencies for controlling plugin load order

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
 
#include <drizzled/item/subselect.h>
29
 
#include <drizzled/sql_lex.h>
30
 
 
31
 
namespace drizzled {
 
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
{
32
31
 
33
32
Item_ref::Item_ref(Name_resolution_context *context_arg,
34
33
                   Item **item, const char *table_name_arg,
114
113
{
115
114
  enum_parsing_place place= NO_MATTER;
116
115
  assert(fixed == 0);
117
 
  Select_Lex *current_sel= session->lex().current_select;
 
116
  Select_Lex *current_sel= session->lex->current_select;
118
117
 
119
118
  if (!ref || ref == not_found_item)
120
119
  {
133
132
      {
134
133
        /* The current reference cannot be resolved in this query. */
135
134
        my_error(ER_BAD_FIELD_ERROR,MYF(0),
136
 
                 full_name(), session->where());
 
135
                 this->full_name(), current_session->where);
137
136
        goto error;
138
137
      }
139
138
 
267
266
        Item_field* fld;
268
267
        if (!(fld= new Item_field(from_field)))
269
268
          goto error;
270
 
        *reference= fld;
 
269
        session->change_item_tree(reference, fld);
271
270
        mark_as_dependent(session, last_checked_context->select_lex,
272
 
                          session->lex().current_select, this, fld);
 
271
                          session->lex->current_select, this, fld);
273
272
        /*
274
273
          A reference is resolved to a nest level that's outer or the same as
275
274
          the nest level of the enclosing set function : adjust the value of
276
275
          max_arg_level for the function if it's needed.
277
276
        */
278
 
        if (session->lex().in_sum_func &&
279
 
            session->lex().in_sum_func->nest_level >=
 
277
        if (session->lex->in_sum_func &&
 
278
            session->lex->in_sum_func->nest_level >=
280
279
            last_checked_context->select_lex->nest_level)
281
 
          set_if_bigger(session->lex().in_sum_func->max_arg_level,
 
280
          set_if_bigger(session->lex->in_sum_func->max_arg_level,
282
281
                        last_checked_context->select_lex->nest_level);
283
282
        return false;
284
283
      }
286
285
      {
287
286
        /* The item was not a table field and not a reference */
288
287
        my_error(ER_BAD_FIELD_ERROR, MYF(0),
289
 
                 full_name(), session->where());
 
288
                 this->full_name(), current_session->where);
290
289
        goto error;
291
290
      }
292
291
      /* Should be checked in resolve_ref_in_select_and_group(). */
298
297
        the nest level of the enclosing set function : adjust the value of
299
298
        max_arg_level for the function if it's needed.
300
299
      */
301
 
      if (session->lex().in_sum_func &&
302
 
          session->lex().in_sum_func->nest_level >=
 
300
      if (session->lex->in_sum_func &&
 
301
          session->lex->in_sum_func->nest_level >=
303
302
          last_checked_context->select_lex->nest_level)
304
 
        set_if_bigger(session->lex().in_sum_func->max_arg_level,
 
303
        set_if_bigger(session->lex->in_sum_func->max_arg_level,
305
304
                      last_checked_context->select_lex->nest_level);
306
305
    }
307
306
  }
369
368
}
370
369
 
371
370
 
372
 
void Item_ref::print(String *str)
 
371
void Item_ref::print(String *str, enum_query_type query_type)
373
372
{
374
373
  if (ref)
375
374
  {
379
378
      str->append_identifier(name, (uint32_t) strlen(name));
380
379
    }
381
380
    else
382
 
      (*ref)->print(str);
 
381
      (*ref)->print(str, query_type);
383
382
  }
384
383
  else
385
 
    Item_ident::print(str);
 
384
    Item_ident::print(str, query_type);
386
385
}
387
386
 
388
387
 
458
457
        type::Decimal decimal_value;
459
458
        type::Decimal *val= result_field->val_decimal(&decimal_value);
460
459
        if (val)
461
 
          return not val->isZero();
 
460
          return not val->is_zero();
462
461
        return 0;
463
462
      }
464
463