vertica/vertica-sql-go

Go type for int column

watercraft opened this issue · 4 comments

I'm evaluating this driver as a replacement for alexbrianman/odbc for connecting to Vertica.
However, the Go type that comes out of xsql's rows.MapScan() for an int column is different.
For odbc the type is int64 and for this driver it is int.
I'm afraid my application depends on getting full precision for int values.
Is there a configuration option or another way to get int64 values through this driver?

There is no option for that today. I'm not sure of the overall standards compatibility between the ODBC standard and GoLang's SQL standard. Can you cite something related to such handling in the Go SQL spec? re: https://golang.org/pkg/database/sql/driver/

I'm not sure what the spec says but I do know that the highly active Postgres driver is able to deliver 64 bit integers for the "bigint" type. As all integers in Vertica are 64 bit, I would expect this to be important for most consumers of your driver. As I mention, I'm doing this today with alexbrianman/odbc on Vertica.

The same Go SQL interface is used to return 64 bit integers from postgres. BIGINT is mapped to Int64, as one would imagine it should be, in the PG driver. Unlike postgres, AFAIK, Vertica doesn't even have a native Int32 datatype. So this is currently resulting in undefined behavior for most of the range of your most popular datatype, I would think. We would like to submit a pull request to fix it for you. Would that be okay? Until then, we are maintaining a local fixed fork, which is a form of technical debt. Thanks in advance for your consideration.

I think the Go spec has int as a 64 bit integer on 64 bit systems so for most users this shouldn't be a problem. Using int64 explicitly would be clearer, and protect you on 32 bit systems though.