Bug #37154 library name conflict between MySQL 4.1.* and Qt 3.3.5
Submitted: 3 Jun 2008 9:08 Modified: 3 Jun 2008 9:25
Reporter: Bolek Tekielski Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S2 (Serious)
Version:4.1.22 OS:Microsoft Windows (XP SP3)
Assigned to: CPU Architecture:Any
Tags: Contribution

[3 Jun 2008 9:08] Bolek Tekielski
Description:
Analogically to Bug #26294 - library name conflict between MySQL 4.x, 5.0 and Qt 3.3, but this time in version 4.1.22 on windows. Since this bug was fixed only in 5+ versions of MySQL I include patch to solve it in 4.1.* release as well.
Tested on windows XP SP3.

How to repeat:
Link any program that uses both qt-mt.lib from Qt v3.3x (non-threaded versions
not tested) and mysqlclient.lib from v4.1.*

Suggested fix:
diff U3 include/my_time.h include/my_time.h
--- include/my_time.h	Fri Nov 03 03:14:54 2006
+++ include/my_time.h	Tue Jun 03 09:56:06 2008
@@ -53,7 +53,7 @@
 
 long calc_daynr(uint year,uint month,uint day);
 
-void init_time(void);
+void my_init_time(void);
 
 my_time_t 
 my_system_gmt_sec(const MYSQL_TIME *t, long *my_timezone, bool *in_dst_time_gap);
diff U3 libmysql/my_time.c libmysql/my_time.c
--- libmysql/my_time.c	Fri Nov 03 03:15:56 2006
+++ libmysql/my_time.c	Tue Jun 03 09:02:33 2008
@@ -595,9 +595,9 @@
   Prepare offset of system time zone from UTC for my_system_gmt_sec() func.
 
   SYNOPSIS
-    init_time()
+    my_init_time() -> renamed from init_time to avoid conflicts with other libraries, like qt3
 */
-void init_time(void)
+void my_init_time(void)
 {
   time_t seconds;
   struct tm *l_time,tm_tmp;
@@ -659,7 +659,7 @@
   NOTES
     The idea is to cache the time zone offset from UTC (including daylight 
     saving time) for the next call to make things faster. But currently we 
-    just calculate this offset during startup (by calling init_time() 
+    just calculate this offset during startup (by calling my_init_time() 
     function) and use it all the time.
     Time value provided should be legal time value (e.g. '2003-01-01 25:00:00'
     is not allowed).
diff U3 libmysqld/init.cpp libmysqld/init.cpp
--- libmysqld/init.cpp	Fri Nov 03 03:17:14 2006
+++ libmysqld/init.cpp	Tue Jun 03 09:52:13 2008
@@ -33,7 +33,7 @@
   wild_many='%'; wild_one='_'; wild_prefix='\\'; /* Change to sql syntax */
 
   current_pid=(ulong) getpid();		/* Save for later ref */
-  init_time();				/* Init time-functions (read zone) */
+  my_init_time();				/* Init time-functions (read zone) */
 #ifndef EMBEDDED_LIBRARY
   my_abort_hook=unireg_abort;		/* Abort with close of databases */
 #endif
diff U3 libmysqld/my_time.c libmysqld/my_time.c
--- libmysqld/my_time.c	Fri Nov 03 03:15:56 2006
+++ libmysqld/my_time.c	Tue Jun 03 09:52:13 2008
@@ -595,9 +595,9 @@
   Prepare offset of system time zone from UTC for my_system_gmt_sec() func.
 
   SYNOPSIS
-    init_time()
+    my_init_time()
 */
-void init_time(void)
+void my_init_time(void)
 {
   time_t seconds;
   struct tm *l_time,tm_tmp;
@@ -659,7 +659,7 @@
   NOTES
     The idea is to cache the time zone offset from UTC (including daylight 
     saving time) for the next call to make things faster. But currently we 
-    just calculate this offset during startup (by calling init_time() 
+    just calculate this offset during startup (by calling my_init_time() 
     function) and use it all the time.
     Time value provided should be legal time value (e.g. '2003-01-01 25:00:00'
     is not allowed).
diff U3 libmysqld/tztime.cpp libmysqld/tztime.cpp
--- libmysqld/tztime.cpp	Fri Nov 03 03:17:30 2006
+++ libmysqld/tztime.cpp	Tue Jun 03 09:52:13 2008
@@ -988,7 +988,7 @@
     return lowest possible my_time_t in case of ambiguity or if we
     provide time corresponding to the time-gap.
 
-    You should call init_time() function before using this function.
+    You should call my_init_time() function before using this function.
 
   RETURN VALUE
     Corresponding my_time_t value or 0 in case of error
@@ -2575,7 +2575,7 @@
   }
   printf("gmt_sec_to_TIME = localtime for time_t in [1000000000,1100000000) range\n");
 
-  init_time();
+  my_init_time();
 
   /*
     Be careful here! my_system_gmt_sec doesn't fully handle unnormalized
diff U3 sql/init.cpp sql/init.cpp
--- sql/init.cpp	Fri Nov 03 03:17:14 2006
+++ sql/init.cpp	Tue Jun 03 09:58:40 2008
@@ -33,7 +33,7 @@
   wild_many='%'; wild_one='_'; wild_prefix='\\'; /* Change to sql syntax */
 
   current_pid=(ulong) getpid();		/* Save for later ref */
-  init_time();				/* Init time-functions (read zone) */
+  my_init_time();				/* Init time-functions (read zone) */
 #ifndef EMBEDDED_LIBRARY
   my_abort_hook=unireg_abort;		/* Abort with close of databases */
 #endif
diff U3 sql/my_time.c sql/my_time.c
--- sql/my_time.c	Fri Nov 03 03:15:56 2006
+++ sql/my_time.c	Tue Jun 03 09:46:24 2008
@@ -595,9 +595,9 @@
   Prepare offset of system time zone from UTC for my_system_gmt_sec() func.
 
   SYNOPSIS
-    init_time()
+    my_init_time()
 */
-void init_time(void)
+void my_init_time(void)
 {
   time_t seconds;
   struct tm *l_time,tm_tmp;
@@ -659,7 +659,7 @@
   NOTES
     The idea is to cache the time zone offset from UTC (including daylight 
     saving time) for the next call to make things faster. But currently we 
-    just calculate this offset during startup (by calling init_time() 
+    just calculate this offset during startup (by calling my_init_time() 
     function) and use it all the time.
     Time value provided should be legal time value (e.g. '2003-01-01 25:00:00'
     is not allowed).
diff U3 sql/mysql_tzinfo_to_sql.cpp sql/mysql_tzinfo_to_sql.cpp
--- sql/mysql_tzinfo_to_sql.cpp	Fri Nov 03 03:17:30 2006
+++ sql/mysql_tzinfo_to_sql.cpp	Tue Jun 03 09:52:13 2008
@@ -988,7 +988,7 @@
     return lowest possible my_time_t in case of ambiguity or if we
     provide time corresponding to the time-gap.
 
-    You should call init_time() function before using this function.
+    You should call my_init_time() function before using this function.
 
   RETURN VALUE
     Corresponding my_time_t value or 0 in case of error
@@ -2575,7 +2575,7 @@
   }
   printf("gmt_sec_to_TIME = localtime for time_t in [1000000000,1100000000) range\n");
 
-  init_time();
+  my_init_time();
 
   /*
     Be careful here! my_system_gmt_sec doesn't fully handle unnormalized
diff U3 sql/tztime.cpp sql/tztime.cpp
--- sql/tztime.cpp	Fri Nov 03 03:17:30 2006
+++ sql/tztime.cpp	Tue Jun 03 09:52:13 2008
@@ -988,7 +988,7 @@
     return lowest possible my_time_t in case of ambiguity or if we
     provide time corresponding to the time-gap.
 
-    You should call init_time() function before using this function.
+    You should call my_init_time() function before using this function.
 
   RETURN VALUE
     Corresponding my_time_t value or 0 in case of error
@@ -2575,7 +2575,7 @@
   }
   printf("gmt_sec_to_TIME = localtime for time_t in [1000000000,1100000000) range\n");
 
-  init_time();
+  my_init_time();
 
   /*
     Be careful here! my_system_gmt_sec doesn't fully handle unnormalized
diff U3 sql-common/my_time.c sql-common/my_time.c
--- sql-common/my_time.c	Fri Nov 03 03:15:56 2006
+++ sql-common/my_time.c	Tue Jun 03 09:32:29 2008
@@ -595,9 +595,9 @@
   Prepare offset of system time zone from UTC for my_system_gmt_sec() func.
 
   SYNOPSIS
-    init_time()
+    my_init_time()
 */
-void init_time(void)
+void my_init_time(void)
 {
   time_t seconds;
   struct tm *l_time,tm_tmp;
@@ -659,7 +659,7 @@
   NOTES
     The idea is to cache the time zone offset from UTC (including daylight 
     saving time) for the next call to make things faster. But currently we 
-    just calculate this offset during startup (by calling init_time() 
+    just calculate this offset during startup (by calling my_init_time() 
     function) and use it all the time.
     Time value provided should be legal time value (e.g. '2003-01-01 25:00:00'
     is not allowed).
[3 Jun 2008 9:09] Bolek Tekielski
Patch to rename init_time() function to my_init_time()

Attachment: init_time_to_my_init_time.patch (application/octet-stream, text), 7.14 KiB.

[3 Jun 2008 9:25] Sveta Smirnova
Thank you for the report.

Technically this is duplicate of bug #26294. So I close it and add link to this report in the original bug.