Bug #31814 Define __NT__ by default for the Win32 builds and fix the docs about it
Submitted: 24 Oct 2007 16:17 Modified: 17 Jan 7:13
Reporter: Georgi Kodinov
Status: Closed
Category:Server: Compiling Severity:S3 (Non-critical)
Version:5.0, 5.1.23, 6.0.4 OS:Microsoft Windows
Assigned to: Timothy Smith Target Version:
Tags: pbfail
Triage: Triaged: D3 (Medium)

[24 Oct 2007 16:17] Georgi Kodinov
Description:
__NT__ compile time define is not only about named pipes (as
http://dev.mysql.com/doc/refman/5.1/en/windows-source-build-cmake.html says) : it also
turns on/off writing messages to the Windows system Application error logs.
So please make sure __NT__ is defined by default when following the normal build
instructions for Windows and update the above docs page. 
This is even more true now as we don't support 9x anymore
(http://dev.mysql.com/doc/refman/5.1/en/windows-installation.html) and hence bug #20739
is not relevant anymore.

How to repeat:
Compile an executable without __NT__ and run it as a service. No messages are written
into the Windows system Application log.

Suggested fix:
define __NT__ by default.
[24 Oct 2007 16:35] Miguel Solorzano
Thank you for the bug report.
[18 Nov 2007 11:20] Ingo Strüwing
This does also make the test suite fail after adding tests in the course of fixing MERGE
table implementation.

When repairing a MERGE child table twice under LOCK TABLES, where both MERGE and child
are explicitly locked, the second repair fails with "Error on delete of
'e:/var-ps_stm-121/master-data/test/t1.MYD' (Errcode: 5)".

This error disappears when removing "&& defined(__NT__)" from include/my_sys.h and
mysys/my_delete.c. The effect of this change is that it enables the use of
nt_share_delete() for my_delete_allow_opened(). Without the change, my_delete() is used,
which cannot delete open files on Windows.

Better than doing this change would be to follow the suggestion of the original bug
report and define __NT__ on windows systems that are based on NT.

This is critical now because it makes the test suite fail.
[20 Nov 2007 15:32] Vladislav Vaintroub
Hi;-)

I've got a patch proposal for this problem. IMO, there is no single reason to support
non-NT or NT4.0 anymore, as these are also out-of support for Microsoft. MySQL 5.x/6.0
documentation also mentions Win2000 is the minimal supported version. Tell me what you
think about it.

The patch contains unconditional #define __NT__ , the definition for _WIN32_WINNT
preprocessor constant (this allows to use full Win2000 API on x86 and full Win2003 API on
x64) and some minor cleanup.

The diff is against 5.1.22-rc

--- a/include/config-win.h	2007-09-24 12:29:44 +02:00
+++ b/include/config-win.h	2007-11-20 13:59:32 +01:00
@@ -15,10 +15,21 @@
 
 /* Defines for Win32 to make it compatible for MySQL */
 
-#ifdef __WIN2000__
-/* We have to do this define before including windows.h to get the AWE API
-functions */
-#define _WIN32_WINNT     0x0500
+/*
+  For windows SDK headers, define minimal supported Windows version.
+  It is Win2000 for 32 bit and WinXP x64 for 64 bit.
+*/
+#ifndef _WIN32_WINNT
+#ifdef _WIN64
+#define _WIN32_WINNT 0x0502
+#else
+#define _WIN32_WINNT 0x0500
+#endif
+#endif
+
+/* Always define __NT__ */
+#ifndef __NT__
+#define __NT__
 #endif
 
 #if defined(_MSC_VER) && _MSC_VER >= 1400
@@ -47,16 +58,13 @@
 #define MACHINE_TYPE	"ia64" 
 #elif defined(_M_IX86) 
 #define MACHINE_TYPE	"ia32" 
-#elif defined(_M_ALPHA) 
-#define MACHINE_TYPE	"axp" 
+#elif defined(_M_X64) 
+#define MACHINE_TYPE	"x64" 
 #else
 #define MACHINE_TYPE	"unknown"	/* Define to machine type name */
 #endif 
  
 #if !(defined(_WIN64) || defined(WIN64)) 
-#ifndef _WIN32
-#define _WIN32				/* Compatible with old source */
-#endif
 #ifndef __WIN32__
 #define __WIN32__
 #endif
[20 Nov 2007 15:41] Daniel Fischer
Maybe we could default to __NT__ in configure.js, so that you have to turn it off
explicitly if you don't want it?
[20 Nov 2007 20:16] Vladislav Vaintroub
Hi Daniel,
you proposal to give non-NT the last chance is certainly less radical than mine, but
whether mysql can run on Windows 9x seems questionable to me.
At least after this change http://lists.mysql.com/commits/34856, where
pthread_mutex_trylock was correctly fixed on NT, yet by using function
TryEnterCriticalSection() that is non-existent on Win9x and not trivial to implement on
this platform. It is even hard to find out what  Win32 API functions were present on
Win9x - online MSDN documentation does not mention anything prior to Windows 2000
anymore.
[21 Nov 2007 0:36] Timothy Smith
The current plan is to define __NT__ by default via CMake.  And to open a worklog item
(TODO) to remove all references to __NT__.  It's no longer at all supported to build on
non-NT systems, and the #ifdef __NT__ stuff can just go away completely.  However, this
is a larger change, and should be done after a bit more consideration.  A Worklog entry
will track that task.
[21 Nov 2007 0:56] 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/38175

ChangeSet@1.2583, 2007-11-20 16:56:12-07:00, tsmith@ramayana.hindu.god +3 -0
  Bug #31814: Define __NT__ by default for the Win32 builds and fix the docs about it
  
  Add a new option for configure.js, DISABLE_NT_SUPPORT, which is entirely
  unsupported (but might allow someone on a non-NT system to perhaps maybe
  build and run the MySQL server, possibly).
  
  Remove the __NT__ option for configure.js, which is no longer needed.
  
  TODO:  Remove all references to __NT__ from the code, and stop pretending
  that we support pre-NT systems at all.  See WL#4151, "Remove __NT__ from
  server code".
[21 Nov 2007 2:35] 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/38180

ChangeSet@1.2583, 2007-11-20 18:34:58-07:00, tsmith@ramayana.hindu.god +3 -0
  Bug #31814: Define __NT__ by default for the Win32 builds and fix the docs about it
  
  Add a new option for configure.js, DISABLE_NT_SUPPORT, which is entirely
  unsupported (but might allow someone on a non-NT system to perhaps maybe
  build and run the MySQL server, possibly).
  
  Remove the __NT__ option for configure.js, which is no longer needed.
  
  TODO:  Remove all references to __NT__ from the code, and stop pretending
  that we support pre-NT systems at all.  See WL#4151, "Remove __NT__ from
  server code".
[22 Nov 2007 21:07] Ingo Strüwing
Please ignore my former comment in this bug report. __NT__ is set in pushbuild. The
correct functions are compiled in. The failure is a bit time critical, so I was tricked
to believe that my change has helped. The cause of the problem is unrelated to this bug
report.

I reverted severity and priority to what they were before I changed them.
[16 Jan 21:38] Timothy Smith
This bug won't be fixed.  This isn't a big deal in 5.1 and below, so won't fix it there. 
And in 6.0, all references to __NT__ are gone, so this bug is irrelevant there.

Docs, nothing to document specifically for this bug, but if __NT__ shows anywhere in the
documentation, please remove it.

MySQL 6.0 doesn't even pretend to build on Win95, et. al.  People using MySQL on older
Windows versions are encouraged to stick with our older 4.x versions.

Timothy
[17 Jan 7:13] Paul DuBois
Removed the references to __NT__.