CartoDB / odbc_fdw

PostgreSQL Foreign-data Wrapper for ODBC
Other
67 stars 22 forks source link

Check errors while reading data #130

Closed jgoizueta closed 3 years ago

jgoizueta commented 3 years ago

We didn't check for errors from SQLGetData calls.

jgoizueta commented 3 years ago

It comes from a situation where we were ignoring errors, and that could lead to segfaults: The SQL Server driver, unlike others doesn't support converting binary data to text (as hex strings). It complained when asked to do so with an error result from SQLGetData, but it also seems to modify the read buffer. Since we were ignoring the problem we then used the buffer as an hex string into a bytea field and occasionally got Segfaults (which in my opinion would never occur if SQLGetData failing calls had avoided modifying the buffer, but well...)

I don't think that's easy to find a good test case: We could use a binary field with the SQL Server driver, buts that's something I'd like to have fixed soon. So we need a column type that we don't ignore but the driver cannon convert to text.