~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_lex.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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
 
#pragma once
 
20
#ifndef DRIZZLED_SQL_LEX_H
 
21
#define DRIZZLED_SQL_LEX_H
21
22
 
22
23
/**
23
24
  @defgroup Semantic_Analysis Semantic Analysis
24
25
*/
25
26
#include <drizzled/message/table.pb.h>
26
 
#include <drizzled/name_resolution_context.h>
27
 
#include <drizzled/table_list.h>
28
 
#include <drizzled/function/math/real.h>
29
 
#include <drizzled/key_part_spec.h>
30
 
#include <drizzled/index_hint.h>
31
 
#include <drizzled/optimizer/explain_plan.h>
 
27
 
 
28
#include "drizzled/plugin/function.h"
 
29
#include "drizzled/name_resolution_context.h"
 
30
#include "drizzled/item/subselect.h"
 
31
#include "drizzled/table_list.h"
 
32
#include "drizzled/function/math/real.h"
 
33
#include "drizzled/alter_drop.h"
 
34
#include "drizzled/alter_column.h"
 
35
#include "drizzled/alter_info.h"
 
36
#include "drizzled/key_part_spec.h"
 
37
#include "drizzled/index_hint.h"
 
38
#include "drizzled/statement.h"
 
39
#include "drizzled/optimizer/explain_plan.h"
32
40
 
33
41
#include <bitset>
34
42
#include <string>
35
43
 
 
44
namespace drizzled
 
45
{
 
46
 
 
47
class st_lex_symbol;
 
48
class select_result_interceptor;
 
49
 
 
50
/* YACC and LEX Definitions */
 
51
 
 
52
/* These may not be declared yet */
 
53
class Table_ident;
 
54
class file_exchange;
 
55
class Lex_Column;
 
56
class Item_outer_ref;
 
57
 
 
58
} /* namespace drizzled */
 
59
 
36
60
/*
37
61
  The following hack is needed because mysql_yacc.cc does not define
38
62
  YYSTYPE before including this file
48
72
#  if defined(DRIZZLE_LEX)
49
73
#   include <drizzled/foreign_key.h>
50
74
#   include <drizzled/lex_symbol.h>
51
 
#   include <drizzled/comp_creator.h>
52
75
#   include <drizzled/sql_yacc.h>
53
76
#   define LEX_YYSTYPE YYSTYPE *
54
77
#  else
207
230
    Base class for Select_Lex (Select_Lex) &
208
231
    Select_Lex_Unit (Select_Lex_Unit)
209
232
*/
 
233
class LEX;
 
234
class Select_Lex;
 
235
class Select_Lex_Unit;
210
236
class Select_Lex_Node {
211
237
protected:
212
238
  Select_Lex_Node *next, **prev,   /* neighbor list */
225
251
      UNCACHEABLE_PREPARE
226
252
  */
227
253
  std::bitset<8> uncacheable;
228
 
  sub_select_type linkage;
 
254
  enum sub_select_type linkage;
229
255
  bool no_table_names_allowed; /* used for global order by */
230
256
  bool no_error; /* suppress error message (convert it to warnings) */
231
257
 
278
304
   Select_Lex_Unit - unit of selects (UNION, INTERSECT, ...) group
279
305
   Select_Lexs
280
306
*/
 
307
class Session;
 
308
class select_result;
 
309
class Join;
 
310
class select_union;
281
311
class Select_Lex_Unit: public Select_Lex_Node {
282
312
protected:
283
313
  TableList result_table_list;
353
383
  inline void unclean() { cleaned= 0; }
354
384
  void reinit_exec_mechanism();
355
385
 
356
 
  void print(String *str);
 
386
  void print(String *str, enum_query_type query_type);
357
387
 
358
388
  bool add_fake_select_lex(Session *session);
359
389
  void init_prepare_fake_select_lex(Session *session);
364
394
  inline bool is_union ();
365
395
 
366
396
  friend void lex_start(Session *session);
 
397
  friend int subselect_union_engine::exec();
367
398
 
368
399
  List<Item> *get_unit_column_types();
369
400
};
444
475
  Item::cond_result having_value;
445
476
  /* point on lex in which it was created, used in view subquery detection */
446
477
  LEX *parent_lex;
447
 
  olap_type olap;
 
478
  enum olap_type olap;
448
479
  /* FROM clause - points to the beginning of the TableList::next_local list. */
449
480
  SQL_LIST table_list;
450
481
  SQL_LIST group_list; /* GROUP BY clause. */
462
493
    by TableList::next_leaf, so leaf_tables points to the left-most leaf.
463
494
  */
464
495
  TableList *leaf_tables;
465
 
  drizzled::optimizer::select_type type; /* type of select for EXPLAIN */
 
496
  enum drizzled::optimizer::select_type type; /* type of select for EXPLAIN */
466
497
 
467
498
  SQL_LIST order_list;                /* ORDER clause */
468
499
  SQL_LIST *gorder_list;
621
652
    init_select();
622
653
  }
623
654
  bool setup_ref_array(Session *session, uint32_t order_group_num);
624
 
  void print(Session *session, String *str);
625
 
  static void print_order(String *str, Order *order);
626
 
 
627
 
  void print_limit(Session *session, String *str);
 
655
  void print(Session *session, String *str, enum_query_type query_type);
 
656
  static void print_order(String *str,
 
657
                          Order *order,
 
658
                          enum_query_type query_type);
 
659
  void print_limit(Session *session, String *str, enum_query_type query_type);
628
660
  void fix_prepare_information(Session *session, Item **conds, Item **having_conds);
629
661
  /*
630
662
    Destroy the used execution plan (JOIN) of this subtree (this
637
669
  */
638
670
  void cleanup_all_joins(bool full);
639
671
 
640
 
  void set_index_hint_type(index_hint_type type, index_clause_map clause);
 
672
  void set_index_hint_type(enum index_hint_type type, index_clause_map clause);
641
673
 
642
674
  /*
643
675
   Add a index hint to the tagged list of hints. The type and clause of the
644
676
   hint will be the current ones (set by set_index_hint())
645
677
  */
646
 
  void add_index_hint(Session *session, char *str, uint32_t length);
 
678
  bool add_index_hint (Session *session, char *str, uint32_t length);
647
679
 
648
680
  /* make a list to hold index hints */
649
681
  void alloc_index_hints (Session *session);
659
691
 
660
692
private:
661
693
  /* current index hint kind. used in filling up index_hints */
662
 
  index_hint_type current_index_hint_type;
 
694
  enum index_hint_type current_index_hint_type;
663
695
  index_clause_map current_index_hint_clause;
664
696
  /* a list of USE/FORCE/IGNORE INDEX */
665
697
  List<Index_hint> *index_hints;
769
801
 
770
802
} /* namespace drizzled */
771
803
 
772
 
#include <drizzled/lex_input_stream.h>
 
804
#include "drizzled/lex_input_stream.h"
773
805
 
774
806
namespace drizzled
775
807
{
785
817
  /* list of all Select_Lex */
786
818
  Select_Lex *all_selects_list;
787
819
 
788
 
  /* This is the "scale" for DECIMAL (S,P) notation */
 
820
  /* This is the "scale" for DECIMAL (S,P) notation */ 
789
821
  char *length;
790
822
  /* This is the decimal precision in DECIMAL(S,P) notation */
791
823
  char *dec;
792
 
 
 
824
  
793
825
  /**
794
 
   * This is used kind of like the "ident" member variable below, as
 
826
   * This is used kind of like the "ident" member variable below, as 
795
827
   * a place to store certain names of identifiers.  Unfortunately, it
796
828
   * is used differently depending on the Command (SELECT on a derived
797
829
   * table vs CREATE)
807
839
   * or a named savepoint.  It should probably be refactored out into
808
840
   * the eventual Command class built for the Keycache and Savepoint
809
841
   * commands.
810
 
   */
 
842
   */ 
811
843
  LEX_STRING ident;
812
844
 
813
845
  unsigned char* yacc_yyss, *yacc_yyvs;
814
846
  /* The owning Session of this LEX */
815
847
  Session *session;
816
 
  const charset_info_st *charset;
 
848
  const CHARSET_INFO *charset;
817
849
  bool text_string_is_7bit;
818
850
  /* store original leaf_tables for INSERT SELECT and PS/SP */
819
851
  TableList *leaf_tables_insert;
912
944
 
913
945
  void cleanup_after_one_table_open();
914
946
 
915
 
  void push_context(Name_resolution_context *context)
 
947
  bool push_context(Name_resolution_context *context)
916
948
  {
917
 
    context_stack.push_front(context);
 
949
    return context_stack.push_front(context);
918
950
  }
919
951
 
920
952
  void pop_context()
926
958
 
927
959
  Name_resolution_context *current_context()
928
960
  {
929
 
    return &context_stack.front();
 
961
    return context_stack.head();
930
962
  }
931
963
 
932
964
  /**
987
1019
    return _create_table;
988
1020
  }
989
1021
 
990
 
  message::AlterTable *alter_table();
991
 
 
992
1022
  message::Table::Field *field()
993
1023
  {
994
1024
    return _create_field;
1009
1039
    return _exists;
1010
1040
  }
1011
1041
 
1012
 
private:
 
1042
private: 
1013
1043
  bool cacheable;
1014
1044
  bool sum_expr_used;
1015
1045
  message::Table *_create_table;
1016
 
  message::AlterTable *_alter_table;
1017
1046
  message::Table::Field *_create_field;
1018
1047
  bool _exists;
1019
1048
};
1020
1049
 
1021
1050
extern void lex_start(Session *session);
 
1051
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
 
1052
extern bool is_lex_native_function(const LEX_STRING *name);
 
1053
 
 
1054
bool check_for_sql_keyword(drizzled::st_lex_symbol const&);
 
1055
bool check_for_sql_keyword(drizzled::lex_string_t const&);
1022
1056
 
1023
1057
/**
1024
1058
  @} (End of group Semantic_Analysis)
1027
1061
} /* namespace drizzled */
1028
1062
 
1029
1063
#endif /* DRIZZLE_SERVER */
 
1064
#endif /* DRIZZLED_SQL_LEX_H */