Skip Menu |
 

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

Report information
The Basics
Id: 83380
Status: patched
Priority: 0/
Queue: SQL-Translator

People
Owner: Nobody in particular
Requestors: chris+rt [...] chrisdolan.net
Cc:
AdminCc:

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



Subject: MySQL parser does not recognize a create with an embedded comment before an auto_increment
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 657
Download (untitled) / with headers
text/plain 657b
Consider the following SQL snippet: CREATE TABLE `city_hours` ( `id` integer(11) NOT NULL comment 'Each row is a datetime range during which Artists and Locations may book Performances for a given City.' auto_increment, `city_id` integer(11) NOT NULL ); SQL::Translator reports the following for that SQL: ERROR (line 1): Invalid statement: Was expecting comment, or use, or set, or drop, or create, or alter, or insert, or delimiter, or empty statement If I remove the "comment '.*'" clause, then it parses successfully. Other columns with comments are fine, just the auto_increment one fails.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-4972-1361045169-83.83380-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 514
Download (untitled) / with headers
text/plain 514b
I believe the error is that a comment is not considered a field_qualifier, by this definition: field : field_comment(s?) field_name data_type field_qualifier(s?) field_comment2(?) reference_definition(?) on_update(?) field_comment(s?) Really, I think the comment should be allowed to be interspersed between any other qualifiers rather than being treated specially as in the above rule.
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-4972-1361045169-83.83380-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-4972-1361045169-83.83380-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-16387-1361045472-594.83380-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 329
Download (untitled) / with headers
text/plain 329b
One last note I forgot to mention. The "faulty" SQL with the comment before the auto_increment came from the DBI translator, not from a hand-written schema. So another possible solution would be to alter that generator to make SQL that the parser can understand, although that's a less elegant solution than fixing the parser.
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-4972-1361045169-83.83380-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-4972-1361045169-83.83380-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-9192-1362811489-1827.83380-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 569
Download (untitled) / with headers
text/plain 569b
On Sat Feb 16 15:06:09 2013, CDOLAN wrote: Show quoted text
> I believe the error is that a comment is not considered a > field_qualifier, by this definition: > > field : field_comment(s?) field_name data_type field_qualifier(s?) > field_comment2(?) > reference_definition(?) on_update(?) field_comment(s?) >
I rather you insert more "field_comment" pieces in the grammar. Basically split the parsing into a: field_definition_chunk | field_comment And have P::RD loop over until it reaches the ; Care to package this up with a test addition to t/14postgres-parser.t ? Cheers
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-2084-1441619733-670.83380-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 324
Download (untitled) / with headers
text/plain 324b
Happens with a stock mysqldump call for me too: CREATE TABLE `gc_discount` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT ' ', ... ) ENGINE=InnoDB AUTO_INCREMENT=288 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; Happening in 0.11021; Removing COMMENT ' ' helps.
X-Amavis-Alert: BAD HEADER SECTION, Improper folded header field made up entirely of whitespace (char 20 hex): X-Exiscan-Spam-Report: ...ping.uio.no\n Score Rule\n \n * -5.0 PING_U[...]
CC: undisclosed-recipients:;
MIME-Version: 1.0
X-Spam-Status: No, score=-6.536 tagged_above=-99.9 required=10 tests=[AWL=1.664, BAYES_00=-1.9, FROM_OUR_RT=-4, RCVD_IN_DNSWL_MED=-2.3] autolearn=ham
In-Reply-To: <rt-4.0.18-2084-1441619733-946.83380-5-0 [...] rt.cpan.org> (Nicolas Mendoza via's message of "Mon, 7 Sep 2015 05:55:34 -0400")
X-Exiscan-Spam-Score: -3.7 (---)
X-Spam-Flag: NO
X-RT-Interface: API
References: <RT-Ticket-83380 [...] rt.cpan.org> <rt-4.0.18-2084-1441619733-946.83380-5-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <d8jd1xsg6xx.fsf [...] dalvik.ping.uio.no>
content-type: text/plain; charset="utf-8"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -6.536
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 0AE68240275 for <cpan-bug+SQL-Translator [...] hipster.bestpractical.com>; Tue, 8 Sep 2015 13:25:07 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gWG-HTje9c9F for <cpan-bug+SQL-Translator [...] hipster.bestpractical.com>; Tue, 8 Sep 2015 13:25:05 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id F3CF92401D6 for <bug-SQL-Translator [...] rt.cpan.org>; Tue, 8 Sep 2015 13:25:04 -0400 (EDT)
Received: (qmail 10554 invoked by alias); 8 Sep 2015 17:25:04 -0000
Received: from pike.ping.uio.no (HELO ping.uio.no) (193.157.115.208) by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Tue, 08 Sep 2015 10:24:59 -0700
Received: from [2001:700:100:570::211] (helo=dalvik.ping.uio.no ident=Debian-exim) by ping.uio.no with esmtp (Exim 4.72 #1 (Debian)) id 1ZZMdP-0006Qw-Et for <bug-SQL-Translator [...] rt.cpan.org>; Tue, 08 Sep 2015 19:24:45 +0200
Received: from ilmari by dalvik.ping.uio.no with local (Exim 4.72) (envelope-from <ilmari [...] ilmari.org>) id 1ZZMdO-0002L2-Cr for bug-SQL-Translator [...] rt.cpan.org; Tue, 08 Sep 2015 19:24:42 +0200
Delivered-To: cpan-bug+SQL-Translator [...] hipster.bestpractical.com
X-Exiscan-Spam-Report: SpamAssassin 3.3.1 (2010-03-16) on pike.ping.uio.no Score Rule * -5.0 PING_UIO_MAIL_IS_INTERNAL Message has never been outside * 129.240.0.0/16 or 193.157.115.0/24 * 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS
Subject: Re: [rt.cpan.org #83380] MySQL parser does not recognize a create with an embedded comment before an auto_increment
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)
Return-Path: <ilmari [...] ilmari.org>
X-Spam-Check-BY: la.mx.develooper.com
X-Original-To: cpan-bug+SQL-Translator [...] hipster.bestpractical.com
X-RT-Mail-Extension: sql-translator
Date: Tue, 08 Sep 2015 18:24:42 +0100
X-Spam-Level:
X-Quarantine-ID: <gWG-HTje9c9F>
To: bug-SQL-Translator [...] rt.cpan.org
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)
RT-Message-ID: <rt-4.0.18-27316-1441733107-1971.83380-0-0 [...] rt.cpan.org>
Content-Length: 1045
"Nicolas Mendoza via RT" <bug-SQL-Translator@rt.cpan.org> writes: Show quoted text
> Happens with a stock mysqldump call for me too: > > CREATE TABLE `gc_discount` ( > `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT ' ', > ... > ) ENGINE=InnoDB AUTO_INCREMENT=288 DEFAULT CHARSET=utf8; > /*!40101 SET character_set_client = @saved_cs_client */;
I can't reproduce this particular problem (but there's a separate bug in that leading spaces in quoted strings got stripped). The fix for the original problem is to add COMMENT <string> to the field_qualifier production instead of having it in a specific place in the field production. This also matches MySQL's behaviour in that multiple COMMENTs are allowed, but only the last one takes effect. Both these fixes (and some fixes for multi-line comments in various producers) are now in git. -- "I use RMS as a guide in the same way that a boat captain would use a lighthouse. It's good to know where it is, but you generally don't want to find yourself in the same spot." - Tollef Fog Heen


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.