~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/subselect.h

merge lp:~linuxjedi/drizzle/trunk-remove-drizzleadmin

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
 
#ifndef DRIZZLED_ITEM_SUBSELECT_H
21
 
#define DRIZZLED_ITEM_SUBSELECT_H
22
 
 
23
 
/* subselect Item */
24
 
 
25
 
 
26
 
#include "drizzled/comp_creator.h"
27
 
#include "drizzled/item/ref.h"
28
 
#include "drizzled/item/field.h"
29
 
#include "drizzled/item/bin_string.h"
30
 
#include "drizzled/util/test.h"
31
 
 
32
 
namespace drizzled
33
 
{
34
 
 
35
 
class Select_Lex;
36
 
class Select_Lex_Unit;
37
 
class Join;
38
 
class select_result_interceptor;
39
 
class subselect_engine;
40
 
class subselect_hash_sj_engine;
41
 
class Item_bool_func2;
42
 
class Cached_item;
43
 
class Item_in_optimizer;
44
 
class Item_func_not_all;
45
 
class Tmp_Table_Param;
46
 
 
47
 
 
48
 
/* base class for subselects */
 
20
#pragma once
 
21
 
 
22
#include <drizzled/comp_creator.h>
 
23
#include <drizzled/item/ref.h>
 
24
#include <drizzled/item/field.h>
 
25
#include <drizzled/item/bin_string.h>
 
26
#include <drizzled/util/test.h>
 
27
 
 
28
namespace drizzled {
49
29
 
50
30
class Item_subselect :public Item_result_field
51
31
{
123
103
  inline bool get_const_item_cache() { return const_item_cache; }
124
104
  Item *get_tmp_table_item(Session *session);
125
105
  void update_used_tables();
126
 
  virtual void print(String *str, enum_query_type query_type);
 
106
  virtual void print(String *str);
127
107
  virtual bool have_guarded_conds() { return false; }
128
108
  bool change_engine(subselect_engine *eng)
129
109
  {
165
145
 
166
146
/* single value subselect */
167
147
 
168
 
class Item_cache;
169
148
class Item_singlerow_subselect :public Item_subselect
170
149
{
171
150
protected:
214
193
};
215
194
 
216
195
/* used in static ALL/ANY optimization */
217
 
class select_max_min_finder_subselect;
218
196
class Item_maxmin_subselect :public Item_singlerow_subselect
219
197
{
220
198
protected:
223
201
public:
224
202
  Item_maxmin_subselect(Session *session, Item_subselect *parent,
225
203
                        Select_Lex *select_lex, bool max);
226
 
  virtual void print(String *str, enum_query_type query_type);
 
204
  virtual void print(String *str);
227
205
  void cleanup();
228
206
  bool any_value() { return was_values; }
229
207
  void register_value() { was_values= true; }
254
232
  type::Decimal *val_decimal(type::Decimal *);
255
233
  bool val_bool();
256
234
  void fix_length_and_dec();
257
 
  virtual void print(String *str, enum_query_type query_type);
 
235
  virtual void print(String *str);
258
236
 
259
237
  friend class select_exists_subselect;
260
238
  friend class subselect_uniquesubquery_engine;
374
352
  void top_level_item() { abort_on_null=1; }
375
353
  inline bool is_top_level_item() { return abort_on_null; }
376
354
  bool test_limit(Select_Lex_Unit *unit);
377
 
  virtual void print(String *str, enum_query_type query_type);
 
355
  virtual void print(String *str);
378
356
  bool fix_fields(Session *session, Item **ref);
379
357
  bool setup_engine();
380
358
  bool init_left_expr_cache();
402
380
  // only ALL subquery has upper not
403
381
  subs_type substype() { return all?ALL_SUBS:ANY_SUBS; }
404
382
  trans_res select_transformer(Join *join);
405
 
  virtual void print(String *str, enum_query_type query_type);
 
383
  virtual void print(String *str);
406
384
};
407
385
 
408
386
 
471
449
  virtual bool may_be_null() { return maybe_null; }
472
450
  virtual table_map upper_select_const_tables()= 0;
473
451
  static table_map calc_const_tables(TableList *);
474
 
  virtual void print(String *str, enum_query_type query_type)= 0;
 
452
  virtual void print(String *str)= 0;
475
453
  virtual bool change_result(Item_subselect *si,
476
454
                             select_result_interceptor *result)= 0;
477
455
  virtual bool no_tables()= 0;
505
483
  bool uncacheable(uint32_t bit_pos);
506
484
  void exclude();
507
485
  table_map upper_select_const_tables();
508
 
  virtual void print (String *str, enum_query_type query_type);
 
486
  virtual void print (String *str);
509
487
  bool change_result(Item_subselect *si, select_result_interceptor *result);
510
488
  bool no_tables();
511
489
  bool may_be_null();
535
513
  bool uncacheable(uint32_t bit_pos);
536
514
  void exclude();
537
515
  table_map upper_select_const_tables();
538
 
  virtual void print (String *str, enum_query_type query_type);
 
516
  virtual void print (String *str);
539
517
  bool change_result(Item_subselect *si, select_result_interceptor *result);
540
518
  bool no_tables();
541
519
  bool is_executed() const;
544
522
};
545
523
 
546
524
 
547
 
class JoinTable;
548
 
 
549
 
 
550
525
/*
551
526
  A subquery execution engine that evaluates the subquery by doing one index
552
527
  lookup in a unique index.
593
568
  bool uncacheable(uint32_t) { return true; }
594
569
  void exclude();
595
570
  table_map upper_select_const_tables() { return 0; }
596
 
  virtual void print (String *str, enum_query_type query_type);
 
571
  virtual void print (String *str);
597
572
  bool change_result(Item_subselect *si, select_result_interceptor *result);
598
573
  bool no_tables();
599
574
  int scan_table();
648
623
     having(having_arg)
649
624
  {}
650
625
  int exec();
651
 
  virtual void print (String *str, enum_query_type query_type);
 
626
  virtual void print (String *str);
652
627
  virtual enum_engine_type engine_type() { return INDEXSUBQUERY_ENGINE; }
653
628
};
654
629
 
705
680
  void cleanup();
706
681
  int prepare() { return 0; }
707
682
  int exec();
708
 
  virtual void print (String *str, enum_query_type query_type);
 
683
  virtual void print (String *str);
709
684
  uint32_t cols()
710
685
  {
711
686
    return materialize_engine->cols();
715
690
 
716
691
} /* namespace drizzled */
717
692
 
718
 
#endif /* DRIZZLED_ITEM_SUBSELECT_H */