Bug #67216 error compiling: DBD-mysql-4.022 dbdimp.c:3490: error: parse error before "if"
Submitted: 12 Oct 2012 22:40 Modified: 6 Nov 2012 20:04
Reporter: Cpp JavaPerl Email Updates:
Status: Unsupported Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S2 (Serious)
Version:4.022 OS:Linux (SUSE 9.0)
Assigned to: CPU Architecture:Any

[12 Oct 2012 22:40] Cpp JavaPerl
Description:
Received this error when installing DBD-mysql from CPAN on an old SUSE 9.0 machine.

dbdimp.c:3490: error: parse error before "if"

So I downloaded a tarball for that version ( http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.022.tar.gz ) with the following MD5SUM:

20fb571245e3b9ac275b8329025c4bf6  DBD-mysql-4.022.tar.gz

After extracting the tarball and attempting to build it manually, I got the same error.

The perl version curently installed on this machine is v5.12.4 (Binary build 1205 [294981] provided by ActiveState).

How to repeat:
Either attempt to install from CPAN or download and compile the perl module separately (on an older machine where the condition in the #if described below is not true).

Suggested fix:
Inspecting line 3490 of dbimp.c shows that it is indeed the start of an if statement.  The first immediately preceding non-whitespace line of code contains a single closing bracket ( } ).  In looking at the context before that bracket, it appears to me that it was intended to close the if statement which is started on line 3459:

if (imp_sth->use_server_side_prepare && ! imp_sth->use_mysql_use_result)  

However, that if statement is conditionally compiled in according to the #if that precedes it:

#if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION   

Consequently (and because I'm on an old machine where that conditional doesn't appear to be true), the bracket on line 3488 should not be appearing in the code (as compiled on my machine).

It seems to me that the bug is a lack of a similar #if surrounding that bracket -- I think the code at line 3488 should read:

#if MYSQL_VERSION_ID >= SERVER_PREPARE_VERSION   
}                                                                               
#endif

Putting in this change allows the file to compile, and DBD::mysql installs and seems to work fine on the same machine I found the error on.
[6 Nov 2012 20:04] Sveta Smirnova
Thank you for the report.

We don't work on DBD::mysql bugs anymore. All its bugs should go to CPAN: https://rt.cpan.org/Public/Dist/Display.html?Name=DBD-mysql

I re-submitted your report to https://rt.cpan.org/Public/Bug/Display.html?id=80667
Please subscribe to the new report on CPAN and work with DBD::mysql developers in case if they need additional details.