Bug #43120 Backup tree does not compile on Windows Vista w/VS 2008 Pro
Submitted: 23 Feb 2009 19:28 Modified: 26 Feb 2009 1:07
Reporter: Chuck Bell Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Backup Severity:S3 (Non-critical)
Version:6.0.10 OS:Microsoft Windows (Vista)
Assigned to: Vladislav Vaintroub
Triage: Triaged: D3 (Medium)

[23 Feb 2009 19:28] Chuck Bell
Description:
The current mysql-6.0-backup tree does not compile on Windows Vista using Visual Studio 2008 Professional. The following errors are generated:

1>backup_info.cc
1>.\backup_info.cc(185) : error C2121: '#' : invalid character : possibly the result of a macro expansion
1>.\backup_info.cc(185) : error C2146: syntax error : missing ')' before identifier 'ifdef'
1>.\backup_info.cc(185) : error C2065: 'ifdef' : undeclared identifier
1>.\backup_info.cc(185) : error C2146: syntax error : missing ';' before identifier 'WITH_MARIA_STORAGE_ENGINE'
1>.\backup_info.cc(185) : error C2065: 'WITH_MARIA_STORAGE_ENGINE' : undeclared identifier
1>.\backup_info.cc(185) : error C2121: '#' : invalid character : possibly the result of a macro expansion
1>.\backup_info.cc(185) : error C2146: syntax error : missing ';' before identifier 'endif'
1>.\backup_info.cc(185) : error C2059: syntax error : ')'
1>.\backup_info.cc(185) : error C2065: 'endif' : undeclared identifier
1>.\backup_info.cc(185) : error C2146: syntax error : missing ';' before identifier 'hton'

How to repeat:
Build the latest tree on Windows with VS 2008 Pro in debug with:

win\configure WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE WITH_ARCHIVE_STORAGE_ENGINE WITH_BLACKHOLE_STORAGE_ENGINE WITH_EXAMPLE_STORAGE_ENGINE WITH_FEDERATED_STORAGE_ENGINE __NT__  EXTRA_DEBUG ENABLED_DEBUG_SYNC BACKUP_TEST

devenv.com mysql.sln /build Debug

Suggested fix:
The problem is the macro definition. This is disrupting the precompiler on Windows VS 2008 Pro. A solution that works on both Windows and Linux is shown below:

=== modified file 'sql/backup/backup_info.cc'
--- sql/backup/backup_info.cc   2009-02-13 12:40:13 +0000
+++ sql/backup/backup_info.cc   2009-02-23 19:03:59 +0000
@@ -172,18 +172,24 @@ Backup_info::find_backup_engine(const ba
 #ifndef DBUG_OFF
   backup_factory *saved_factory; // to save hton->get_backup_engine

+#ifdef WITH_MARIA_STORAGE_ENGINE
   DBUG_EXECUTE_IF("backup_test_dummy_be_factory",
     {
       handlerton *hton= se_hton(se);
       saved_factory= hton->get_backup_engine;
-      if (hton == myisam_hton
-#ifdef WITH_MARIA_STORAGE_ENGINE
-          || hton == maria_hton
-#endif
-          )
+      if (hton == myisam_hton || hton == maria_hton)
+        hton->get_backup_engine= dummy_backup_engine_factory;
+    });
+#else
+  DBUG_EXECUTE_IF("backup_test_dummy_be_factory",
+    {
+      handlerton *hton= se_hton(se);
+      saved_factory= hton->get_backup_engine;
+      if (hton == myisam_hton)
         hton->get_backup_engine= dummy_backup_engine_factory;
     });
 #endif
+#endif

   snap= native_snapshots[se];
[24 Feb 2009 5:23] Rafal Somla
Here is an alternative fix which avoids code repetition.

=== modified file 'sql/backup/backup_info.cc'
--- sql/backup/backup_info.cc   2009-02-13 12:40:13 +0000
+++ sql/backup/backup_info.cc   2009-02-24 05:19:00 +0000
@@ -171,16 +171,15 @@ Backup_info::find_backup_engine(const ba
 
 #ifndef DBUG_OFF
   backup_factory *saved_factory; // to save hton->get_backup_engine
+#ifndef WITH_MARIA_STORAGE_ENGINE
+  handlerton *maria_hton= (handlerton*) 1;  
+#endif
 
   DBUG_EXECUTE_IF("backup_test_dummy_be_factory", 
     {
       handlerton *hton= se_hton(se);
       saved_factory= hton->get_backup_engine;
-      if (hton == myisam_hton
-#ifdef WITH_MARIA_STORAGE_ENGINE
-          || hton == maria_hton
-#endif
-          ) 
+      if (hton == myisam_hton || hton == maria_hton) 
         hton->get_backup_engine= dummy_backup_engine_factory;
     });
 #endif
[24 Feb 2009 9:51] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/67328

3063 Vladislav Vaintroub	2009-02-24
      Bug #43131 Maria compile error 6.0-main
      Bug #43120 Backup tree does not compile on Windows Vista w/VS 2008 Pro 
      
      Use patches by Rafal and Sergei to fix compile problems on Windows debug
[24 Feb 2009 18:18] Chuck Bell
Patch approved.
[25 Feb 2009 5:12] Rafal Somla
Good to push.
[25 Feb 2009 9:03] Bugs System
Pushed into 6.0.11-alpha (revid:alik@sun.com-20090225085147-fgsuroycbofgpm5b) (version source revid:vvaintroub@mysql.com-20090224095047-dpp5nc49hpmnd3mg) (merge vers: 6.0.11-alpha) (pib:6)
[26 Feb 2009 1:07] Paul Dubois
Noted in 6.0.11 changelog.

Compilation failures on Windows Vista using Visual Studio
2008 Professional were corrected.