alexbrainman / odbc

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

Crash when adding column #62

Open JoopClaireIT opened 8 years ago

JoopClaireIT commented 8 years ago

screenshot 2015-10-29 at 16 55 34

Sorry, didn't manage to copy/paste the error in this case. Will try to debug and solve myself, then issue PR, but just so you know about it :smiley:.

alexbrainman commented 8 years ago

If you can provide me with a small program I can run myself, I will investigate. Otherwise it is hard to guess what the problem is.

Alex

JoopClaireIT commented 8 years ago

I know, will have to narrow it down myself first...

JoopClaireIT commented 8 years ago

It only happens with one specific column, it's not number of columns, I bet it's something with the column type. This is with an Intersystems Caché database (uses SQL abstracting over an OO system internally, and technically only using strings internally). The contents of the specific column is a string describing car types. The specific lines point to the Next() method, and there in the columns.go file to the return c.BaseColumn.Value(c.Buffer[:c.Len]) line. So maybe in some corner cases c.Len is not accurate?

JoopClaireIT commented 8 years ago

Just logged it with a printf of len(c.Buffer) and c.Len just before the return, and in the loop it goes well most of the time, then produces len(c.Buffer) as 51 but c.Len as 60, which of course causes it to crash. Maybe there needs to be an additional bounds check here?

alexbrainman commented 8 years ago

I agree it must be to do with the way ODBC driver reports your column types. Is it possible for me reproduce this bug here? What software do I need? What are the steps? This package has been mainly used with MS SQL Server, and I wouldn't be surprised if there is some missing logice for other databases.

Alex

JoopClaireIT commented 8 years ago

The database is Intersystems Caché, it's a commercial one so not sure if you would be able to gain access to one. The ODBC driver is a free download though, and there seems to be a free full functioning one person trial without time limit or other limitations that would make debugging impossible... The exact bug happened with me only in a rare case but on that specific case always, not intermittently, so I think you should be able to trace the origin then...

ariel17ml commented 6 years ago

Hello @alexbrainman. I've faced same problem using this driver with Apache Hive (query with single string column), applied changes provided by @JoopClaireIT and now it works like expected. Is there any planned ETA for merging it into production?

Thank you and best regards. Ariel Ríos.

alexbrainman commented 6 years ago

Is there any planned ETA for merging it into production?

I would like to understand what is the problem that this PR fixes first.

Can you provide a small program that demonstrates the problem? Run your program, show its output here, and explain to me why you think that your program output is wrong.

Can I run your program here, on my own computer? What do I need to run it?

Thank you.

Alex

haynesherway commented 5 years ago

I am having the same issue, specifically it seems with null dates coming from an IBM iSeries database. They don't report SQL_NULL_DATA as true, so it doesn't get caught with the IsNull(). Then it panics when this slice is out of range. I spent way too much of my life investigating this.