Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 110439
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: mcarey [...] ucar.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Add support for $dbh->{ReadOnly} attribute
Date: Fri, 18 Dec 2015 11:20:55 -0700
To: bug-DBD-SQLite [...] rt.cpan.org
From: Maxwell Carey <mcarey [...] ucar.edu>
DBI provides the ReadOnly handle attribute ( https://metacpan.org/pod/DBI#ReadOnly) and says: "If the driver can make the handle truly read-only then it should (unless doing so would have unpleasant side effect, like changing the consistency level from per-statement to per-session)...If the driver cannot ensure the ReadOnly attribute is adhered to it will record a warning." However, DBD::SQLite doesn't appear to honor this: use strict;use warnings; use Data::Dump;use DBI; my $db = 'foo.db'; unlink $db if -f $db; my $dbh = DBI->connect("dbi:SQLite:dbname=$db",'','', { RaiseError => 1, ReadOnly => 1}); $dbh->do( q{CREATE TABLE foo(id INTEGER, name TEXT)} ); $dbh->do( q{INSERT INTO foo VALUES(1, 'foo')} );my $values = $dbh->selectall_arrayref( q{SELECT * FROM foo} ); dd $values; __END__ [[1, "foo"]] Not only are the database and table created and values inserted, but there's also no warning (promised by the DBI docs) that ReadOnly is being ignored. Since making handles truly read-only IS possible, I think ReadOnly => 1 should simply have the same behavior as sqlite_open_flags => DBD::SQLite::OPEN_READONLY
Implemented in 1.49_05. Thanks. On Sat Dec 19 03:21:26 2015, mcarey@ucar.edu wrote: Show quoted text
> DBI provides the ReadOnly handle attribute ( > https://metacpan.org/pod/DBI#ReadOnly) and says: > > "If the driver can make the handle truly read-only then it should (unless > doing so would have unpleasant side effect, like changing the consistency > level from per-statement to per-session)...If the driver cannot ensure the > ReadOnly attribute is adhered to it will record a warning." > > However, DBD::SQLite doesn't appear to honor this: > > use strict;use warnings; > use Data::Dump;use DBI; > my $db = 'foo.db'; > unlink $db if -f $db; > my $dbh = DBI->connect("dbi:SQLite:dbname=$db",'','', { > RaiseError => 1, > ReadOnly => 1}); > > $dbh->do( q{CREATE TABLE foo(id INTEGER, name TEXT)} ); > $dbh->do( q{INSERT INTO foo VALUES(1, 'foo')} );my $values = > $dbh->selectall_arrayref( q{SELECT * FROM foo} ); > > dd $values; > __END__ > [[1, "foo"]] > > Not only are the database and table created and values inserted, but > there's also no warning > (promised by the DBI docs) that ReadOnly is being ignored. > > Since making handles truly read-only IS possible, I think > > ReadOnly => 1 > > should simply have the same behavior as > > sqlite_open_flags => DBD::SQLite::OPEN_READONLY
Closed as 1.50 was shipped. Thanks.