Subject: | DBD-Sybase does not support [n]varchar(max) |
Date: | Tue, 12 Jul 2016 16:22:51 +1200 |
To: | bug-DBD-Sybase [...] rt.cpan.org |
From: | Andrew Thompson <thompsa [...] freebsd.org> |
Using p5-DBD-Sybase-1.15
In dbdimp.c line 3271 the code is
imp_sth->datafmt[i].maxlength = get_cwidth(&imp_sth->datafmt[i])
+ 1;
maxlength and get_cwidth are both signed int types so when the column is
varchar(max) the get_cwidth() call returns 2147483647
2147483647 + 1 = -2147483648
When this is cast to size_t for the Perl_safesysmalloc() call (via New
macro) it tries to allocate 18446744071562067968 bytes (on 64bit arch). The
script will exit with "Out of memory!" error.
The maxlength may need to check for overflow but I am unsure how to handle
the +1 byte padding.
Andrew