X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FParser%2FMySQL.pm;h=5383f74e2deb1364c8b39313806acce6fc32d5fc;hb=ba506e52c480afe33dfec6b38a12759fad1e7fa2;hp=c9cf42c863a16f50946a878ca2b182cbc398d0ef;hpb=f1fe509dbf01ab05e10edc5bafd6ccb23f389fd8;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Parser/MySQL.pm b/lib/SQL/Translator/Parser/MySQL.pm index c9cf42c..5383f74 100644 --- a/lib/SQL/Translator/Parser/MySQL.pm +++ b/lib/SQL/Translator/Parser/MySQL.pm @@ -147,7 +147,7 @@ More information about the MySQL comment-syntax: L[0], $item[3]->[0]) + . " $item[4] $item[5] $item[6]"; # Hack to strip database from function calls in SQL $sql =~ s#`\w+`\.(`\w+`\()##g; @@ -357,6 +358,8 @@ create : CREATE algorithm /view/i NAME not_delimiter "$delimiter" $views{ $view_name }{'sql'} = $sql; } +replace : /or replace/i + algorithm : /algorithm/i /=/ WORD { $return = "$item[1]=$item[3]"; @@ -591,19 +594,13 @@ 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' { $return = \$item[2]; } | - /default/i /'(?:.*?\\')*.*?'|(?:')?[\w\d:.-]*(?:')?/ + /default/i /'(?:.*?(?:\\'|''))*.*?'|(?:')?[\w\d:.-]*(?:')?/ { $item[2] =~ s/^\s*'|'\s*$//g; $return = $item[2]; @@ -664,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(?!using)\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 = { @@ -753,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] } | /'.*?'/ {