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
39 stars 3 forks source link

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

Open hyundonk opened 1 month ago

hyundonk commented 1 month 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 1 month 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 weeks ago

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

karenc-bq commented 1 week 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 6 days ago

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