From: Ken Youens-Clark Date: Wed, 12 Aug 2009 15:03:19 +0000 (+0000) Subject: Added parsing of index types (btree, rtree, hash). X-Git-Tag: v0.11008~123 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd11d3c50dfe465dee8536af16930af5dfbad611;p=dbsrgits%2FSQL-Translator.git Added parsing of index types (btree, rtree, hash). --- diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index f560529..81b7d24 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -594,12 +594,6 @@ not_null : /not/i /null/i unsigned : /unsigned/i { $return = 0 } -#default_val : /default/i /(?:')?[\s\w\d:.-]*(?:')?/ -# { -# $item[2] =~ s/'//g; -# $return = $item[2]; -# } - default_val : /default/i 'CURRENT_TIMESTAMP' { @@ -667,16 +661,22 @@ unique_key_def : UNIQUE KEY(?) index_name(?) '(' name_with_opt_paren(s /,/) ')' } } -normal_index : KEY index_name(?) '(' name_with_opt_paren(s /,/) ')' +normal_index : KEY index_name_not_using(?) index_type(?) '(' name_with_opt_paren(s /,/) ')' { $return = { supertype => 'index', type => 'normal', - name => $item{'index_name(?)'}[0], - fields => $item[4], + name => $item[2][0], + fields => $item[5], + options => $item[3][0], } } +index_name_not_using : QUOTED_NAME + | /\b([^u][^s]?[^i]?[^n]?[^g]?\w*?)\b/ { $return = $1 } + +index_type : /using (btree|hash|rtree)/i { $return = uc $1 } + fulltext_index : /fulltext/i KEY(?) index_name(?) '(' name_with_opt_paren(s /,/) ')' { $return = { @@ -756,14 +756,15 @@ BACKTICK : '`' DOUBLE_QUOTE: '"' -NAME : BACKTICK /[^`]+/ BACKTICK +QUOTED_NAME : BACKTICK /[^`]+/ BACKTICK { $item[2] } | DOUBLE_QUOTE /[^"]+/ DOUBLE_QUOTE { $item[2] } - | /\w+/ - { $item[1] } -VALUE : /[-+]?\.?\d+(?:[eE]\d+)?/ +NAME: QUOTED_NAME + | /\w+/ + +VALUE : /[-+]?\.?\d+(?:[eE]\d+)?/ { $item[1] } | /'.*?'/ {