~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_lex.h

  • Committer: Toru Maesaka
  • Date: 2008-07-17 05:59:20 UTC
  • mto: (202.1.1 toru)
  • mto: This revision was merged to the branch mainline in revision 204.
  • Revision ID: dev@torum.net-20080717055920-10okif50x6nh7b1d
forgot to bzr-add new files in the previous push

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef DRIZZLE_SERVER_SQL_LEX_H
21
 
#define DRIZZLE_SERVER_SQL_LEX_H
 
1
/* Copyright (C) 2000-2006 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
22
15
 
23
16
/**
24
17
  @defgroup Semantic_Analysis Semantic Analysis
25
18
*/
26
19
 
27
 
#include "sql_udf.h"
28
 
 
29
20
/* YACC and LEX Definitions */
30
21
 
31
22
/* These may not be declared yet */
33
24
class sql_exchange;
34
25
class LEX_COLUMN;
35
26
 
36
 
#ifdef DRIZZLE_SERVER
 
27
#ifdef MYSQL_SERVER
37
28
/*
38
29
  The following hack is needed because mysql_yacc.cc does not define
39
30
  YYSTYPE before including this file
41
32
 
42
33
#include "set_var.h"
43
34
 
44
 
#ifdef DRIZZLE_YACC
 
35
#ifdef MYSQL_YACC
45
36
#define LEX_YYSTYPE void *
46
37
#else
47
 
#if defined(DRIZZLE_LEX)
 
38
#if defined(MYSQL_LEX)
48
39
#include "lex_symbol.h"
49
40
#include "sql_yacc.h"
50
41
#define LEX_YYSTYPE YYSTYPE *
93
84
  SQLCOM_CHECKSUM,
94
85
  SQLCOM_BINLOG_BASE64_EVENT,
95
86
  SQLCOM_SHOW_PLUGINS,
 
87
  SQLCOM_ALTER_DB_UPGRADE,
96
88
  /*
97
89
    When a command is added here, be sure it's also added in mysqld.cc
98
90
    in "struct show_var_st status_vars[]= {" ...
105
97
#define DESCRIBE_NORMAL         1
106
98
#define DESCRIBE_EXTENDED       2
107
99
 
108
 
#ifdef DRIZZLE_SERVER
 
100
#ifdef MYSQL_SERVER
 
101
 
 
102
enum enum_sp_data_access
 
103
{
 
104
  SP_DEFAULT_ACCESS= 0,
 
105
  SP_CONTAINS_SQL,
 
106
  SP_NO_SQL,
 
107
  SP_READS_SQL_DATA,
 
108
  SP_MODIFIES_SQL_DATA
 
109
};
 
110
 
 
111
const LEX_STRING sp_data_access_name[]=
 
112
{
 
113
  { C_STRING_WITH_LEN("") },
 
114
  { C_STRING_WITH_LEN("CONTAINS SQL") },
 
115
  { C_STRING_WITH_LEN("NO SQL") },
 
116
  { C_STRING_WITH_LEN("READS SQL DATA") },
 
117
  { C_STRING_WITH_LEN("MODIFIES SQL DATA") }
 
118
};
109
119
 
110
120
#define DERIVED_NONE    0
111
121
#define DERIVED_SUBQUERY        1
112
122
 
 
123
enum enum_drop_mode
 
124
{
 
125
  DROP_DEFAULT, // mode is not specified
 
126
  DROP_CASCADE, // CASCADE option
 
127
  DROP_RESTRICT // RESTRICT option
 
128
};
 
129
 
113
130
typedef List<Item> List_item;
114
131
 
115
132
/* SERVERS CACHE CHANGES */
116
133
typedef struct st_lex_server_options
117
134
{
118
 
  int32_t port;
119
 
  uint32_t server_name_length;
120
 
  char *server_name, *host, *db, *username, *password, *scheme, *owner;
 
135
  long port;
 
136
  uint server_name_length;
 
137
  char *server_name, *host, *db, *username, *password, *scheme, *socket, *owner;
121
138
} LEX_SERVER_OPTIONS;
122
139
 
123
140
typedef struct st_lex_master_info
124
141
{
125
142
  char *host, *user, *password, *log_file_name;
126
 
  uint32_t port, connect_retry;
 
143
  uint port, connect_retry;
127
144
  float heartbeat_period;
128
145
  uint64_t pos;
129
 
  uint32_t server_id;
 
146
  ulong server_id;
130
147
  /*
131
148
    Enum is used for making it possible to detect if the user
132
149
    changed variable or if it should be left at old value
135
152
    ssl, ssl_verify_server_cert, heartbeat_opt;
136
153
  char *ssl_key, *ssl_cert, *ssl_ca, *ssl_capath, *ssl_cipher;
137
154
  char *relay_log_name;
138
 
  uint32_t relay_log_pos;
 
155
  ulong relay_log_pos;
139
156
} LEX_MASTER_INFO;
140
157
 
141
158
 
160
177
  Keep in sync with index_hint_type.
161
178
*/
162
179
extern const char * index_hint_type_name[];
163
 
typedef unsigned char index_clause_map;
 
180
typedef uchar index_clause_map;
164
181
 
165
182
/*
166
183
  Bits in index_clause_map : one for each possible FOR clause in
188
205
  LEX_STRING key_name;
189
206
 
190
207
  Index_hint (enum index_hint_type type_arg, index_clause_map clause_arg,
191
 
              char *str, uint32_t length) :
 
208
              char *str, uint length) :
192
209
    type(type_arg), clause(clause_arg)
193
210
  {
194
211
    key_name.str= str;
336
353
      UNCACHEABLE_EXPLAIN
337
354
      UNCACHEABLE_PREPARE
338
355
  */
339
 
  uint8_t uncacheable;
 
356
  uint8 uncacheable;
340
357
  enum sub_select_type linkage;
341
358
  bool no_table_names_allowed; /* used for global order by */
342
359
  bool no_error; /* suppress error message (convert it to warnings) */
346
363
    return sql_alloc(size);
347
364
  }
348
365
  static void *operator new(size_t size, MEM_ROOT *mem_root)
349
 
  { return (void*) alloc_root(mem_root, (uint32_t) size); }
350
 
  static void operator delete(void *ptr __attribute__((unused)),
351
 
                              size_t size __attribute__((unused)))
 
366
  { return (void*) alloc_root(mem_root, (uint) size); }
 
367
  static void operator delete(void *ptr __attribute__((__unused__)),
 
368
                              size_t size __attribute__((__unused__)))
352
369
  { TRASH(ptr, size); }
353
 
  static void operator delete(void *ptr __attribute__((unused)),
354
 
                              MEM_ROOT *mem_root __attribute__((unused)))
 
370
  static void operator delete(void *ptr __attribute__((__unused__)),
 
371
                              MEM_ROOT *mem_root __attribute__((__unused__)))
355
372
  {}
356
373
  st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {}
357
374
  virtual ~st_select_lex_node() {}
370
387
 
371
388
  virtual bool set_braces(bool value);
372
389
  virtual bool inc_in_sum_expr();
373
 
  virtual uint32_t get_in_sum_expr();
374
 
  virtual TableList* get_table_list();
 
390
  virtual uint get_in_sum_expr();
 
391
  virtual TABLE_LIST* get_table_list();
375
392
  virtual List<Item>* get_item_list();
376
 
  virtual uint32_t get_table_join_options();
377
 
  virtual TableList *add_table_to_list(THD *thd, Table_ident *table,
 
393
  virtual ulong get_table_join_options();
 
394
  virtual TABLE_LIST *add_table_to_list(THD *thd, Table_ident *table,
378
395
                                        LEX_STRING *alias,
379
 
                                        uint32_t table_options,
 
396
                                        ulong table_options,
380
397
                                        thr_lock_type flags= TL_UNLOCK,
381
398
                                        List<Index_hint> *hints= 0,
382
399
                                        LEX_STRING *option= 0);
383
 
  virtual void set_lock_for_tables(thr_lock_type lock_type __attribute__((unused)))
 
400
  virtual void set_lock_for_tables(thr_lock_type lock_type __attribute__((__unused__)))
384
401
  {}
385
402
 
386
403
  friend class st_select_lex_unit;
400
417
class select_union;
401
418
class st_select_lex_unit: public st_select_lex_node {
402
419
protected:
403
 
  TableList result_table_list;
 
420
  TABLE_LIST result_table_list;
404
421
  select_union *union_result;
405
 
  Table *table; /* temporary table using for appending UNION results */
 
422
  TABLE *table; /* temporary table using for appending UNION results */
406
423
 
407
424
  select_result *result;
408
425
  uint64_t found_rows_for_union;
455
472
  st_select_lex* outer_select();
456
473
  st_select_lex* first_select()
457
474
  {
458
 
    return reinterpret_cast<st_select_lex*>(slave);
 
475
    return my_reinterpret_cast(st_select_lex*)(slave);
459
476
  }
460
477
  st_select_lex_unit* next_unit()
461
478
  {
462
 
    return reinterpret_cast<st_select_lex_unit*>(next);
 
479
    return my_reinterpret_cast(st_select_lex_unit*)(next);
463
480
  }
464
481
  st_select_lex* return_after_parsing() { return return_to; }
465
482
  void exclude_level();
466
483
  void exclude_tree();
467
484
 
468
485
  /* UNION methods */
469
 
  bool prepare(THD *thd, select_result *result, uint32_t additional_options);
 
486
  bool prepare(THD *thd, select_result *result, ulong additional_options);
470
487
  bool exec();
471
488
  bool cleanup();
472
489
  inline void unclean() { cleaned= 0; }
499
516
  Name_resolution_context context;
500
517
  char *db;
501
518
  Item *where, *having;                         /* WHERE & HAVING clauses */
 
519
  Item *prep_where; /* saved WHERE clause for prepared statement processing */
 
520
  Item *prep_having;/* saved HAVING clause for prepared statement processing */
502
521
  /* Saved values of the WHERE and HAVING clauses*/
503
522
  Item::cond_result cond_value, having_value;
504
523
  /* point on lex in which it was created, used in view subquery detection */
505
524
  st_lex *parent_lex;
506
525
  enum olap_type olap;
507
 
  /* FROM clause - points to the beginning of the TableList::next_local list. */
 
526
  /* FROM clause - points to the beginning of the TABLE_LIST::next_local list. */
508
527
  SQL_LIST            table_list;
509
528
  SQL_LIST            group_list; /* GROUP BY clause. */
510
529
  List<Item>          item_list;  /* list of fields & expressions */
517
536
  List<Item_real_func> *ftfunc_list;
518
537
  List<Item_real_func> ftfunc_list_alloc;
519
538
  JOIN *join; /* after JOIN::prepare it is pointer to corresponding JOIN */
520
 
  List<TableList> top_join_list; /* join list of the top level          */
521
 
  List<TableList> *join_list;    /* list for the currently parsed join  */
522
 
  TableList *embedding;          /* table embedding to the above list   */
523
 
  List<TableList> sj_nests;
 
539
  List<TABLE_LIST> top_join_list; /* join list of the top level          */
 
540
  List<TABLE_LIST> *join_list;    /* list for the currently parsed join  */
 
541
  TABLE_LIST *embedding;          /* table embedding to the above list   */
 
542
  List<TABLE_LIST> sj_nests;
524
543
  /*
525
544
    Beginning of the list of leaves in a FROM clause, where the leaves
526
545
    inlcude all base tables including view tables. The tables are connected
527
 
    by TableList::next_leaf, so leaf_tables points to the left-most leaf.
 
546
    by TABLE_LIST::next_leaf, so leaf_tables points to the left-most leaf.
528
547
  */
529
 
  TableList *leaf_tables;
 
548
  TABLE_LIST *leaf_tables;
530
549
  const char *type;               /* type of select for EXPLAIN          */
531
550
 
532
551
  SQL_LIST order_list;                /* ORDER clause */
540
559
    bigger then can be number of entries that will be added to all item
541
560
    list during split_sum_func
542
561
  */
543
 
  uint32_t select_n_having_items;
544
 
  uint32_t cond_count;    /* number of arguments of and/or/xor in where/having/on */
545
 
  uint32_t between_count; /* number of between predicates in where/having/on      */
546
 
  uint32_t max_equal_elems; /* maximal number of elements in multiple equalities  */   
 
562
  uint select_n_having_items;
 
563
  uint cond_count;    /* number of arguments of and/or/xor in where/having/on */
 
564
  uint between_count; /* number of between predicates in where/having/on      */
 
565
  uint max_equal_elems; /* maximal number of elements in multiple equalities  */   
547
566
  /*
548
567
    Number of fields used in select list or where clause of current select
549
568
    and all inner subselects.
550
569
  */
551
 
  uint32_t select_n_where_fields;
 
570
  uint select_n_where_fields;
552
571
  enum_parsing_place parsing_place; /* where we are parsing expression */
553
572
  bool with_sum_func;   /* sum function indicator */
554
573
  /* 
557
576
  */
558
577
  bool conds_processed_with_permanent_arena;
559
578
 
560
 
  uint32_t table_join_options;
561
 
  uint32_t in_sum_expr;
562
 
  uint32_t select_number; /* number of select (used for EXPLAIN) */
 
579
  ulong table_join_options;
 
580
  uint in_sum_expr;
 
581
  uint select_number; /* number of select (used for EXPLAIN) */
563
582
  int nest_level;     /* nesting level of select */
564
583
  Item_sum *inner_sum_func_list; /* list of sum func in nested selects */ 
565
 
  uint32_t with_wild; /* item list contain '*' */
 
584
  uint with_wild; /* item list contain '*' */
566
585
  bool  braces;         /* SELECT ... UNION (SELECT ... ) <- this braces */
567
586
  /* true when having fix field called in processing of this SELECT */
568
587
  bool having_fix_field;
569
588
  /* List of references to fields referenced from inner selects */
570
589
  List<Item_outer_ref> inner_refs_list;
571
590
  /* Number of Item_sum-derived objects in this SELECT */
572
 
  uint32_t n_sum_items;
 
591
  uint n_sum_items;
573
592
  /* Number of Item_sum-derived objects in children and descendant SELECTs */
574
 
  uint32_t n_child_sum_items;
 
593
  uint n_child_sum_items;
575
594
 
576
595
  /* explicit LIMIT clause was used */
577
596
  bool explicit_limit;
582
601
  bool subquery_in_having;
583
602
  /* true <=> this SELECT is correlated w.r.t. some ancestor select */
584
603
  bool is_correlated;
 
604
  /*
 
605
    This variable is required to ensure proper work of subqueries and
 
606
    stored procedures. Generally, one should use the states of
 
607
    Query_arena to determine if it's a statement prepare or first
 
608
    execution of a stored procedure. However, in case when there was an
 
609
    error during the first execution of a stored procedure, the SP body
 
610
    is not expelled from the SP cache. Therefore, a deeply nested
 
611
    subquery might be left unoptimized. So we need this per-subquery
 
612
    variable to inidicate the optimization/execution state of every
 
613
    subquery. Prepared statements work OK in that regard, as in
 
614
    case of an error during prepare the PS is not created.
 
615
  */
 
616
  bool first_execution;
 
617
  bool first_cond_optimization;
 
618
  /* do not wrap view fields with Item_ref */
 
619
  bool no_wrap_view_item;
585
620
  /* exclude this select from check of unique_table() */
586
621
  bool exclude_from_table_unique_test;
587
622
  /* List of fields that aren't under an aggregate function */
593
628
  /* 
594
629
    This is a copy of the original JOIN USING list that comes from
595
630
    the parser. The parser :
596
 
      1. Sets the natural_join of the second TableList in the join
 
631
      1. Sets the natural_join of the second TABLE_LIST in the join
597
632
         and the st_select_lex::prev_join_using.
598
 
      2. Makes a parent TableList and sets its is_natural_join/
 
633
      2. Makes a parent TABLE_LIST and sets its is_natural_join/
599
634
       join_using_fields members.
600
 
      3. Uses the wrapper TableList as a table in the upper level.
 
635
      3. Uses the wrapper TABLE_LIST as a table in the upper level.
601
636
    We cannot assign directly to join_using_fields in the parser because
602
 
    at stage (1.) the parent TableList is not constructed yet and
 
637
    at stage (1.) the parent TABLE_LIST is not constructed yet and
603
638
    the assignment will override the JOIN USING fields of the lower level
604
639
    joins on the right.
605
640
  */
613
648
      1 - aggregate functions are used in this select,
614
649
          defined as SUM_FUNC_USED.
615
650
  */
616
 
  uint8_t full_group_by_flag;
 
651
  uint8 full_group_by_flag;
617
652
  void init_query();
618
653
  void init_select();
619
654
  st_select_lex_unit* master_unit();
640
675
 
641
676
  bool set_braces(bool value);
642
677
  bool inc_in_sum_expr();
643
 
  uint32_t get_in_sum_expr();
 
678
  uint get_in_sum_expr();
644
679
 
645
680
  bool add_item_to_list(THD *thd, Item *item);
646
681
  bool add_group_to_list(THD *thd, Item *item, bool asc);
647
682
  bool add_order_to_list(THD *thd, Item *item, bool asc);
648
 
  TableList* add_table_to_list(THD *thd, Table_ident *table,
 
683
  TABLE_LIST* add_table_to_list(THD *thd, Table_ident *table,
649
684
                                LEX_STRING *alias,
650
 
                                uint32_t table_options,
 
685
                                ulong table_options,
651
686
                                thr_lock_type flags= TL_UNLOCK,
652
687
                                List<Index_hint> *hints= 0,
653
688
                                LEX_STRING *option= 0);
654
 
  TableList* get_table_list();
 
689
  TABLE_LIST* get_table_list();
655
690
  bool init_nested_join(THD *thd);
656
 
  TableList *end_nested_join(THD *thd);
657
 
  TableList *nest_last_join(THD *thd);
658
 
  void add_joined_table(TableList *table);
659
 
  TableList *convert_right_join();
 
691
  TABLE_LIST *end_nested_join(THD *thd);
 
692
  TABLE_LIST *nest_last_join(THD *thd);
 
693
  void add_joined_table(TABLE_LIST *table);
 
694
  TABLE_LIST *convert_right_join();
660
695
  List<Item>* get_item_list();
661
 
  uint32_t get_table_join_options();
 
696
  ulong get_table_join_options();
662
697
  void set_lock_for_tables(thr_lock_type lock_type);
663
698
  inline void init_order()
664
699
  {
665
700
    order_list.elements= 0;
666
701
    order_list.first= 0;
667
 
    order_list.next= (unsigned char**) &order_list.first;
 
702
    order_list.next= (uchar**) &order_list.first;
668
703
  }
669
704
  /*
670
705
    This method created for reiniting LEX in mysql_admin_table() and can be
682
717
    init_query();
683
718
    init_select();
684
719
  }
685
 
  bool setup_ref_array(THD *thd, uint32_t order_group_num);
 
720
  bool setup_ref_array(THD *thd, uint order_group_num);
686
721
  void print(THD *thd, String *str, enum_query_type query_type);
687
722
  static void print_order(String *str,
688
 
                          order_st *order,
 
723
                          ORDER *order,
689
724
                          enum_query_type query_type);
690
725
  void print_limit(THD *thd, String *str, enum_query_type query_type);
691
726
  void fix_prepare_information(THD *thd, Item **conds, Item **having_conds);
706
741
   Add a index hint to the tagged list of hints. The type and clause of the
707
742
   hint will be the current ones (set by set_index_hint()) 
708
743
  */
709
 
  bool add_index_hint (THD *thd, char *str, uint32_t length);
 
744
  bool add_index_hint (THD *thd, char *str, uint length);
710
745
 
711
746
  /* make a list to hold index hints */
712
747
  void alloc_index_hints (THD *thd);
757
792
#define ALTER_FOREIGN_KEY         (1L << 31)
758
793
 
759
794
/**
760
 
  @brief Parsing data for CREATE or ALTER Table.
 
795
  @brief Parsing data for CREATE or ALTER TABLE.
761
796
 
762
797
  This structure contains a list of columns or indexes to be created,
763
798
  altered or dropped.
770
805
  List<Alter_column>            alter_list;
771
806
  List<Key>                     key_list;
772
807
  List<Create_field>            create_list;
773
 
  uint32_t                          flags;
 
808
  uint                          flags;
774
809
  enum enum_enable_or_disable   keys_onoff;
775
810
  enum tablespace_op_type       tablespace_op;
776
 
  uint32_t                          no_parts;
 
811
  uint                          no_parts;
777
812
  enum ha_build_method          build_method;
778
813
  Create_field                 *datetime_field;
779
814
  bool                          error_if_not_empty;
830
865
{
831
866
public:
832
867
  /* Global list of all tables used by this statement */
833
 
  TableList *query_tables;
 
868
  TABLE_LIST *query_tables;
834
869
  /* Pointer to next_global member of last element in the previous list. */
835
 
  TableList **query_tables_last;
 
870
  TABLE_LIST **query_tables_last;
836
871
  /*
837
872
    If non-0 then indicates that query requires prelocking and points to
838
873
    next_global member of last own element in query table list (i.e. last
839
874
    table which was not added to it as part of preparation to prelocking).
840
875
    0 - indicates that this query does not need prelocking.
841
876
  */
842
 
  TableList **query_tables_own_last;
 
877
  TABLE_LIST **query_tables_own_last;
843
878
  /*
844
879
    Set of stored routines called by statement.
845
880
    (Note that we use lazy-initialization for this hash).
856
891
    in which it was right after query parsing.
857
892
  */
858
893
  SQL_LIST sroutines_list;
859
 
  unsigned char    **sroutines_list_own_last;
860
 
  uint32_t     sroutines_list_own_elements;
 
894
  uchar    **sroutines_list_own_last;
 
895
  uint     sroutines_list_own_elements;
861
896
 
862
897
  /*
863
898
    These constructor and destructor serve for creation/destruction
879
914
    If you are using this function, you must ensure that the table
880
915
    object, in particular table->db member, is initialized.
881
916
  */
882
 
  void add_to_query_tables(TableList *table)
 
917
  void add_to_query_tables(TABLE_LIST *table)
883
918
  {
884
919
    *(table->prev_global= query_tables_last)= table;
885
920
    query_tables_last= &table->next_global;
886
921
  }
887
922
  /* Return pointer to first not-own table in query-tables or 0 */
888
 
  TableList* first_not_own_table()
 
923
  TABLE_LIST* first_not_own_table()
889
924
  {
890
925
    return ( query_tables_own_last ? *query_tables_own_last : 0);
891
926
  }
939
974
    a reliable binlog/replication, or if we will use stored functions
940
975
    or triggers which themselves need require row-based binlogging.
941
976
  */
942
 
  uint32_t binlog_stmt_flags;
 
977
  uint32 binlog_stmt_flags;
943
978
};
944
979
 
945
980
 
1207
1242
  }
1208
1243
 
1209
1244
  /** Get the length of the current token, in the raw buffer. */
1210
 
  uint32_t yyLength()
 
1245
  uint yyLength()
1211
1246
  {
1212
1247
    /*
1213
1248
      The assumption is that the lexical analyser is always 1 character ahead,
1214
1249
      which the -1 account for.
1215
1250
    */
1216
1251
    assert(m_ptr > m_tok_start);
1217
 
    return (uint32_t) ((m_ptr - m_tok_start) - 1);
 
1252
    return (uint) ((m_ptr - m_tok_start) - 1);
1218
1253
  }
1219
1254
 
1220
1255
  /** Get the utf8-body string. */
1224
1259
  }
1225
1260
 
1226
1261
  /** Get the utf8-body length. */
1227
 
  uint32_t get_body_utf8_length()
 
1262
  uint get_body_utf8_length()
1228
1263
  {
1229
1264
    return m_body_utf8_ptr - m_body_utf8;
1230
1265
  }
1234
1269
  void body_utf8_append(const char *ptr, const char *end_ptr);
1235
1270
  void body_utf8_append_literal(THD *thd,
1236
1271
                                const LEX_STRING *txt,
1237
 
                                const CHARSET_INFO * const txt_cs,
 
1272
                                CHARSET_INFO *txt_cs,
1238
1273
                                const char *end_ptr);
1239
1274
 
1240
1275
  /** Current thread. */
1241
1276
  THD *m_thd;
1242
1277
 
1243
1278
  /** Current line number. */
1244
 
  uint32_t yylineno;
 
1279
  uint yylineno;
1245
1280
 
1246
1281
  /** Length of the last token parsed. */
1247
 
  uint32_t yytoklen;
 
1282
  uint yytoklen;
1248
1283
 
1249
1284
  /** Interface with bison, value of the last token parsed. */
1250
1285
  LEX_YYSTYPE yylval;
1275
1310
  const char *m_buf;
1276
1311
 
1277
1312
  /** Length of the raw buffer. */
1278
 
  uint32_t m_buf_length;
 
1313
  uint m_buf_length;
1279
1314
 
1280
1315
  /** Echo the parsed stream to the pre-processed buffer. */
1281
1316
  bool m_echo;
1328
1363
  const char *found_semicolon;
1329
1364
 
1330
1365
  /** Token character bitmaps, to detect 7bit strings. */
1331
 
  unsigned char tok_bitmap;
 
1366
  uchar tok_bitmap;
1332
1367
 
1333
1368
  /** SQL_MODE = IGNORE_SPACE. */
1334
1369
  bool ignore_space;
1335
1370
 
 
1371
  /**
 
1372
    true if we're parsing a prepared statement: in this mode
 
1373
    we should allow placeholders and disallow multi-statements.
 
1374
  */
 
1375
  bool stmt_prepare_mode;
 
1376
 
1336
1377
  /** State of the lexical analyser for comments. */
1337
1378
  enum_comment_state in_comment;
1338
1379
 
1357
1398
 
1358
1399
    NOTE: this member must be used within MYSQLlex() function only.
1359
1400
  */
1360
 
  const CHARSET_INFO *m_underscore_cs;
 
1401
  CHARSET_INFO *m_underscore_cs;
1361
1402
};
1362
1403
 
1363
1404
 
1375
1416
  char *length,*dec,*change;
1376
1417
  LEX_STRING name;
1377
1418
  char *help_arg;
 
1419
  LEX_STRING backup_dir;                                /* For RESTORE/BACKUP */
1378
1420
  char* to_log;                                 /* For PURGE MASTER LOGS TO */
1379
1421
  char* x509_subject,*x509_issuer,*ssl_cipher;
1380
1422
  String *wild;
1383
1425
  Item *default_value, *on_update_value;
1384
1426
  LEX_STRING comment, ident;
1385
1427
  XID *xid;
1386
 
  unsigned char* yacc_yyss, *yacc_yyvs;
 
1428
  uchar* yacc_yyss, *yacc_yyvs;
1387
1429
  THD *thd;
1388
1430
 
1389
1431
  /* maintain a list of used plugins for this LEX */
1390
1432
  DYNAMIC_ARRAY plugins;
1391
1433
  plugin_ref plugins_static_buffer[INITIAL_LEX_PLUGIN_LIST_SIZE];
1392
1434
 
1393
 
  const CHARSET_INFO *charset;
 
1435
  CHARSET_INFO *charset;
1394
1436
  bool text_string_is_7bit;
1395
1437
  /* store original leaf_tables for INSERT SELECT and PS/SP */
1396
 
  TableList *leaf_tables_insert;
 
1438
  TABLE_LIST *leaf_tables_insert;
1397
1439
 
1398
1440
  List<Key_part_spec> col_list;
1399
1441
  List<Key_part_spec> ref_list;
1400
1442
  List<String>        interval_list;
 
1443
  List<LEX_USER>      users_list;
1401
1444
  List<LEX_COLUMN>    columns;
1402
1445
  List<Item>          *insert_list,field_list,value_list,update_list;
1403
1446
  List<List_item>     many_values;
1404
1447
  List<set_var_base>  var_list;
1405
1448
  List<Item_param>    param_list;
 
1449
  List<LEX_STRING>    view_list; // view list (list of field names in view)
1406
1450
  /*
1407
1451
    A stack of name resolution contexts for the query. This stack is used
1408
1452
    at parse time to set local name resolution contexts for various parts
1428
1472
  KEY_CREATE_INFO key_create_info;
1429
1473
  LEX_MASTER_INFO mi;                           // used by CHANGE MASTER
1430
1474
  LEX_SERVER_OPTIONS server_options;
1431
 
  uint32_t type;
 
1475
  USER_RESOURCES mqh;
 
1476
  ulong type;
1432
1477
  /*
1433
1478
    This variable is used in post-parse stage to declare that sum-functions,
1434
1479
    or functions which have sense only if GROUP BY is present, are allowed.
1455
1500
  union {
1456
1501
    enum ha_rkey_function ha_rkey_mode;
1457
1502
    enum xa_option_words xa_opt;
1458
 
    bool lock_transactional;            /* For LOCK Table ... IN ... MODE */
 
1503
    bool lock_transactional;            /* For LOCK TABLE ... IN ... MODE */
1459
1504
  };
1460
1505
  enum enum_var_type option_type;
 
1506
  enum enum_drop_mode drop_mode;
1461
1507
 
1462
 
  uint32_t profile_query_id;
1463
 
  uint32_t profile_options;
 
1508
  uint profile_query_id;
 
1509
  uint profile_options;
1464
1510
  enum column_format_type column_format;
1465
 
  uint32_t which_columns;
 
1511
  uint which_columns;
1466
1512
  enum Foreign_key::fk_match_opt fk_match_option;
1467
1513
  enum Foreign_key::fk_option fk_update_opt;
1468
1514
  enum Foreign_key::fk_option fk_delete_opt;
1469
 
  uint32_t slave_thd_opt, start_transaction_opt;
 
1515
  uint slave_thd_opt, start_transaction_opt;
1470
1516
  int nest_level;
1471
1517
  /*
1472
1518
    In LEX representing update which were transformed to multi-update
1473
1519
    stores total number of tables. For LEX representing multi-delete
1474
1520
    holds number of tables from which we will delete records.
1475
1521
  */
1476
 
  uint32_t table_count;
1477
 
  uint8_t describe;
 
1522
  uint table_count;
 
1523
  uint8 describe;
1478
1524
  /*
1479
1525
    A flag that indicates what kinds of derived tables are present in the
1480
1526
    query (0 if no derived tables, otherwise DERIVED_SUBQUERY).
1481
1527
  */
1482
 
  uint8_t derived_tables;
 
1528
  uint8 derived_tables;
1483
1529
  bool drop_if_exists, drop_temporary, local_file, one_shot_set;
1484
1530
  bool autocommit;
1485
 
  bool verbose;
 
1531
  bool verbose, no_write_to_binlog;
1486
1532
 
1487
1533
  bool tx_chain, tx_release;
 
1534
  /*
 
1535
    Special JOIN::prepare mode: changing of query is prohibited.
 
1536
    When creating a view, we need to just check its syntax omitting
 
1537
    any optimizations: afterwards definition of the view will be
 
1538
    reconstructed by means of ::print() methods and written to
 
1539
    to an .frm file. We need this definition to stay untouched.
 
1540
  */
 
1541
  bool view_prepare_mode;
1488
1542
  bool subqueries, ignore;
1489
1543
  st_parsing_options parsing_options;
1490
1544
  Alter_info alter_info;
1522
1576
    delete_dynamic(&plugins);
1523
1577
  }
1524
1578
 
1525
 
  TableList *unlink_first_table(bool *link_to_local);
1526
 
  void link_first_table_back(TableList *first, bool link_to_local);
 
1579
  TABLE_LIST *unlink_first_table(bool *link_to_local);
 
1580
  void link_first_table_back(TABLE_LIST *first, bool link_to_local);
1527
1581
  void first_lists_tables_same();
1528
1582
 
1529
1583
  bool can_be_merged();
1531
1585
  bool can_not_use_merged();
1532
1586
  bool only_view_structure();
1533
1587
  bool need_correct_ident();
 
1588
  uint8 get_effective_with_check(TABLE_LIST *view);
 
1589
  /*
 
1590
    Is this update command where 'WHITH CHECK OPTION' clause is important
 
1591
 
 
1592
    SYNOPSIS
 
1593
      st_lex::which_check_option_applicable()
 
1594
 
 
1595
    RETURN
 
1596
      true   have to take 'WHITH CHECK OPTION' clause into account
 
1597
      false  'WHITH CHECK OPTION' clause do not need
 
1598
  */
 
1599
  inline bool which_check_option_applicable()
 
1600
  {
 
1601
    switch (sql_command) {
 
1602
    case SQLCOM_UPDATE:
 
1603
    case SQLCOM_UPDATE_MULTI:
 
1604
    case SQLCOM_INSERT:
 
1605
    case SQLCOM_INSERT_SELECT:
 
1606
    case SQLCOM_REPLACE:
 
1607
    case SQLCOM_REPLACE_SELECT:
 
1608
    case SQLCOM_LOAD:
 
1609
      return true;
 
1610
    default:
 
1611
      return false;
 
1612
    }
 
1613
  }
1534
1614
 
1535
1615
  void cleanup_after_one_table_open();
1536
1616
 
1591
1671
  }
1592
1672
  static void *operator new(size_t size, MEM_ROOT *mem_root) throw()
1593
1673
  {
1594
 
    return (void*) alloc_root(mem_root, (uint32_t) size);
 
1674
    return (void*) alloc_root(mem_root, (uint) size);
1595
1675
  }
1596
 
  static void operator delete(void *ptr __attribute__((unused)),
1597
 
                              size_t size __attribute__((unused)))
 
1676
  static void operator delete(void *ptr __attribute__((__unused__)),
 
1677
                              size_t size __attribute__((__unused__)))
1598
1678
  { TRASH(ptr, size); }
1599
 
  static void operator delete(void *ptr __attribute__((unused)),
1600
 
                              MEM_ROOT *mem_root __attribute__((unused)))
 
1679
  static void operator delete(void *ptr __attribute__((__unused__)),
 
1680
                              MEM_ROOT *mem_root __attribute__((__unused__)))
1601
1681
  { /* Never called */ }
1602
1682
};
1603
1683
 
1606
1686
extern void lex_start(THD *thd);
1607
1687
extern void lex_end(LEX *lex);
1608
1688
 
1609
 
extern void trim_whitespace(const CHARSET_INFO * const cs, LEX_STRING *str);
 
1689
extern void trim_whitespace(CHARSET_INFO *cs, LEX_STRING *str);
1610
1690
 
1611
1691
extern bool is_lex_native_function(const LEX_STRING *name);
1612
1692
 
1614
1694
  @} (End of group Semantic_Analysis)
1615
1695
*/
1616
1696
 
1617
 
#endif /* DRIZZLE_SERVER */
1618
 
#endif /* DRIZZLE_SERVER_SQL_LEX_H */
 
1697
#endif /* MYSQL_SERVER */