DBD::Informix, 451 errors & Linux
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
Hi: I have found that if you insert an empty string ('') into a TEXT IN TABLE column using DBD::Informix, then later fetching that row of the table causes a 451 `Locator buffer size too small' error. Actually, the failure happens only if you fetch two rows, and the first row is badly formed like this. Has anyone seen this? I've looked into this in depth, and the DBD::Informix code seems to be doing the correct thing, but the ESQL/C library seems broken. Any help, or suggestions how to proceed? Rich. -- rich@annexia.org | Free email for life at: http://www.postmaster.co.uk/ BiblioTech Ltd, Unit 2 Piper Centre, 50 Carnwath Road, London, SW6 3EG. +44 171 384 6917 | Click here to play XRacer: http://xracer.annexia.org/ --- Original message content Copyright © 1999 Richard Jones ---
rich@no-annexia-spam.org wrote: : Hi: : I have found that if you insert an empty string ('') : into a TEXT IN TABLE column using DBD::Informix, then : later fetching that row of the table causes a 451 : `Locator buffer size too small' error. Actually, the : failure happens only if you fetch two rows, and the : first row is badly formed like this. Here's some code which reproduces this bug. You have to create a database called 'test_451' on a server somewhere, and edit the 'XXX' strings in the code before running it. You can also play with the order of the inserted rows. The order in which the rows are selected seems to matter. I can only reproduce the bug when the first row which is fetched contains the '' empty string. Rearranging so that this row is fetched second makes it all work fine ... odd. When run as it stands: connecting to database ... dropping existing test table ... creating new test table ... inserting data ... selecting data ... fetching rows ... fetched row: ,1 DBD::Informix::st fetch failed: SQL: -451: Locator buffer size too small. disconnecting ... When I rearrange the rows: connecting to database ... dropping existing test table ... creating new test table ... inserting data ... selecting data ... fetching rows ... fetched row: abc,1 fetched row: ,2 fetched row: def,3 disconnecting ... Rich. Platform: Linux IDS 7.30.UC7 DBD::Informix 0.61_02 DBI 1.06 ---------------------------------------------------------------------- #!/usr/bin/perl # # Copyright (C) 1999 Bibliotech Ltd., 631-633 Fulham Rd., London SW6 5UQ. # # $Id$ # Reproduce 451 errors with Perl. use DBI; use DBD::Informix; # Database settings. $ENV{INFORMIXSERVER} = 'XXXSERVER'; $database = 'test_451'; $user = 'XXXUSERNAME'; $pass = 'XXXPASSWORD'; # Connect to the database. print "connecting to database ...\\n"; $dbh = DBI->connect ("dbi:Informix:$database", $user, $pass) or die "cannot connect to database $database: $!"; # Drop any existing table. print "dropping existing test table ...\\n"; $dbh->do ("drop table test"); # Create new table. print "creating new test table ...\\n"; $dbh->do ("create table test (" . " col1 text in table," . " col2 int" . ")") or die "create table: $!"; # Insert a couple of rows. Note the first row # is a single '' (empty string, not a null) and # the second row is a string containing data. print "inserting data ...\\n"; $dbh->do ("insert into test (col1, col2) values (?, 1)", undef, '') or die "first insert: $!"; $dbh->do ("insert into test (col1, col2) values (?, 2)", undef, 'abc') or die "second insert: $!"; $dbh->do ("insert into test (col1, col2) values (?, 3)", undef, 'def') or die "third insert: $!"; # Select the rows. Order them so that the row # containing the empty string blob is fetched # first. print "selecting data ...\\n"; $sth = $dbh->prepare ("select col1, col2 from test order by col2") or die "prepare select: $!"; $sth->execute () or die "execute select: $!"; print "fetching rows ...\\n"; while ($ref = $sth->fetch) { my @row = @$ref; # Print the row. print "fetched row: ", $row[0], ",", $row[1], "\\n"; } if ($sth->{sqlcode} < 0) { die "error in fetch: sql code = ", $sth->{sqlcode}; } # Disconnect from database. print "disconnecting ...\\n"; $dbh->disconnect; -- rich@annexia.org | Free email for life at: http://www.postmaster.co.uk/ BiblioTech Ltd, Unit 2 Piper Centre, 50 Carnwath Road, London, SW6 3EG. +44 171 384 6917 | Click here to play XRacer: http://xracer.annexia.org/ --- Original message content Copyright © 1999 Richard Jones ---