Hi,
I found a bug which psqlODBC returns a string without null-terminated when SQLFetch is executed on Windows.
IMHO, it seems to be caused by differences of snprintf function between Windows and Linux.
You have changed sprintf into snprintf at psqlodbc-09.03.0400 release.
But snprintf on Windows(_snprintf) doesn't include a terminating character(\0) when a copy buffer length is less than
anoriginal buffer length; besides this returns -1.
Their behavior are different from that of Linux but psqlODBC does not currently make allowances for their differences.
As you can confirm this bug, I attached a program(test.cpp) which reproduces a bug.
This result is following.
----
Please Enter key...
SQLAllocHandle() OK
SQLAllocHandle() ok
SQLConnect ok
data-length=24
length=-1 //invalid length
2015-09-15 17:48:44.7300フフフフフフフフフフフフフフフフ・ //unterminated string
no data
---
To fix this behavior, copy_and_convert_field function and stime2timestamp function need to repair at least.
I tried to fix it up and attached a patch on this mail.
Could you confirm this?
Best Regards
---
Naoya Anzai
Engineering Department
NEC Solution Inovetors, Ltd.
E-Mail: nao-anzai@xc.jp.nec.com
---