Message-ID: From: "omeuid (@omeuid)" To: "postgresql-interfaces/psqlodbc" Date: Thu, 18 Jul 2024 06:15:01 +0000 Subject: [postgresql-interfaces/psqlodbc] issue #33: SQLGetData function can return an incorrect SQLSTATE List-Id: X-GitHub-Author-Id: 6940566 X-GitHub-Author-Login: omeuid X-GitHub-Issue: 33 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/issues/33 Content-Type: text/plain; charset=utf-8 Hi, The ODBC API documentation of the [SQLGetData ](https://learn.microsoft.com/en-us/sql/odbc/reference/syntax/sqlgetdata-function#retrieving-data-with-sqlgetdata)function says: > If the data is NULL and StrLen_or_IndPtr was a null pointer, SQLGetData returns SQLSTATE 22002 (Indicator variable required but not supplied). But the PostgreSQL ODBC driver returns a generic HY000 SQLSTATE. As I understand, to fix the issue the following change could be made. In the _copy_and_convert_field_ method from the _convert.c_ file, replace the next fragment: ``` { SC_set_error(stmt, STMT_RETURN_NULL_WITHOUT_INDICATOR, "StrLen_or_IndPtr was a null pointer and NULL data was retrieved", func); return SQL_ERROR; } ``` by the next one: ``` { SC_set_error(stmt, STMT_RETURN_NULL_WITHOUT_INDICATOR, "StrLen_or_IndPtr was a null pointer and NULL data was retrieved", func); return COPY_GENERAL_ERROR; } ``` Regards, Carlos