[Midnight Commander] #4369: sqlite 3 view: use 'immutable=1' URI parameter to prevent leaving wal/shm files after viewing sqlite database

3 views
Skip to first unread message

Ticket System

unread,
Apr 27, 2022, 4:12:30 PM4/27/22
to karl...@gmail.com, mc-...@googlegroups.com
#4369: sqlite 3 view: use 'immutable=1' URI parameter to prevent leaving wal/shm
files after viewing sqlite database
--------------------------------+-----------------------------------
Reporter: karlicoss | Type: enhancement
Status: new | Priority: major
Milestone: Future Releases | Component: mcview
Version: master | Keywords: sqlite
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
--------------------------------+-----------------------------------
The problem I often had with viewing .sqlite files with mc is that exiting
the view mode mid-way may leave .wal/.shm files in the database directory.
This never caused any actual issues, but a bit annoying, since leftover
.wal files are often a sign that the program working with the database
exited ungracefully.
This effectively reproduces mc's behaviour:
/tmp/testsqlite $ rm -f *-wal *-shm && sqlite3 "/tmp/testsqlite/db
file.sqlite" .dump | head >/dev/null && ls -1 /tmp/testsqlite/
'db file.sqlite'
'db file.sqlite-shm'
'db file.sqlite-wal'

After the change -- no shm/wal files:
/tmp/testsqlite $ rm -f *-wal *-shm && sqlite3
"file:/tmp/testsqlite/db file.sqlite?immutable=1" .dump | head >/dev/null
&& ls -1 /tmp/testsqlite/
'db file.sqlite'

You can find the docs on immutable mode here
https://www.sqlite.org/uri.html#uriimmutable
Immutable mode has been supported in sqlite since 2014:
https://www.sqlite.org/changes.html#version_3_8_5
In case user's sqlite installation is older, the mode is just quietly
ignored, so the change is backwards compatible.

--
Ticket URL: <http://www.midnight-commander.org/ticket/4369>
Midnight Commander <https://midnight-commander.org>
Midnight Development Center

Ticket System

unread,
Apr 27, 2022, 4:19:57 PM4/27/22
to karl...@gmail.com, mc-...@googlegroups.com
#4369: sqlite 3 view: use 'immutable=1' URI parameter to prevent leaving wal/shm
files after viewing sqlite database
----------------------------+---------------------------------------
Reporter: karlicoss | Owner:

Type: enhancement | Status: new
Priority: major | Milestone: Future Releases
Component: mcview | Version: master
Resolution: | Keywords: sqlite

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
----------------------------+---------------------------------------

Comment (by karlicoss):

The only downside of this change is that now if you're trying to view a
database with an uncommitted WAL,the WAL is basically ignored, whereas
previously it would also display the changes in WAL.

This may or may not be desirable (personally I'd rather prefer for it not
to dump empty WAL files). If we want to preserve the old behaviour, could
change the viewer to be adaptive: if there are no existing -wal files, use
immutable mode; otherwise open in the default mode which would also
display uncommitted changes.

--
Ticket URL: <http://www.midnight-commander.org/ticket/4369#comment:1>

Ticket System

unread,
Apr 27, 2022, 4:42:41 PM4/27/22
to karl...@gmail.com, mc-...@googlegroups.com
#4369: sqlite 3 view: use 'immutable=1' URI parameter to prevent leaving wal/shm
files after viewing sqlite database
----------------------------+---------------------------------------
Reporter: karlicoss | Owner:

Type: enhancement | Status: new
Priority: major | Milestone: Future Releases
Component: mcview | Version: master
Resolution: | Keywords: sqlite

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
----------------------------+---------------------------------------

Comment (by karlicoss):

also in the meantime, if you want to achieve that behaviour, you can use
this in your local ext config (~/.config/mc/mc.ext)


{{{
# sqlite3.db
type/^SQLite 3.x database
Open=/usr/lib/mc/ext.d/misc.sh open sqlite
View=%view{ascii} sqlite3 file:%f?immutable=1 .dump

}}}

--
Ticket URL: <http://www.midnight-commander.org/ticket/4369#comment:2>

Ticket System

unread,
May 1, 2022, 2:53:26 AM5/1/22
to karl...@gmail.com, andrew....@gmail.com, mc-...@googlegroups.com
#4369: sqlite 3 view: use 'immutable=1' URI parameter to prevent leaving wal/shm
files after viewing sqlite database
----------------------------+----------------------------------------
Reporter: karlicoss | Owner: andrew_b
Type: enhancement | Status: closed
Priority: major | Milestone: 4.8.29
Component: mc-core | Version: master
Resolution: fixed | Keywords: sqlite
Blocked By: | Blocking:
Branch state: no branch | Votes for changeset: committed-master
----------------------------+----------------------------------------
Changes (by andrew_b):

* status: testing => closed


--
Ticket URL: <http://www.midnight-commander.org/ticket/4369#comment:5>

Ticket System

unread,
May 1, 2022, 2:53:26 AM5/1/22
to karl...@gmail.com, andrew....@gmail.com, mc-...@googlegroups.com
#4369: sqlite 3 view: use 'immutable=1' URI parameter to prevent leaving wal/shm
files after viewing sqlite database
----------------------------+----------------------------------------
Reporter: karlicoss | Owner: andrew_b
Type: enhancement | Status: testing

Priority: major | Milestone: 4.8.29
Component: mc-core | Version: master
Resolution: fixed | Keywords: sqlite
Blocked By: | Blocking:

Branch state: no branch | Votes for changeset: committed-master
----------------------------+----------------------------------------
Changes (by andrew_b):

* status: accepted => testing
* votes: => committed-master
* resolution: => fixed


Comment:

Thanks.
Applied as [ebbdc8847ecfedb587d494a6b85a76ec8f1c9e8b].

--
Ticket URL: <http://www.midnight-commander.org/ticket/4369#comment:4>

Ticket System

unread,
May 1, 2022, 2:53:29 AM5/1/22
to karl...@gmail.com, andrew....@gmail.com, mc-...@googlegroups.com
#4369: sqlite 3 view: use 'immutable=1' URI parameter to prevent leaving wal/shm
files after viewing sqlite database
----------------------------+--------------------------------
Reporter: karlicoss | Owner: andrew_b
Type: enhancement | Status: accepted

Priority: major | Milestone: 4.8.29
Component: mc-core | Version: master
Resolution: | Keywords: sqlite

Blocked By: | Blocking:
Branch state: no branch | Votes for changeset:
----------------------------+--------------------------------
Changes (by andrew_b):

* owner: => andrew_b
* status: new => accepted
* component: mcview => mc-core
* milestone: Future Releases => 4.8.29


--
Ticket URL: <http://www.midnight-commander.org/ticket/4369#comment:3>

Reply all
Reply to author
Forward
0 new messages