<div dir="ltr">On Thu, 23 Oct 2014 11:38:37 -0400 Pablo Virgo <<a href="mailto:medusa.v2@gmail.com">medusa.v2@gmail.com</a>> wrote:<br>> I'm working on a small perl script that pulls random records from an sqlite3<br>> database.  Typically, as with the sqlite interface or cpan installations of<br>> this module, I can do this with a simple "ORDER BY RANDOM() LIMIT 1" clause.<br>> For some reason, when I use the .deb package version of the library, the result<br>> of that clause is always the first matching database record rather than a<br>> random one.<br><div>I've tried to reproduce this problem on <span style="color:rgb(0,0,0);line-height:19.2000007629395px">libdbd-sqlite3-perl 1.37-1, 1.40-2 and 1.44-1 without success.</span></div><div><font color="#000000"><span style="line-height:19.2000007629395px">Below is what was done to try and reproduce the problem:</span></font></div><div><font color="#000000"><span style="line-height:19.2000007629395px">arnestig@debian:~$ sqlite3 database.db "CREATE TABLE test (id INTEGER, data VARCHAR)"</span></font><br></div><div><div style><font color="#000000"><span style="line-height:19.2000007629395px"><div>arnestig@debian:~$ sqlite3 database.db "INSERT INTO test VALUES( 1, 'item1' )"</div><div>arnestig@debian:~$ sqlite3 database.db "INSERT INTO test VALUES( 2, 'item2' )"</div><div>arnestig@debian:~$ sqlite3 database.db "INSERT INTO test VALUES( 3, 'item3' )"</div><div><span style="line-height:19.2000007629395px">arnestig@debian:~$ perl -e 'use DBD::SQLite; my $dbh = DBI->connect("DBI:SQLite:dbname=database.db"); my $stmt = "SELECT * FROM test ORDER BY RANDOM() LIMIT 1"; my $sth = $dbh->prepare( $stmt ); my $rv = $sth->execute() or die $DBI::errstr; while(my @row = $sth->fetchrow_array()) { print "Result: $row[0],$row[1]\n"; }'</span><br></div></span></font></div><div style><font color="#000000"><span style="line-height:19.2000007629395px">Result: 2,item2</span></font></div><div style><font color="#000000"><span style="line-height:19.2000007629395px">arnestig@debian:~$ perl -e 'use DBD::SQLite; my $dbh = DBI->connect("DBI:SQLite:dbname=database.db"); my $stmt = "SELECT * FROM test ORDER BY RANDOM() LIMIT 1"; my $sth = $dbh->prepare( $stmt ); my $rv = $sth->execute() or die $DBI::errstr; while(my @row = $sth->fetchrow_array()) { print "</span></font><span style="color:rgb(0,0,0);line-height:19.2000007629395px">Result:</span><span style="color:rgb(0,0,0);line-height:19.2000007629395px"> </span><span style="line-height:19.2000007629395px;color:rgb(0,0,0)">$row[0],$row[1]\n"; }'</span></div><div style><font color="#000000"><span style="line-height:19.2000007629395px">Result: 3,item3</span></font></div><div style><font color="#000000"><span style="line-height:19.2000007629395px">arnestig@debian:~$ perl -e 'use DBD::SQLite; my $dbh = DBI->connect("DBI:SQLite:dbname=database.db"); my $stmt = "SELECT * FROM test ORDER BY RANDOM() LIMIT 1"; my $sth = $dbh->prepare( $stmt ); my $rv = $sth->execute() or die $DBI::errstr; while(my @row = $sth->fetchrow_array()) { print "</span></font><span style="color:rgb(0,0,0);line-height:19.2000007629395px">Result:</span><span style="color:rgb(0,0,0);line-height:19.2000007629395px"> </span><span style="line-height:19.2000007629395px;color:rgb(0,0,0)">$row[0],$row[1]\n"; }'</span></div><div style><span style="color:rgb(0,0,0);line-height:19.2000007629395px">Result:</span><span style="color:rgb(0,0,0);line-height:19.2000007629395px"> </span><font color="#000000"><span style="line-height:19.2000007629395px">1,item1</span></font></div><div style><font color="#000000"><span style="line-height:19.2000007629395px">arnestig@debian:~$ perl -e 'use DBD::SQLite; my $dbh = DBI->connect("DBI:SQLite:dbname=database.db"); my $stmt = "SELECT * FROM test ORDER BY RANDOM() LIMIT 1"; my $sth = $dbh->prepare( $stmt ); my $rv = $sth->execute() or die $DBI::errstr; while(my @row = $sth->fetchrow_array()) { print "</span></font><span style="color:rgb(0,0,0);line-height:19.2000007629395px">Result:</span><span style="color:rgb(0,0,0);line-height:19.2000007629395px"> </span><span style="line-height:19.2000007629395px;color:rgb(0,0,0)">$row[0],$row[1]\n"; }'</span></div><div style><span style="color:rgb(0,0,0);line-height:19.2000007629395px">Result:</span><span style="color:rgb(0,0,0);line-height:19.2000007629395px"> </span><font color="#000000"><span style="line-height:19.2000007629395px">2,item2</span></font></div><div style><br></div></div><div style>Please let us know if you have more information on how to reproduce the problem.</div><div style><br></div><div style> - Tobias</div></div>