Here is a self-contained script. Sorry, I don't have access to another
environment (except for a VM with the same strawberry - btw., a portable
installation; DBI is 1.637, but updating to 1.642 didn't help)
use strict;
use DBI;
my($dbh, $sth, @data);
unlink "test.sqlite" or warn "Can't erase test.sqlite";
$dbh = DBI->connect("DBI:SQLite:dbname=test.sqlite", "", "");
$dbh->do("CREATE TABLE test_table (
t1 REAL default 0,
t2 REAL default 0,
t3 REAL default 0,
t4 REAL default 0);");
$dbh->do("INSERT INTO test_table (t1, t2, t3, t4) VALUES (1.1, 1.2, 1.3,
1.4);");
$dbh->do("INSERT INTO test_table (t1, t2, t3, t4) VALUES (2.1, 2.2, 2.3,
2.4);");
$dbh->do("INSERT INTO test_table (t1, t2, t3, t4) VALUES (3.1, 3.2, 3.3,
3.4);");
$dbh->do("INSERT INTO test_table (t1, t2, t3, t4) VALUES (4.1, 4.2, 4.3,
4.4);");
$sth = $dbh->prepare("SELECT t1, t2, t3, t4 FROM test_table;");
$sth->execute();
while (my $row_ref = $sth->fetchrow_arrayref) {
splice @$row_ref, 1, 1; # -- breaks if DBI:SQLite is used above
push @data, [ @$row_ref ]; # -- trying to copy array after
splice kills perl
#splice @{$data[-1]}, 1, 1; # -- alternate (working) solution:
splice on copy of array
}
for (my $i = 0; $i < scalar @data; $i++) {
print join ", ", @{$data[$i]};
print "\n";
}
On 27-Dec-18 22:05, Kenichi Ishigaki via RT wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=128121 >
>
> On Fri Dec 28 04:43:05 2018, Stefan_E wrote:
>> Thx, Ishigaki San, for providing DBD::SQLite!
>>
>> Running the following code on Strawberry perl 5.26.1 (64 bit, Win 7)
>> crashes at the line indicated. I'm currently porting some code from
>> mySQL to SQLite; same code had no problem with DBD::mysql. Issue is
>> reproduced with DBD::SQLite 1.54 and 1.60.
>>
>> use strict;
>> use DBI;
>> my($dbh, $sth, @data);
>>
>> $dbh = DBI->connect("DBI:SQLite:dbname=dummy1.sqlite", "", "");
>> $sth = $dbh->prepare("SELECT id, f_1397, f_1398, f_1399, f_1400 FROM
>> myTable;");
>> $sth->execute();
>>
>> while (my $row_ref = $sth->fetchrow_arrayref) {
>> splice @$row_ref, 1, 1; # -- breaks if DBI:SQLite is used above
>> push @data, [ @$row_ref ]; # -- trying to copy array after
>> splice kills perl (works without splice above)
>> #splice @{$data[-1]}, 1, 1; # -- alternate (working) solution:
>> splice on copy of array
>> }
>>
>> Thx. for your consideration
>>
>> Kind regards, Stefan
>>
> Couldn't reproduce the issue under almost the same environment (64bit Win7 + strawberry 5.26.3) and a few other environments.
>
> Could you make the script above a little more complete? (create a table and insert necessary data, set proper attributes, etc; please let it reproduce the issue by just running it.)
>
> And what happens if you run the same script under other OSes (in other words, isn't it your environmental issue, rather than DBD::SQLite's)?
>
> .
>