CartoDB / odbc_fdw

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

Improve error messages #126

Closed jgoizueta closed 3 years ago

jgoizueta commented 4 years ago

When an error occurs in a ODBC call, we were only producing generic error messages about what we we're trying to do. With this patch we now also include information about the error provided by the ODBC driver.

This is to support https://app.clubhouse.io/cartoteam/story/80914/improve-error-messages-while-importing

For example, if a SQL query executed (via sql_quey in IMPORT FOREIGN SCHEMA) was syntactically incorrect, we had:

ERROR:  Executing ODBC query

With the extension compiled with debug information and debug messages on we had some additional information, but not as part of the error message:

DEBUG:  Error result (-1): Executing ODBC query
DEBUG:   42000:1:1003:SQL compilation error:
syntax error line 1 at position 51 unexpected '10'.

ERROR:  Executing ODBC query

Now we have the same information in the DEBUG log appendend to the error message:

ERROR:  Executing ODBC query to get schema
SQL compilation error:
syntax error line 1 at position 51 unexpected '10'.

This will allow for better error messages in the CARTO Import API: see https://app.clubhouse.io/cartoteam/story/80914/improve-error-messages-while-importing

jgoizueta commented 4 years ago

Tests need to be adapted now for the augmented error messages

jgoizueta commented 4 years ago

@rafatower sorry I requested your review too early, to avoid bothering you too much I'll ping you when tests are ready

jgoizueta commented 4 years ago

😅 I thought adapting the test was going to be much harder