Opened 6 years ago

Closed 5 years ago

#7258 closed defect (wontfix)

Incorrect GDAL ODBC error handling

Reported by: kovbal Owned by: warmerdam
Priority: normal Milestone: closed_because_of_github_migration
Component: default Version: unspecified
Severity: normal Keywords: odbc, error_handling
Cc:

Description

The ODBC error handler code in CPLODBCSession::Failed() is using the API incorrectly. Although the official documentation does not mention it explicitly, but the SQLError() (and its 3.0 counterpart SQLGetDiagRec()) has to be called repeatedly, because a single ODBC error may cause multiple errors. This can be seen in various ODBC sample code from Microsoft (e.g. here).

Another issue is that CPLODBCSession::Failed() ignores SQLState. This is problematic, because without the SQLState, applications cannot really differentiate between error types. The only information conveyed by the driver is the MessageText. But the exact text varies between ODBC drivers, so at the moment, an application using GDAL cannot really detect whether the error was a syntax error or a network error. SQLState on the other hand, seems to consistent between ODBC drivers.

I checked these issues with GDAL 1.11, but I think they are present in newer versions as well.

Change History (4)

comment:1 by Even Rouault, 6 years ago

May you be able to submit a pull request for this against https://github.com/OSGeo/gdal?

comment:2 by kovbal, 6 years ago

Yes, definitely.

However, I think a proper solution would break ABI compatibility (CPLODBCSession::m_szLastError's type would change). I haven't found any policy about that, but maybe I haven't looked hard enough.

comment:3 by Even Rouault, 6 years ago

However, I think a proper solution would break ABI compatibility

That's OK for trunk.

comment:4 by Even Rouault, 5 years ago

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: assignedclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub. If you believe this ticket is still valid, you may file it to https://github.com/OSGeo/gdal/issues if it is not already reported there.

Note: See TracTickets for help on using tickets.