[unixODBC-dev] more on quiktest.c

Eric Sharkey sharkey at netrics.com
Wed Feb 23 21:13:10 GMT 2005

I'm still working my way through quiktest.c, and I'm getting a failure
report based exclusively on unixODBC (not my driver).

TestDiagField() runs the following sequence (edited for clarity):

  /* The following are used to produce "(S1)HY009" SQL State */
  rc = SQLAllocStmt(hdbc, NULL);

  rc = SQLGetDiagField(SQL_HANDLE_DBC, hdc,
                       1, SQL_DIAG_SERVER_NAME,
                       rgbValue, SQL_MAX_MESSAGE_LENGTH, &cbValue);

It then compares the string in rgbValue to that returned by
SQLGetInfo(hdbc, SQL_DATA_SOURCE_NAME, ...).

The problem is that the HY009 error generated by SQLAllocStmt is
an internal error and __post_internal_error_ex() in __info.c does:

    tmp = ansi_to_unicode_alloc((SQLCHAR*) "", SQL_NTS, __get_connection( error_header ) );
    wide_strcpy( e1 -> diag_server_name, tmp );
    wide_strcpy( e2 -> diag_server_name, tmp );
    free( tmp );

which sets the server name to the empty string.

The MSDN docs say this about SQL_DIAG_SERVER_NAME:

  For diagnostic data structures associated with the environment
  handle and for diagnostics that do not relate to any server,
  this field is a zero-length string.

So, is the test broken, for assuming SQLAllocStmt(hdbc, NULL) on an
open connection to a server relates to that server, or is unixODBC
at fault, for not filling in the server name?


More information about the unixODBC-dev mailing list