~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/ref.cc

  • Committer: Olaf van der Spek
  • Date: 2011-07-04 19:11:47 UTC
  • mto: This revision was merged to the branch mainline in revision 2367.
  • Revision ID: olafvdspek@gmail.com-20110704191147-s99ojek811zi1fzj
RemoveĀ unusedĀ Name_resolution_context::error_reporter

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 <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 {
31
32
 
32
33
Item_ref::Item_ref(Name_resolution_context *context_arg,
33
34
                   Item **item, const char *table_name_arg,
113
114
{
114
115
  enum_parsing_place place= NO_MATTER;
115
116
  assert(fixed == 0);
116
 
  Select_Lex *current_sel= session->lex->current_select;
 
117
  Select_Lex *current_sel= session->lex().current_select;
117
118
 
118
119
  if (!ref || ref == not_found_item)
119
120
  {
120
 
    if (!(ref= resolve_ref_in_select_and_group(session, this,
121
 
                                               context->select_lex)))
122
 
      goto error;             /* Some error occurred (e.g. ambiguous names). */
 
121
    if (!(ref= resolve_ref_in_select_and_group(session, this, context->select_lex)))
 
122
      return true;             /* Some error occurred (e.g. ambiguous names). */
123
123
 
124
124
    if (ref == not_found_item) /* This reference was not resolved. */
125
125
    {
131
131
      if (!outer_context)
132
132
      {
133
133
        /* The current reference cannot be resolved in this query. */
134
 
        my_error(ER_BAD_FIELD_ERROR,MYF(0),
135
 
                 full_name(), session->where());
136
 
        goto error;
 
134
        my_error(ER_BAD_FIELD_ERROR,MYF(0), full_name(), session->where());
 
135
        return true;
137
136
      }
138
137
 
139
138
      /*
158
157
        if (outer_context->resolve_in_select_list)
159
158
        {
160
159
          if (!(ref= resolve_ref_in_select_and_group(session, this, select)))
161
 
            goto error; /* Some error occurred (e.g. ambiguous names). */
 
160
            return true; /* Some error occurred (e.g. ambiguous names). */
162
161
          if (ref != not_found_item)
163
162
          {
164
163
            assert(*ref && (*ref)->fixed);
204
203
                                           reference,
205
204
                                           IGNORE_EXCEPT_NON_UNIQUE, true);
206
205
          if (! from_field)
207
 
            goto error;
 
206
            return true;
208
207
          if (from_field == view_ref_found)
209
208
          {
210
209
            Item::Type refer_type= (*reference)->type();
264
263
      if (from_field != not_found_field)
265
264
      {
266
265
        Item_field* fld;
267
 
        if (!(fld= new Item_field(from_field)))
268
 
          goto error;
269
 
        session->change_item_tree(reference, fld);
 
266
        fld= new Item_field(from_field);
 
267
        *reference= fld;
270
268
        mark_as_dependent(session, last_checked_context->select_lex,
271
 
                          session->lex->current_select, this, fld);
 
269
                          session->lex().current_select, this, fld);
272
270
        /*
273
271
          A reference is resolved to a nest level that's outer or the same as
274
272
          the nest level of the enclosing set function : adjust the value of
275
273
          max_arg_level for the function if it's needed.
276
274
        */
277
 
        if (session->lex->in_sum_func &&
278
 
            session->lex->in_sum_func->nest_level >=
 
275
        if (session->lex().in_sum_func &&
 
276
            session->lex().in_sum_func->nest_level >=
279
277
            last_checked_context->select_lex->nest_level)
280
 
          set_if_bigger(session->lex->in_sum_func->max_arg_level,
 
278
          set_if_bigger(session->lex().in_sum_func->max_arg_level,
281
279
                        last_checked_context->select_lex->nest_level);
282
280
        return false;
283
281
      }
284
282
      if (ref == 0)
285
283
      {
286
284
        /* The item was not a table field and not a reference */
287
 
        my_error(ER_BAD_FIELD_ERROR, MYF(0),
288
 
                 full_name(), session->where());
289
 
        goto error;
 
285
        my_error(ER_BAD_FIELD_ERROR, MYF(0), full_name(), session->where());
 
286
        return true;
290
287
      }
291
288
      /* Should be checked in resolve_ref_in_select_and_group(). */
292
289
      assert(*ref && (*ref)->fixed);
297
294
        the nest level of the enclosing set function : adjust the value of
298
295
        max_arg_level for the function if it's needed.
299
296
      */
300
 
      if (session->lex->in_sum_func &&
301
 
          session->lex->in_sum_func->nest_level >=
 
297
      if (session->lex().in_sum_func &&
 
298
          session->lex().in_sum_func->nest_level >=
302
299
          last_checked_context->select_lex->nest_level)
303
 
        set_if_bigger(session->lex->in_sum_func->max_arg_level,
 
300
        set_if_bigger(session->lex().in_sum_func->max_arg_level,
304
301
                      last_checked_context->select_lex->nest_level);
305
302
    }
306
303
  }
319
316
          current_sel->having_fix_field)) ||
320
317
       !(*ref)->fixed))
321
318
  {
322
 
    my_error(ER_ILLEGAL_REFERENCE, MYF(0),
323
 
             name, ((*ref)->with_sum_func?
324
 
                    "reference to group function":
325
 
                    "forward reference in item list"));
326
 
    goto error;
 
319
    my_error(ER_ILLEGAL_REFERENCE, MYF(0), name, ((*ref)->with_sum_func ? "reference to group function" : "forward reference in item list"));
 
320
    return true;
327
321
  }
328
322
 
329
323
  set_properties();
330
324
 
331
325
  if ((*ref)->check_cols(1))
332
 
    goto error;
 
326
    return true;
333
327
  return false;
334
 
 
335
 
error:
336
 
  context->process_error(session);
337
 
  return true;
338
328
}
339
329
 
340
330
 
368
358
}
369
359
 
370
360
 
371
 
void Item_ref::print(String *str, enum_query_type query_type)
 
361
void Item_ref::print(String *str)
372
362
{
373
363
  if (ref)
374
364
  {
378
368
      str->append_identifier(name, (uint32_t) strlen(name));
379
369
    }
380
370
    else
381
 
      (*ref)->print(str, query_type);
 
371
      (*ref)->print(str);
382
372
  }
383
373
  else
384
 
    Item_ident::print(str, query_type);
 
374
    Item_ident::print(str);
385
375
}
386
376
 
387
377
 
388
 
bool Item_ref::send(plugin::Client *client, String *tmp)
 
378
void Item_ref::send(plugin::Client *client, String *tmp)
389
379
{
390
380
  if (result_field)
391
 
    return client->store(result_field);
 
381
  {
 
382
    client->store(result_field);
 
383
    return;
 
384
  }
392
385
  return (*ref)->send(client, tmp);
393
386
}
394
387