aws / aws-mysql-odbc

The Amazon Web Services (AWS) ODBC Driver for MySQL allows an application to take advantage of the features of clustered MySQL databases. It is based on and can be used as a drop-in compatible for the MySQL Connector/ODBC driver, and is compatible with all MySQL deployments.
Other
41 stars 4 forks source link

access violation exception with ADO library (msado15.dll) #202

Open hyundonk opened 3 months ago

hyundonk commented 3 months ago

Describe the bug

When querying with ADO library (msado15.dll), it gets access violation exception.

Below is sample test code.

#include <iostream>
#include <comdef.h>
#include <atlbase.h>
#include <atlsafe.h>
#import "C:\\Program Files\\Common Files\\System\\ado\\msado15.dll" no_namespace rename("EOF", "EndOfFile")

void InitializeCOM() {
    HRESULT hr = CoInitialize(NULL);
    if (FAILED(hr)) {
        std::cerr << "Failed to initialize COM library." << std::endl;
        exit(1);
    }
}

void UninitializeCOM() {
    CoUninitialize();
}

void ExecuteQuery() {
    _ConnectionPtr pConn;
    _RecordsetPtr pRst;

    try {
        // Initialize the connection
        HRESULT hr = pConn.CreateInstance(__uuidof(Connection));
        if (FAILED(hr)) {
            _com_error err(hr);
            std::wcerr << L"Failed to create Connection instance: " << err.ErrorMessage() << std::endl;
            return;
        }

        // Connection string
        //_bstr_t connStr = L"Driver={MySQL ODBC 8.0 Unicode Driver};Server=my-server-address;Database=databasename;User=admin;Password=mypassword;no_ssps=1;";
        _bstr_t connStr = L"Driver={AWS ODBC Unicode Driver for MySQL};;Server=my-server-address;Database=databasename;User=admin;Password=mypassword;no_ssps=1;";

        // Open the connection
        pConn->Open(connStr, L"", L"", adConnectUnspecified);

        // Initialize the recordset
        hr = pRst.CreateInstance(__uuidof(Recordset));
        if (FAILED(hr)) {
            _com_error err(hr);
            std::wcerr << L"Failed to create Recordset instance: " << err.ErrorMessage() << std::endl;
            return;
        }

        // SQL query
        _bstr_t sql = L"SELECT * FROM sample LIMIT 5;";

        // Execute the query. I got exception here!
        pRst->Open(sql, _variant_t((IDispatch*)pConn, true), adOpenStatic, adLockReadOnly, adCmdText);

        // Process the results
        while (!pRst->EndOfFile) {
            std::wcout << (LPCWSTR)(_bstr_t)pRst->Fields->Item[L"your_column"]->Value << std::endl;
            pRst->MoveNext();
        }

        // Close the recordset and connection
        pRst->Close();
        pConn->Close();
    }
    catch (_com_error& e) {
        std::wcerr << L"COM error: " << e.ErrorMessage() << std::endl;
    }
}

int main() {
    InitializeCOM();
    ExecuteQuery();
    UninitializeCOM();
    return 0;
}

When using MySQL ODBC 8.0 Unicode Driver, I don't see such exception error. Please help on this.

Expected Behavior

No exception error when querying with ADO library

Were cluster failover and/or enhanced failure detection enabled? Were any AWS authentication methods used? What other connection properties were set?

N.A.

Current Behavior

When querying with ADO library (msado15.dll), it gets access violation exception.

Reproduction Steps

Sample code provided

Possible Solution

No response

Additional Information/Context

No response

The AWS ODBC Driver for MySQL version used

1.0.0

Operating System and version

Windows 2019

karenc-bq commented 3 months ago

Hi @hyundonk, thank you for raising this issue. I am able to reproduce it and I am looking into it now, will keep you posted.

InnovBase commented 2 months ago

Hi, Any update.. I am facing the same issue... do you have any work around until the next release?

karenc-bq commented 2 months ago

Hi @InnovBase, we have root caused the issue and was verifying the fix. We understand this is a blocking issue for you so we will be doing a patch release next week, thank you for your patience.

karenc-bq commented 2 months ago

Hi all, we released the fix in version 1.1.0. Please let us know if you are still seeing this issue.

InnovBase commented 2 months ago

Salaam... Same issue with version 1.1.0. screen closed once you press test or drill the database combobox

InnovBase commented 2 months ago

here you are Event Viewer error description: Faulting application name: odbcad32.exe, version: 10.0.20348.1, time stamp: 0xf73007ad Faulting module name: MSVCP140.dll, version: 14.29.30153.0, time stamp: 0x653aa208 Exception code: 0xc000041d Fault offset: 0x0000000000013080 Faulting process id: 0xa7c Faulting application start time: 0x01db083d9ca12920 Faulting application path: C:\Windows\system32\odbcad32.exe Faulting module path: C:\Windows\SYSTEM32\MSVCP140.dll Report Id: 052a6691-df04-45ce-828e-73858b946d01 Faulting package full name: Faulting package-relative application ID:

karenc-bq commented 2 months ago

Hi @InnovBase, could you please clarify if you are still experiencing the access violation exception or this other issue ? Could you please let us know if the suggestion in that thread works for you? Thanks.

InnovBase commented 2 months ago

Yes, the suggestion resolved ODBC connection problem.