RawrUniversal / xerial

Automatically exported from code.google.com/p/xerial
0 stars 1 forks source link

Read-only database open support #19

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Changed to use sqlite3_open_v2 for supporting READ_ONLY database connection:
http://sqlite.org/c3ref/open.html

Original issue reported on code.google.com by taroleo on 18 Aug 2009 at 2:23

GoogleCodeExporter commented 8 years ago

Original comment by taroleo on 10 Sep 2009 at 5:56

GoogleCodeExporter commented 8 years ago
setting read_only mode when creating connection is simple, but supporting JDBC's
setReadOnly() method is needs adding proxy class for the db instance inside the
Conn.java class. The current implementation calls sqlite3_open() API when 
creating
the connection, and after that it is impossible to set read-only flag without 
closing
the database. 

Proxy class is for wrapping db instance. If db instance is not initialized, the
wrapper open's the database (and also set read_only flag as an argument to
sqlite3_open method), otherwise it simply returns the db instance. 

Original comment by taroleo on 25 Sep 2009 at 10:24

GoogleCodeExporter commented 8 years ago
changed the milestone

Original comment by taroleo on 25 Nov 2009 at 11:50

GoogleCodeExporter commented 8 years ago
Maybe it is not worth to introduce setReadOnly() support, for the following 
reasons:

- With this solution you still don't have support for SQLITE_OPEN_READWRITE & ~
SQLITE_OPEN_CREATE
- setReadOnly(false) on a read-only connection will not work (i.e. switching 
r/o on
and off will not work)

Original comment by thenl...@gmail.com on 7 Dec 2009 at 11:16

GoogleCodeExporter commented 8 years ago
Thanks for the suggestion.

So, it would be better to support this feature only when creating connections 
using properties object in DriverManager.getConnection(..., Properties prop). 

where the Properties object is initialized as follows:
Properties prop = new Properties();
prop.putProperty("readonly", "true");

A helper function might be necessary to correctly set these properties, for 
example, 

SQLiteConfig config = new SQLiteConfig();
config.readOnly(true);
config.enableSharedCache(true);

DriverManager.getConnection(..., config.toProperties());

Original comment by taroleo on 7 Dec 2009 at 11:35

GoogleCodeExporter commented 8 years ago
This issue was closed by revision 6d9beb7350.

Original comment by taroleo on 8 Dec 2009 at 6:10

GoogleCodeExporter commented 8 years ago

Original comment by taroleo on 12 Mar 2010 at 9:16