~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_yacc.yy

  • Committer: Monty Taylor
  • Date: 2008-10-13 10:14:09 UTC
  • mfrom: (383.7.6 drizzle-virtual-columns)
  • mto: This revision was merged to the branch mainline in revision 511.
  • Revision ID: monty@inaugust.com-20081013101409-aszm0nonww0f07zd
Merged in Virtual Column work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
678
678
%token  PAGE_SYM
679
679
%token  PAGE_CHECKSUM_SYM
680
680
%token  PARAM_MARKER
 
681
%token  PARSE_VCOL_EXPR_SYM
681
682
%token  PARTIAL                       /* SQL-2003-N */
682
683
%token  PHASE_SYM
683
684
%token  PLUGINS_SYM
776
777
%token  STD_SYM
777
778
%token  STOP_SYM
778
779
%token  STORAGE_SYM
 
780
%token  STORED_SYM
779
781
%token  STRAIGHT_JOIN
780
782
%token  STRING_SYM
781
783
%token  SUBDATE_SYM
841
843
%token  VARIANCE_SYM
842
844
%token  VARYING                       /* SQL-2003-R */
843
845
%token  VAR_SAMP_SYM
 
846
%token  VIRTUAL_SYM
844
847
%token  WAIT_SYM
845
848
%token  WARNINGS
846
849
%token  WEEK_SYM
892
895
        text_string opt_gconcat_separator
893
896
 
894
897
%type <num>
895
 
        type int_type real_type order_dir
 
898
        type int_type real_type order_dir field_def
896
899
        if_exists opt_local opt_table_options table_options
897
900
        table_option opt_if_not_exists
898
901
        opt_temporary all_or_any opt_distinct
1032
1035
        opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
1033
1036
        binlog_base64_event
1034
1037
        init_key_options key_options key_opts key_opt key_using_alg
 
1038
        parse_vcol_expr vcol_opt_attribute vcol_opt_attribute_list
 
1039
        vcol_attribute
1035
1040
END_OF_INPUT
1036
1041
 
1037
1042
%type <index_hint> index_hint_type
1107
1112
        | lock
1108
1113
        | optimize
1109
1114
        | keycache
 
1115
        | parse_vcol_expr
1110
1116
        | purge
1111
1117
        | release
1112
1118
        | rename
1708
1714
            lex->comment=null_lex_str;
1709
1715
            lex->charset=NULL;
1710
1716
            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
 
1717
            lex->vcol_info= NULL;
1711
1718
          }
1712
 
          type opt_attribute
 
1719
          field_def
1713
1720
          {
1714
1721
            LEX *lex=Lex;
1715
1722
            if (add_field_to_list(lex->thd, &$1, (enum enum_field_types) $3,
1717
1724
                                  lex->column_format,
1718
1725
                                  lex->default_value, lex->on_update_value, 
1719
1726
                                  &lex->comment,
1720
 
                                  lex->change,&lex->interval_list,lex->charset))
1721
 
              DRIZZLE_YYABORT;
 
1727
                                  lex->change,&lex->interval_list,lex->charset,
 
1728
                                  lex->vcol_info))
 
1729
              DRIZZLE_YYABORT;
 
1730
          }
 
1731
        ;
 
1732
field_def:
 
1733
          type opt_attribute {}
 
1734
        | VIRTUAL_SYM type AS '(' virtual_column_func ')' vcol_opt_attribute
 
1735
          {
 
1736
            $$=DRIZZLE_TYPE_VIRTUAL;
 
1737
            Lex->vcol_info->set_field_type((enum enum_field_types) $2);
 
1738
          }
 
1739
        ;
 
1740
 
 
1741
vcol_opt_attribute:
 
1742
          /* empty */ {}
 
1743
        | vcol_opt_attribute_list {}
 
1744
        ;
 
1745
 
 
1746
vcol_opt_attribute_list:
 
1747
          vcol_opt_attribute_list vcol_attribute {}
 
1748
        | vcol_attribute
 
1749
        ;
 
1750
 
 
1751
vcol_attribute:
 
1752
          UNIQUE_SYM
 
1753
          {
 
1754
            LEX *lex=Lex;
 
1755
            lex->type|= UNIQUE_FLAG; 
 
1756
            lex->alter_info.flags|= ALTER_ADD_INDEX;
 
1757
          }
 
1758
        | UNIQUE_SYM KEY_SYM
 
1759
          {
 
1760
            LEX *lex=Lex;
 
1761
            lex->type|= UNIQUE_KEY_FLAG; 
 
1762
            lex->alter_info.flags|= ALTER_ADD_INDEX; 
 
1763
          }
 
1764
        | COMMENT_SYM TEXT_STRING_sys { Lex->comment= $2; }
 
1765
        | STORED_SYM
 
1766
          {
 
1767
            Lex->vcol_info->set_field_stored(true);
 
1768
          }
 
1769
        ;
 
1770
 
 
1771
parse_vcol_expr:
 
1772
          PARSE_VCOL_EXPR_SYM '(' virtual_column_func ')'
 
1773
          {
 
1774
            /* 
 
1775
              "PARSE_VCOL_EXPR" can only be used by the SQL server
 
1776
              when reading a '*.frm' file.
 
1777
              Prevent the end user from invoking this command.
 
1778
            */
 
1779
            if (not Lex->parse_vcol_expr)
 
1780
            {
 
1781
              my_message(ER_SYNTAX_ERROR, ER(ER_SYNTAX_ERROR), MYF(0));
 
1782
              DRIZZLE_YYABORT;
 
1783
            }
 
1784
          }
 
1785
        ;
 
1786
 
 
1787
virtual_column_func:
 
1788
          remember_name expr remember_end
 
1789
          {
 
1790
            Lex->vcol_info= new virtual_column_info();
 
1791
            if (not Lex->vcol_info)
 
1792
            {
 
1793
              my_error(ER_OUTOFMEMORY, MYF(0), sizeof(virtual_column_info));
 
1794
              DRIZZLE_YYABORT;
 
1795
            }
 
1796
            uint expr_len= (uint)($3 - $1) - 1;
 
1797
            Lex->vcol_info->expr_str.str= (char* ) sql_memdup($1 + 1, expr_len);
 
1798
            Lex->vcol_info->expr_str.length= expr_len;
 
1799
            Lex->vcol_info->expr_item= $2;
1722
1800
          }
1723
1801
        ;
1724
1802
 
2323
2401
            lex->charset= NULL;
2324
2402
            lex->alter_info.flags|= ALTER_CHANGE_COLUMN;
2325
2403
            lex->column_format= COLUMN_FORMAT_TYPE_DEFAULT;
 
2404
            lex->vcol_info= NULL;
2326
2405
          }
2327
 
          type opt_attribute
 
2406
          field_def
2328
2407
          {
2329
2408
            LEX *lex=Lex;
2330
2409
            if (add_field_to_list(lex->thd,&$3,
2333
2412
                                  lex->column_format,
2334
2413
                                  lex->default_value, lex->on_update_value,
2335
2414
                                  &lex->comment,
2336
 
                                  $3.str, &lex->interval_list, lex->charset))
 
2415
                                  $3.str, &lex->interval_list, lex->charset,
 
2416
                                  lex->vcol_info))
2337
2417
              DRIZZLE_YYABORT;
2338
2418
          }
2339
2419
          opt_place