Обсуждение: Reported lengths of char fields - psqlODBC
Environment:
Linux Mint 18.3 x64 (base on Ubuntu 16.04 package base)
Postgresql v 9.5.14
unixODBC v2.3.1-4.1
psqlODBC v1:09.03.0300-1
I created a simple table containing one column of type character (n). When I ask for the width of the column via (ODBC)SQLColAttribute function, it answers (n*6) , so if defined as character(1) the call reports length 6, character(2) reports 12, character(4) reports 24, etc.
I see the same kind of results when using a varchar(n) field (character varying (2), etc ) as well .
Is this expected, or am I doing something wrong?
Thanks,
Bob
Bob Brodd wrote: > Postgresql v 9.5.14 > psqlODBC v1:09.03.0300-1 Please note that newer versions of the ODBC driver are backwards compatible, and have bug fixes. > I created a simple table containing one column of type character (n). > When I ask for the width of the column via (ODBC)SQLColAttribute function, > it answers (n*6) I guess you are asking not for SQL_DESC_LENGTH but SQL_DESC_OCTET_LENGTH? The latter multiplies the column size (in characters) by the maximum possible number of bytes per character, which is 4 in the Unicode driver, and 6 when using UTF-8 as client encoding. (In driver version 9.6.3, the UTF-8 value was corrected to 4.) Regards, Clemens