Skip Menu |

This queue is for tickets about the SQL-Translator CPAN distribution.

Report information
The Basics
Id: 78868
Status: new
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: fred.lindberg [...] yudoglobal.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Index_col_name not allowing (ASC|DESC)
Date: Thu, 9 Aug 2012 15:32:05 +0000 (UTC)
To: "bug-SQL-Translator [...] rt.cpan.org" <bug-sql-translator [...] rt.cpan.org>
From: Fred Lindberg <fred.lindberg [...] yudoglobal.com>
SQL-Translator-0.11012
Parser::MySQL.pm
3.2.0-27-generic-pae #43-Ubuntu
This is perl 5, version 14, subversion 2 (v5.14.2)

Hi, I am using your very helpful module to parse MySQL-workbench output DDL and trying to convert to Oracle DDL. Index clauses fail, because the field_name(s) specified have "ASC" following them and the module grammar does not allow for this.

Parsing fails for:
CREATE  TABLE IF NOT EXISTS `Ringfence` (
  `idRingfence` INT UNSIGNED NOT NULL ,
  `idUni` INT UNSIGNED NOT NULL ,
  `rfPublic` TINYINT(1) NOT NULL DEFAULT 0 ,
  `rfName` VARCHAR(255) NOT NULL ,
  `rfLabel` VARCHAR(255) NOT NULL ,
  PRIMARY KEY (`idUni`, `idRingfence`) ,
  UNIQUE INDEX `i_Ringfence_rfName` (`idUni` ASC, `rfName` ASC) )
ENGINE = InnoDB;

Parsing succeeds for (the two "ASC" removed):
CREATE  TABLE IF NOT EXISTS `Ringfence` (
  `idRingfence` INT UNSIGNED NOT NULL ,
  `idUni` INT UNSIGNED NOT NULL ,
  `rfPublic` TINYINT(1) NOT NULL DEFAULT 0 ,
  `rfName` VARCHAR(255) NOT NULL ,
  `rfLabel` VARCHAR(255) NOT NULL ,
  PRIMARY KEY (`idUni`, `idRingfence`) ,
  UNIQUE INDEX `i_Ringfence_rfName` (`idUni`, `rfName`) )
ENGINE = InnoDB;

From http://dev.mysql.com/doc/refman/5.1/en/create-table.html:
index_col_name:
    col_name [(length)] [ASC | DESC]

create_definition: col_name column_definition | [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...) [index_option] ... | {INDEX|KEY} [index_name] [index_type] (index_col_name,...) [index_option] ... | [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY] [index_name] [index_type] (index_col_name,...) [index_option] ... | {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...) [index_option] ... | [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name,...) reference_definition | CHECK (expr)
I don't understand Parse::RecDescent. However, if I change the grammar per below the first create statement parses as well.

table_name   : NAME

ORDER        : /(asc|desc)/i
index_field  : field_name ORDER

field_name   : NAME

FWIW, the MySQL manual also says:
  • An index_col_name specification can end with ASC or DESC. These keywords are permitted for future extensions for specifying ascending or descending index value storage. Currently, they are parsed but ignored; index values are always stored in ascending order.

so it seems fair to ignore the value.


Thanks!


Fred Lindberg