Bug #27765 Logging does not work
Submitted: 11 Apr 2007 20:47 Modified: 3 May 2007 13:22
Reporter: Dennis Gronewold
Status: Closed
Category:Connector/Net Severity:S2 (Serious)
Version:5.0.6 OS:Microsoft Windows
Assigned to: Target Version:

[11 Apr 2007 20:47] Dennis Gronewold
Description:
The logging functionality of the Connector does not work, because the code was compiled
without the TRACE constant. This also breaks the usage advisor. 

How to repeat:
Download and install the Connector, add "logging=true" to the connection string and make a
query. It will not appear in the configured trace listeners.

Suggested fix:
Compile the Connector with the TRACE constant.
[15 Apr 2007 14:18] Tonci Grgin
Hi Dennis.
Let me help understand you better. I just compiled release version from latest sources and
added "logging=true" to one of my tests connection string. The result is as expected:
[15.04.2007 14:13:37] - Executing command QUERY with text ='SHOW VARIABLES'
[15.04.2007 14:13:38] - Executing command QUERY with text ='SHOW COLLATION'
[15.04.2007 14:13:38] - Executing command QUERY with text ='SET NAMES utf8;SET
character_set_results=NULL'
'bug16126.vshost.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.Ent
erpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option
'Just My Code' is enabled.
[15.04.2007 14:13:38] - Executing command QUERY with text ='drop procedure if exists
spTestBug27679'
[15.04.2007 14:13:39] - Executing command QUERY with text ='CREATE PROCEDURE
spTestBug27679 (IN id TINYINT UNSIGNED, OUT valo TINYINT UNSIGNED) BEGIN SET valo =
(id-1); END'
[15.04.2007 14:13:39] - Executing command QUERY with text ='SELECT * FROM
INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='test' AND
ROUTINE_NAME='spTestBug27679''
Test 1):
Param Id (TINYINT UNSIGNED) MySqlDbType: UByte
Param valo (TINYINT UNSIGNED) MySqlDbType: UByte
Test 1) done.
[15.04.2007 14:13:39] - Executing command QUERY with text ='SHOW CREATE PROCEDURE
test.spTestBug27679'
Retrieving procedure metadata for test.spTestBug27679 from server.
[15.04.2007 14:13:39] - Executing command QUERY with text ='call spTestBug27679 (155,
@1859594273valo)'
[15.04.2007 14:13:39] - Executing command QUERY with text ='SELECT @1859594273valo'
Retrieving procedure metadata for test.spTestBug27679 from procedure cache.
Test 2):
Test 2) done.
The thread '<No Name>' (0x1f94) has exited with code 0 (0x0).
The thread '<No Name>' (0xc48) has exited with code 0 (0x0).
The program '[6884] bug16126.vshost.exe: Managed' has exited with code 0 (0x0).

Now, do you think I should try installing GA version? Can you post a sample test case and
state what you think should happen and what happens actually?
[15 Apr 2007 14:40] Dennis Gronewold
Hi !

You seem to have compiled a version with Visual Studio. VS has a option 'Define TRACE
constant', which is true by default, so it works for you. But, AFAICS the distribution
builds are compiled with the NAnt build file, therefore the TRACE constant must be passed
to csc.exe manually. 

From the build file:

<if test="${not property::exists('defines')}">
    <property name="defines" value=""/>

[...]
 <csc output="${outdir}/MySql.Data.dll" target="library"
		define="${defines}" debug="${debug}" optimize="${opt}" 
                keycontainer="ConnectorNet" doc="${outdir}/MySql.Data.xml">

As you can see, the defines property is empty (unless it is set via a command line
parameter when calling NAnt). 

This is the code of the Logger Class from Connector/.Net 5.0.6 disassembled with
Reflector: 

internal class Logger
{
    // Methods
    private Logger()
    {
    }

    public static void LogCommand(DBCmd cmd, string text)
    {
        if (text.Length > 300)
        {
            text = text.Substring(0, 300);
        }
        WriteLine(string.Format("Executing command {0} with text ='{1}'", cmd.ToString(),
text));
    }

    public static void LogException(Exception ex)
    {
        WriteLine(string.Format("EXCEPTION: " + ex.Message, new object[0]));
    }

    public static void LogInformation(string msg)
    {
    }

    public static void LogWarning(string s)
    {
        WriteLine("WARNING:" + s);
    }

    public static void Write(string s)
    {
    }

    public static void WriteLine(string s)
    {
    }
}

As you can see, Write() and WriteLine() are empty, because the compiler omitted
the call to Trace.Writeline().
[15 Apr 2007 15:17] Tonci Grgin
Dennis, thanks for your help in resolving this.

Verified as described with:
 - MySQL server 5.0.38BK on WinXP Pro SP2
 - c/NET 5.0.6GA, NET FW 2.0
[1 May 2007 22:38] 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/25848
[1 May 2007 22:40] 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/25849
[1 May 2007 22:40] Reggie Burnett
Fixed in 5.0 and trunk
[3 May 2007 13:22] MC Brown
A note has been added to the changelog.