Re: [sqlite] sqlite 3.22.0 read-only WAL mode clarifications

2018-02-09 Thread Simon Slavin


On 9 Feb 2018, at 10:50am, Leonard Lausen  wrote:

> sqlite 3.22.0 added the ability to read from WAL mode databases even if
> the application lacks write permission on the database and its
> containing directory, as long as the -shm and -wal files exist in that
> directory.
> 
> Even though the wiki page states that WAL does not work over a network
> filesystem, I am able to use WAL over a network filesystem when using
> sqlite 3.22.0 as long as the respective -shm and -wal files exist. (This
> may or may not work with earlier versions.)

Yes, you are getting results for the pattern of access you tried.  That doesn't 
mean you'll not start getting error messages or corrupted files when you try 
something else.  The problem is not with reading files, it's with locking.

> Could someone clarify if this is intended or may result in database
> corruption? (I am only reading from the database on the remote host)

You note above unusual circumstances: "even if the application lacks write 
permission on the database and its containing directory".  

Will any of the processes accessing the database have write permission ?  If 
not, if they're all just reading the existing database, then there's no 
opportunity for corruption.  Think of it as

1) Reading a database while it's being written to may yield corrupt results.  
SQLite uses locking to avoid this.
2) Two processes writing a database at once will corrupt the database.  SQLite 
uses locking to avoid this.
3) Locking does not work properly across a network

and you'll figure out the danger scenarios.

Simon.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] sqlite 3.22.0 read-only WAL mode clarifications

2018-02-09 Thread Richard Hipp
On 2/9/18, Leonard Lausen  wrote:
> sqlite 3.22.0 added the ability to read from WAL mode databases even if
> the application lacks write permission on the database and its
> containing directory, as long as the -shm and -wal files exist in that
> directory.
>
> Even though the wiki page states that WAL does not work over a network
> filesystem, I am able to use WAL over a network filesystem when using
> sqlite 3.22.0 as long as the respective -shm and -wal files exist. (This
> may or may not work with earlier versions.)
>
> Could someone clarify if this is intended or may result in database
> corruption? (I am only reading from the database on the remote host)

Wal relies on a small amount of shared memory to coordinate activities
between clients.  On unix, the shared memory is implemented by calling
mmap() on the -shm file.

If two or more clients connect from different hosts, then obviously
they cannot share the same memory.  In that case, WAL will
malfunction.

It may have worked for you in your test.  But that just means you
didn't test it enough.

>
> Is there some way to force the -shm and -wal files to always be present?
>

https://www.sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlpersistwal
-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] sqlite 3.22.0 read-only WAL mode clarifications

2018-02-09 Thread Leonard Lausen
sqlite 3.22.0 added the ability to read from WAL mode databases even if
the application lacks write permission on the database and its
containing directory, as long as the -shm and -wal files exist in that
directory.

Even though the wiki page states that WAL does not work over a network
filesystem, I am able to use WAL over a network filesystem when using
sqlite 3.22.0 as long as the respective -shm and -wal files exist. (This
may or may not work with earlier versions.)

Could someone clarify if this is intended or may result in database
corruption? (I am only reading from the database on the remote host)

Is there some way to force the -shm and -wal files to always be present?

Best regards
Leonard

PS: The details of the network filesystem mount: hostname:/home/data on
/home/hostname type nfs4
(ro,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=IPADDR,local_lock=none,addr=IPADDR)

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] -Wsign-compare warning in lempar.c

2018-02-09 Thread Richard Hipp
On 2/9/18, Richard Damon  wrote:
> On 2/8/18 9:21 AM, Nick Wellnhofer wrote:
>> With the latest Lemon code, I get a warning under GCC with
>> -Wsign-compare:
>>
>> warning: comparison between signed and unsigned integer expressions
>> [-Wsign-compare]
>>  assert( i>=0 &&
>> i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );
>>^
>>
>> Nick
> Looks like not a problem. The danger of comparing a signed value to an
> unsigned is that you can get an unexpected result if the signed value is
> negative, but in this case we first check that i is positive, so that
> issue never occurs.

Correct.  The previous term of the assert() guarantees that variable i
is non-negative.

This is nuisance warning (as are most warnings, actually).  We'll fix
it though, just to reduce bandwidth on the mailing list.

-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] -Wsign-compare warning in lempar.c

2018-02-09 Thread Richard Damon

On 2/8/18 9:21 AM, Nick Wellnhofer wrote:
With the latest Lemon code, I get a warning under GCC with 
-Wsign-compare:


warning: comparison between signed and unsigned integer expressions 
[-Wsign-compare]
 assert( i>=0 && 
i+YYNTOKEN<=sizeof(yy_lookahead)/sizeof(yy_lookahead[0]) );

   ^

Nick 
Looks like not a problem. The danger of comparing a signed value to an 
unsigned is that you can get an unexpected result if the signed value is 
negative, but in this case we first check that i is positive, so that 
issue never occurs.


--
Richard Damon

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users