I enabled ODBC trace . Attached trace log. Had to edit connection details and snipped few repetitive lines as I ran the same sql multiple times Connection Out [DSN=BLUE;UID=*;PWD=***;DATABASE=***;HOST...] [ODBC][4248][1539734369.611042][SQLGetInfo.c][554] Entry: Connection = 0x2150e90 Info Type = SQL_IDENTIFIER_QUOTE_CHAR (29) Info Value = 0x7ffdaf8700ee Buffer Length = 2 StrLen = (nil) [ODBC][4248][1539734369.611055][SQLGetInfo.c][617] Exit:[SQL_SUCCESS] [ODBC][4248][1539734369.611067][SQLGetInfo.c][554] Entry: Connection = 0x2150e90 Info Type = SQL_CATALOG_NAME_SEPARATOR (41) Info Value = 0x7ffdaf8700ee Buffer Length = 2 StrLen = (nil) [ODBC][4248][1539734369.611075][SQLGetInfo.c][617] Exit:[SQL_SUCCESS] [ODBC][4248][1539734369.611092][SQLAllocHandle.c][540] Entry: Handle Type = 3 Input Handle = 0x2150e90 [ODBC][4248][1539734369.611122][SQLAllocHandle.c][1081] Exit:[SQL_SUCCESS] Output Handle = 0x2167610 [ODBC][4248][1539734369.611138][SQLExecDirect.c][240] Entry: Statement = 0x2167610 SQL = [select fld1,fld2 from rkrishna.fdwtest][length = 38 (SQL_NTS)] [ODBC][4248][1539734369.612221][SQLExecDirect.c][503] Exit:[SQL_SUCCESS] [ODBC][4248][1539734369.612242][SQLNumResultCols.c][156] Entry: Statement = 0x2167610 Column Count = 0x7ffdaf87015e [ODBC][4248][1539734369.612257][SQLNumResultCols.c][248] Exit:[SQL_SUCCESS] Count = 0x7ffdaf87015e -> 2 [ODBC][4248][1539734369.612282][SQLFetch.c][162] Entry: Statement = 0x2167610 [ODBC][4248][1539734369.612303][SQLFetch.c][348] Exit:[SQL_SUCCESS] [ODBC][4248][1539734369.612314][SQLNumResultCols.c][156] Entry: Statement = 0x2167610 Column Count = 0x7ffdaf8701ca [ODBC][4248][1539734369.612321][SQLNumResultCols.c][248] Exit:[SQL_SUCCESS] Count = 0x7ffdaf8701ca -> 2 [ODBC][4248][1539734369.612334][SQLDescribeCol.c][247] Entry: Statement = 0x2167610 Column Number = 1 Column Name = 0x2164b78 Buffer Length = 255 Name Length = 0x7ffdaf8701cc Data Type = 0x7ffdaf8701ce Column Size = 0x7ffdaf8701d8 Decimal Digits = 0x7ffdaf8701d0 Nullable = 0x7ffdaf8701d2 [ODBC][4248][1539734369.612394][SQLDescribeCol.c][497] Exit:[SQL_SUCCESS] Column Name = [FLD1] Data Type = 0x7ffdaf8701ce -> 4 Column Size = 0x7ffdaf8701d8 -> 10 Decimal Digits = 0x7ffdaf8701d0 -> 0 Nullable = 0x7ffdaf8701d2 -> 1 [ODBC][4248][1539734369.612409][SQLDescribeCol.c][247] Entry: Statement = 0x2167610 Column Number = 2 Column Name = 0x2164b78 Buffer Length = 255 Name Length = 0x7ffdaf8701cc Data Type = 0x7ffdaf8701ce Column Size = 0x7ffdaf8701d8 Decimal Digits = 0x7ffdaf8701d0 Nullable = 0x7ffdaf8701d2 [ODBC][4248][1539734369.612419][SQLDescribeCol.c][497] Exit:[SQL_SUCCESS] Column Name = [FLD2] Data Type = 0x7ffdaf8701ce -> 1 Column Size = 0x7ffdaf8701d8 -> 1 Decimal Digits = 0x7ffdaf8701d0 -> 0 Nullable = 0x7ffdaf8701d2 -> 1 [ODBC][4787][1539734703.466709][__handles.c][460] Exit:[SQL_SUCCESS] Environment = 0x2432cd0 [ODBC][4787][1539734703.466760][SQLSetEnvAttr.c][189] Entry: Environment = 0x2432cd0 Attribute = SQL_ATTR_ODBC_VERSION Value = 0x3 StrLen = 0 [ODBC][4787][1539734703.466769][SQLSetEnvAttr.c][363] Exit:[SQL_SUCCESS] [ODBC][4787][1539734703.466776][SQLAllocHandle.c][375] Entry: Handle Type = 2 Input Handle = 0x2432cd0 [ODBC][4787][1539734703.466783][SQLAllocHandle.c][493] Exit:[SQL_SUCCESS] Output Handle = 0x24bc7f0 [ODBC][4787][1539734703.466794][SQLDriverConnect.c][726] Entry: Connection = 0x24bc7f0 Window Hdl = (nil) Str In = [DSN=BLUE][length = 8 (SQL_NTS)] Str Out = 0x7ffec5a2d370 Str Out Max = 1024 Str Out Ptr = 0x7ffec5a2d34e Completion = 1 UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE '' connection details removed. [ODBC][4787][1539734705.934065][SQLAllocHandle.c][540] Entry: Handle Type = 3 Input Handle = 0x24bc7f0 [ODBC][4787][1539734705.934091][SQLAllocHandle.c][1081] Exit:[SQL_SUCCESS] Output Handle = 0x24fc9e0 [ODBC][4787][1539734705.934106][SQLExecDirect.c][240] Entry: Statement = 0x24fc9e0 SQL = [select count(*) from rkrishna.fdwtest][length = 37 (SQL_NTS)] [ODBC][4787][1539734705.935348][SQLExecDirect.c][503] Exit:[SQL_SUCCESS] [ODBC][4787][1539734705.935389][SQLFetch.c][162] Entry: Statement = 0x24fc9e0 [ODBC][4787][1539734705.935431][SQLFetch.c][348] Exit:[SQL_SUCCESS] [ODBC][4787][1539734705.935466][SQLGetData.c][237] Entry: Statement = 0x24fc9e0 Column Number = 1 Target Type = -27 SQL_C_SBIGINT Buffer Length = 0 Target Value = 0x7ffec5a2d7d0 StrLen Or Ind = 0x7ffec5a2d7d8 [ODBC][4787][1539734705.935515][SQLGetData.c][501] Exit:[SQL_SUCCESS] Buffer = [Data...] Strlen Or Ind = 0x7ffec5a2d7d8 -> 8 [ODBC][4787][1539734705.935552][SQLFreeHandle.c][381] Entry: Handle Type = 3 Input Handle = 0x24fc9e0 [ODBC][4787][1539734705.936176][SQLFreeHandle.c][491] Exit:[SQL_SUCCESS] [ODBC][4787][1539734705.936195][SQLFreeHandle.c][284] Entry: Handle Type = 2 Input Handle = 0x24bc7f0 [ODBC][4787][1539734705.936205][SQLFreeHandle.c][298]Error: HY010 [ODBC][4787][1539734705.936222][SQLFreeHandle.c][219] Entry: Handle Type = 1 Input Handle = 0x2432cd0 [ODBC][4787][1539734705.936233][SQLFreeHandle.c][233]Error: HY010 [ODBC][4787][1539734705.936362][__handles.c][460] Exit:[SQL_SUCCESS] Environment = 0x24fbb30 [ODBC][4787][1539734705.936407][SQLSetEnvAttr.c][189] Entry: Environment = 0x24fbb30 Attribute = SQL_ATTR_ODBC_VERSION Value = 0x3 StrLen = 0 [ODBC][4787][1539734705.936419][SQLSetEnvAttr.c][363] Exit:[SQL_SUCCESS] [ODBC][4787][1539734705.936431][SQLAllocHandle.c][375] Entry: Handle Type = 2 Input Handle = 0x24fbb30 [ODBC][4787][1539734705.936453][SQLAllocHandle.c][493] Exit:[SQL_SUCCESS] Output Handle = 0x2526b90 [ODBC][4787][1539734705.936466][SQLDriverConnect.c][726] Entry: Connection = 0x2526b90 Window Hdl = (nil) Str In = [DSN=BLUE][length = 8 (SQL_NTS)] Str Out = 0x7ffec5a2d3a0 Str Out Max = 1024 Str Out Ptr = 0x7ffec5a2d37e Completion = 1 UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE '' [ODBC][4787][1539734708.340223][SQLExecDirect.c][240] Entry: Statement = 0x24fe2e0 SQL = [select count(*) from rkrishna.fdwtest][length = 37 (SQL_NTS)] [ODBC][4787][1539734708.380473][SQLExecDirect.c][503] Exit:[SQL_SUCCESS] [ODBC][4787][1539734708.380501][SQLFetch.c][162] Entry: Statement = 0x24fe2e0 [ODBC][4787][1539734708.380523][SQLFetch.c][348] Exit:[SQL_SUCCESS] [ODBC][4787][1539734708.380536][SQLGetData.c][237] Entry: Statement = 0x24fe2e0 Column Number = 1 Target Type = -27 SQL_C_SBIGINT Buffer Length = 0 Target Value = 0x7ffec5a2d800 StrLen Or Ind = 0x7ffec5a2d808 [ODBC][4787][1539734708.380555][SQLGetData.c][501] Exit:[SQL_SUCCESS] Buffer = [Data...] Strlen Or Ind = 0x7ffec5a2d808 -> 8 [ODBC][4787][1539734708.380567][SQLFreeHandle.c][381] Entry: Handle Type = 3 Input Handle = 0x24fe2e0 [ODBC][4787][1539734708.381263][SQLFreeHandle.c][491] Exit:[SQL_SUCCESS] [ODBC][4787][1539734708.381281][SQLFreeHandle.c][284] Entry: Handle Type = 2 Input Handle = 0x2526b90 [ODBC][4787][1539734708.381292][SQLFreeHandle.c][298]Error: HY010 [ODBC][4787][1539734708.381314][SQLFreeHandle.c][219] Entry: Handle Type = 1 Input Handle = 0x24fbb30 [ODBC][4787][1539734708.381326][SQLFreeHandle.c][233]Error: HY010 [ODBC][4787][1539734708.381400][__handles.c][460] Exit:[SQL_SUCCESS] Environment = 0x2519280 [ODBC][4787][1539734708.381418][SQLSetEnvAttr.c][189] Entry: Environment = 0x2519280 Attribute = SQL_ATTR_ODBC_VERSION Value = 0x3 StrLen = 0 [ODBC][4787][1539734708.381429][SQLSetEnvAttr.c][363] Exit:[SQL_SUCCESS] [ODBC][4787][1539734708.381440][SQLAllocHandle.c][375] Entry: Handle Type = 2 Input Handle = 0x2519280 [ODBC][4787][1539734708.381452][SQLAllocHandle.c][493] Exit:[SQL_SUCCESS] Output Handle = 0x253d320 [ODBC][4787][1539734708.381465][SQLDriverConnect.c][726] Entry: Connection = 0x253d320 Window Hdl = (nil) Str In = [DSN=BLUE][length = 8 (SQL_NTS)] Str Out = 0x7ffec5a2d5b0 Str Out Max = 1024 Str Out Ptr = 0x7ffec5a2d58e Completion = 1 UNICODE Using encoding ASCII 'ISO8859-1' and UNICODE ''