package SQL::Translator::Parser::MySQL;
# -------------------------------------------------------------------
-# $Id: MySQL.pm,v 1.14 2003-04-07 16:27:30 dlc Exp $
+# $Id: MySQL.pm,v 1.15 2003-04-30 21:58:40 kycl4rk Exp $
# -------------------------------------------------------------------
# Copyright (C) 2003 Ken Y. Clark <kclark@cpan.org>,
# darren chamberlain <darren@cpan.org>,
use strict;
use vars qw[ $DEBUG $VERSION $GRAMMAR @EXPORT_OK ];
-$VERSION = sprintf "%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/;
+$VERSION = sprintf "%d.%02d", q$Revision: 1.15 $ =~ /(\d+)\.(\d+)/;
$DEBUG = 0 unless defined $DEBUG;
use Data::Dumper;
}
}
- for my $opt ( @{ $item{'table_option'} } ) {
+ for my $opt ( @{ $item{'table_option(s?)'} } ) {
if ( my ( $key, $val ) = each %$opt ) {
$tables{ $table_name }{'table_options'}{ $key } = $val;
}
}
+
+ 1;
}
create : /CREATE/i unique(?) /(INDEX|KEY)/i index_name /on/i table_name '(' field_name(s /,/) ')' ';'
field : field_name data_type field_qualifier(s?) reference_definition(?)
{
- my %qualifiers = map { %$_ } @{ $item{'field_qualifier'} || [] };
+ my %qualifiers = map { %$_ } @{ $item{'field_qualifier(s?)'} || [] };
my $null = defined $item{'not_null'} ? $item{'not_null'} : 1;
delete $qualifiers{'not_null'};
if ( my @type_quals = @{ $item{'data_type'}{'qualifiers'} || [] } ) {
size => $item{'data_type'}{'size'},
list => $item{'data_type'}{'list'},
null => $null,
- constraints => $item{'reference_definition'},
+ constraints => $item{'reference_definition(?)'},
%qualifiers,
}
}
| unique_index
| fulltext_index
| normal_index
+ | <error>
table_name : WORD
primary_key_index : primary_key index_name(?) '(' field_name(s /,/) ')'
{
$return = {
- name => $item{'index_name'}[0],
+ name => $item{'index_name(?)'}[0],
type => 'primary_key',
fields => $item[4],
- }
+ };
}
normal_index : key index_name(?) '(' name_with_opt_paren(s /,/) ')'
{
$return = {
- name => $item{'index_name'}[0],
+ name => $item{'index_name(?)'}[0],
type => 'normal',
fields => $item[4],
}
unique_index : unique key(?) index_name(?) '(' name_with_opt_paren(s /,/) ')'
{
$return = {
- name => $item{'index_name'}[0],
+ name => $item{'index_name(?)'}[0],
type => 'unique',
fields => $item[5],
}
fulltext_index : fulltext key(?) index_name(?) '(' name_with_opt_paren(s /,/) ')'
{
$return = {
- name => $item{'index_name'}[0],
+ name => $item{'index_name(?)'}[0],
type => 'fulltext',
fields => $item[5],
}