Bug in CONCAT function blocks input of strings longer than 1 MB
am 04.03.2003 15:13:10 von Dmitry Kuznetsov>Description:
A PERL/DBI script (attached) was used to input long strings from files into MyISAM table
using CONCAT function. Each file contains a string splitted over several lines. If length
of the string attempted to input is less ~1 Mb, all goes OK. Othewise, multiple characters
become lost, and the string attempted to input in DB become trncated. Amount of lost
characters is random, often 0 bytes goes to DB.
>How-To-Repeat:
2 data input files might be retrieved from:
http://ludwig-sun1.unil.ch/~dkuznets/good.seq
http://ludwig-sun1.unil.ch/~dkuznets/bad.seq
The script connects to "my-host"(should be changed), DB "test" as user "test" without password
and reads data from input file being supplied as the first argument. After completion, it prints
count of bytes read from the input file, and length of the string being input in the DB.
The actual output from the script with 1st file (good.seq) as input:
175531 bytes uploaded, 175531 are in DB
The actual output from the script with 2nd file (bad.seq) as input:
1144924 bytes uploaded, are in DB
(missing value is "undef" returned by the query, actually there are 0 bytes in DB)
The script itself:
############################## cut here #################################
#!/usr/local/bin/perl
use DBI;
die "Usage: $0 data_file\n" if (@ARGV == 0);
my $dsn_b = "DBI:mysql:database=test;host=my-host";
my $db_h = DBI->connect($dsn_b,'test') || die $DBI::errstr;
$db_h->do('CREATE TABLE IF NOT EXISTS Table_A (LongString LONGTEXT)');
$db_h->do('DELETE from Table_A');
$sth_insert = $db_h->prepare("INSERT into Table_A (LongString) values (?)");
$sth_update = $db_h->prepare("UPDATE Table_A SET LongString=CONCAT(LongString,?)");
$sth_select = $db_h->prepare("SELECT length(LongString) FROM Table_A");
$ActualChars=0;
while (<>) {
chomp ($_);
if (not defined ($ok)){ # first insert
$sth_insert->execute($_);
$ok='y';
}
else {
$sth_update->execute($_);
}
$TotalChars += length ($_);
}
$sth_select->execute();
$ActualChars = $sth_select->fetchrow_array;
print "$TotalChars bytes uploaded, $ActualChars are in DB\n";
$sth_select->finish;
$db_h->disconnect;
################################## cut here #######################################
>Fix:
Not known :-((
>Submitter-Id: N/A
>Originator: N/A
>Organization:
Ludwig Institute for Cancer Research, ITO
ch. Boveresses 155, CH-1066 Epalinges
Switzerland
>MySQL support: none
>Synopsis: Bug in CONCAT function blocks input of strings longer than 1 MB
>Severity:
>Priority:
>Category: mysql
>Class:
>Release: mysql-3.23.53a-max (Official MySQL-max binary), downloaded and installed without changes
>Environment:
PERL v5.6.1 built for sun4-solaris
DBI 1.21
System: SunOS ludwig-sun3 5.8 Generic_108528-09 sun4u sparc SUNW,Ultra-250, 2 CPUs, 2Gb RAM
Architecture: sun4
Some paths: /usr/local/bin/perl /usr/local/bin/make /usr/local/bin/gcc /opt/SUNWspro/bin/cc
GCC: Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/3.2.1/specs
Configured with: ../configure --disable-nls --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld
Thread model: posix
gcc version 3.2.1
Compilation info: CC='gcc' CFLAGS='-O3 -fno-omit-frame-pointer' CXX='gcc' CXXFLAGS='-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti' LDFLAGS=''
LIBC:
-rw-r--r-- 1 root bin 1759400 Jul 31 2001 /lib/libc.a
lrwxrwxrwx 1 root root 11 Nov 7 2001 /lib/libc.so -> ./libc.so.1
-rwxr-xr-x 1 root bin 1136720 Jul 31 2001 /lib/libc.so.1
-rw-r--r-- 1 root bin 1759400 Jul 31 2001 /usr/lib/libc.a
lrwxrwxrwx 1 root root 11 Nov 7 2001 /usr/lib/libc.so -> ./libc.so.1
-rwxr-xr-x 1 root bin 1136720 Jul 31 2001 /usr/lib/libc.so.1
Configure command: ./configure --prefix=/usr/local/mysql '--with-comment=Official MySQL-max binary' --with-extra-charsets=complex --with-server-suffix=-max --enable-thread-safe-client --enable-local-infile --enable-assembler --disable-shared --with-innodb CC=gcc 'CFLAGS=-O3 -fno-omit-frame-pointer' 'CXXFLAGS=-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti' CXX=gcc
------------------------------------------------------------ ---------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail bugs-thread13892@lists.mysql.com
To unsubscribe, e-mail