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.