File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -849,37 +849,43 @@ function parse_index_columns(&$tokens, &$index){
849849 }
850850
851851 function parse_index_options (&$ tokens , &$ index ){
852+
852853 # index_option:
853854 # KEY_BLOCK_SIZE [=] value
854855 # | index_type
855856 # | WITH PARSER parser_name
856857 # | COMMENT 'string'
857858
858- if (count ($ tokens ) >= 1 ){
859+ while (count ($ tokens ) >= 1 ){
860+
859861 if ($ tokens [0 ] == 'KEY_BLOCK_SIZE ' ){
860862 array_shift ($ tokens );
861863 if ($ tokens [0 ] == '= ' ) array_shift ($ tokens );
862864 $ index ['key_block_size ' ] = $ tokens [0 ];
863865 array_shift ($ tokens );
866+ continue ;
864867 }
865- }
866-
867- $ this ->parse_index_mode ($ tokens , $ index );
868868
869- if (count ($ tokens ) >= 1 ){
870869 if ($ tokens [0 ] == 'WITH PARSER ' ){
871870 $ index ['parser ' ] = $ tokens [1 ];
872871 array_shift ($ tokens );
873872 array_shift ($ tokens );
873+ continue ;
874874 }
875- }
876875
877- if (count ($ tokens ) >= 1 ){
878876 if ($ tokens [0 ] == 'COMMENT ' ){
879877 $ index ['comment ' ] = $ this ->decode_value ($ tokens [1 ]);
880878 array_shift ($ tokens );
881879 array_shift ($ tokens );
880+ continue ;
882881 }
882+
883+ if (!isset ($ index ['mode ' ])){
884+ $ this ->parse_index_mode ($ tokens , $ index );
885+ if (isset ($ index ['mode ' ])) continue ;
886+ }
887+
888+ break ;
883889 }
884890 }
885891
Original file line number Diff line number Diff line change @@ -155,6 +155,13 @@ function testIndexOptions(){
155155 # comment
156156 $ tbl = $ this ->get_first_table ("CREATE TABLE foo (bar INT, baz INT, PRIMARY KEY (bar) COMMENT \"hello world \") " );
157157 $ this ->assertEquals ($ tbl ['indexes ' ][0 ]['comment ' ], "hello world " );
158+
159+ # everything
160+ $ tbl = $ this ->get_first_table ("CREATE TABLE foo (bar INT, baz INT, PRIMARY KEY (bar) COMMENT \"hello world \" USING HASH KEY_BLOCK_SIZE=4 WITH PARSER foo) " );
161+ $ this ->assertEquals ($ tbl ['indexes ' ][0 ]['comment ' ], "hello world " );
162+ $ this ->assertEquals ($ tbl ['indexes ' ][0 ]['mode ' ], "HASH " );
163+ $ this ->assertEquals ($ tbl ['indexes ' ][0 ]['key_block_size ' ], "4 " );
164+ $ this ->assertEquals ($ tbl ['indexes ' ][0 ]['parser ' ], "foo " );
158165 }
159166
160167 function get_first_table ($ str ){
You can’t perform that action at this time.
0 commit comments