~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Brian Aker
  • Date: 2011-01-21 20:44:06 UTC
  • mto: This revision was merged to the branch mainline in revision 2102.
  • Revision ID: brian@tangent.org-20110121204406-t7sbaproqbxnpki5
Additional parser cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
#define DRIZZLE_YYABORT_UNLESS(A)         \
68
68
  if (!(A))                             \
69
69
  {                                     \
70
 
    struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };\
 
70
    parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };\
71
71
    parser::my_parse_error(&pass);\
72
72
    DRIZZLE_YYABORT;                      \
73
73
  }
90
90
}
91
91
 
92
92
 
93
 
static bool check_reserved_words(LEX_STRING *name)
94
 
{
95
 
  if (!my_strcasecmp(system_charset_info, name->str, "GLOBAL") ||
96
 
      !my_strcasecmp(system_charset_info, name->str, "LOCAL") ||
97
 
      !my_strcasecmp(system_charset_info, name->str, "SESSION"))
98
 
    return true;
99
 
  return false;
100
 
}
101
 
 
102
93
/**
103
94
  @brief Bison callback to report a syntax/OOM error
104
95
 
134
125
  if (strcmp(s,"parse error") == 0 || strcmp(s,"syntax error") == 0)
135
126
    s= ER(ER_SYNTAX_ERROR);
136
127
 
137
 
  struct my_parse_error_st pass= { s, session };
 
128
  parser::error_t pass= { s, session };
138
129
  parser::my_parse_error(&pass);
139
130
}
140
131
 
161
152
  drizzled::Key_part_spec *key_part;
162
153
  const drizzled::plugin::Function *udf;
163
154
  drizzled::TableList *table_list;
164
 
  enum drizzled::enum_field_types field_val;
165
 
  struct drizzled::sys_var_with_base variable;
166
 
  enum drizzled::sql_var_t var_type;
 
155
  drizzled::enum_field_types field_val;
 
156
  drizzled::sys_var_with_base variable;
 
157
  drizzled::sql_var_t var_type;
167
158
  drizzled::Key::Keytype key_type;
168
 
  enum drizzled::ha_key_alg key_alg;
169
 
  enum drizzled::ha_rkey_function ha_rkey_mode;
170
 
  enum drizzled::enum_tx_isolation tx_isolation;
171
 
  enum drizzled::Cast_target cast_type;
 
159
  drizzled::ha_key_alg key_alg;
 
160
  drizzled::ha_rkey_function ha_rkey_mode;
 
161
  drizzled::enum_tx_isolation tx_isolation;
 
162
  drizzled::Cast_target cast_type;
172
163
  const drizzled::CHARSET_INFO *charset;
173
164
  drizzled::thr_lock_type lock_type;
174
165
  drizzled::interval_type interval, interval_time_st;
175
 
  enum drizzled::enum_drizzle_timestamp_type date_time_type;
 
166
  drizzled::enum_drizzle_timestamp_type date_time_type;
176
167
  drizzled::Select_Lex *select_lex;
177
168
  drizzled::chooser_compare_func_creator boolfunc2creator;
178
 
  struct drizzled::st_lex *lex;
179
 
  enum drizzled::index_hint_type index_hint;
180
 
  enum drizzled::enum_filetype filetype;
181
 
  enum drizzled::ha_build_method build_method;
 
169
  drizzled::st_lex *lex;
 
170
  drizzled::index_hint_type index_hint;
 
171
  drizzled::enum_filetype filetype;
 
172
  drizzled::ha_build_method build_method;
182
173
  drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption m_fk_option;
183
174
  drizzled::execute_string_t execute_string;
184
175
}
2279
2270
            Select_Lex * sel= Lex->current_select;
2280
2271
            if (Lex->current_select->set_braces(0))
2281
2272
            {
2282
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
2273
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
2283
2274
              parser::my_parse_error(&pass);
2284
2275
              DRIZZLE_YYABORT;
2285
2276
            }
2286
2277
            if (sel->linkage == UNION_TYPE &&
2287
2278
                sel->master_unit()->first_select()->braces)
2288
2279
            {
2289
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
2280
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
2290
2281
              parser::my_parse_error(&pass);
2291
2282
              DRIZZLE_YYABORT;
2292
2283
            }
3285
3276
        | '@' opt_var_ident_type user_variable_ident opt_component
3286
3277
          {
3287
3278
            /* disallow "SELECT @@global.global.variable" */
3288
 
            if ($3.str && $4.str && check_reserved_words(&$3))
 
3279
            if ($3.str && $4.str && parser::check_reserved_words(&$3))
3289
3280
            {
3290
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3281
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3291
3282
              parser::my_parse_error(&pass);
3292
3283
              DRIZZLE_YYABORT;
3293
3284
            }
3329
3320
          {
3330
3321
            if (Lex->current_select->inc_in_sum_expr())
3331
3322
            {
3332
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3323
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3333
3324
              parser::my_parse_error(&pass);
3334
3325
              DRIZZLE_YYABORT;
3335
3326
            }
3617
3608
            {
3618
3609
              if (sel->set_braces(1))
3619
3610
              {
3620
 
                struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3611
                parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3621
3612
                parser::my_parse_error(&pass);
3622
3613
                DRIZZLE_YYABORT;
3623
3614
              }
3682
3673
            else if (($3->select_lex && $3->select_lex->master_unit()->is_union()) || $5)
3683
3674
            {
3684
3675
              /* simple nested joins cannot have aliases or unions */
3685
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3676
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3686
3677
              parser::my_parse_error(&pass);
3687
3678
              DRIZZLE_YYABORT;
3688
3679
            }
3718
3709
            Select_Lex * sel= Lex->current_select;
3719
3710
            if (Lex->current_select->set_braces(0))
3720
3711
            {
3721
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3712
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3722
3713
              parser::my_parse_error(&pass);
3723
3714
              DRIZZLE_YYABORT;
3724
3715
            }
3725
3716
            if (sel->linkage == UNION_TYPE &&
3726
3717
                sel->master_unit()->first_select()->braces)
3727
3718
            {
3728
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3719
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3729
3720
              parser::my_parse_error(&pass);
3730
3721
              DRIZZLE_YYABORT;
3731
3722
            }
3763
3754
              DRIZZLE_YYABORT;
3764
3755
            if (!$3 && $$)
3765
3756
            {
3766
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3757
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3767
3758
              parser::my_parse_error(&pass);
3768
3759
              DRIZZLE_YYABORT;
3769
3760
            }
3775
3766
            Lex->derived_tables|= DERIVED_SUBQUERY;
3776
3767
            if (not Lex->expr_allows_subselect)
3777
3768
            {
3778
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3769
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3779
3770
              parser::my_parse_error(&pass);
3780
3771
              DRIZZLE_YYABORT;
3781
3772
            }
3804
3795
            if (!sel->embedding || sel->end_nested_join(Lex->session))
3805
3796
            {
3806
3797
              /* we are not in parentheses */
3807
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
3798
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
3808
3799
              parser::my_parse_error(&pass);
3809
3800
              DRIZZLE_YYABORT;
3810
3801
            }
5862
5853
          {
5863
5854
            if (not Lex->expr_allows_subselect)
5864
5855
            {
5865
 
              struct my_parse_error_st pass= { ER(ER_SYNTAX_ERROR), YYSession };
 
5856
              parser::error_t pass= { ER(ER_SYNTAX_ERROR), YYSession };
5866
5857
              parser::my_parse_error(&pass);
5867
5858
              DRIZZLE_YYABORT;
5868
5859
            }