alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
348 stars 139 forks source link

fix panic when DB returns an error #189

Closed tonodor closed 11 months ago

tonodor commented 11 months ago

This fixed #184 for me. api.SQLGetDiagRec is expecting a pointer to a smallint to store the message length but the current implementation passes a nil.

alexbrainman commented 11 months ago

@tonodor thanks for the fix.

Looks reasonable.

Is it possible to add test that is fixed by this bug?

Alex

tonodor commented 11 months ago

In my case it was happening on a Linux system connecting to Hadoop using Cloudera Impala ODBC driver. I can't replicate it with MySQL, SQL Server or Postgres so it's likely due to the driver that is not checking if the pointer is valid before using it. I can't find any reference that states if the parameter is optional or not, however, passing a valid pointer is probably better.

alexbrainman commented 11 months ago

In my case it was happening on a Linux system connecting to Hadoop using Cloudera Impala ODBC driver. I can't replicate it with MySQL, SQL Server or Postgres so it's likely due to the driver that is not checking if the pointer is valid before using it. I can't find any reference that states if the parameter is optional or not, however, passing a valid pointer is probably better.

Thanks for explaining.

The bug is in github.com/alexbrainman/odbc so you change is valid.

I just merged your your change. So closing this PR.

Alex