GNU bug report logs - #59346
Adding sqlite-backup

Previous Next

Package: emacs;

Reported by: Andrew Hyatt <ahyatt <at> gmail.com>

Date: Fri, 18 Nov 2022 02:41:01 UTC

Severity: wishlist

Tags: wontfix

To reply to this bug, email your comments to 59346 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Fri, 18 Nov 2022 02:41:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Andrew Hyatt <ahyatt <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 18 Nov 2022 02:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andrew Hyatt <ahyatt <at> gmail.com>
To: Bug-Gnu-Emacs <bug-gnu-emacs <at> gnu.org>
Subject: Adding sqlite-backup
Date: Thu, 17 Nov 2022 23:40:11 -0300
[Message part 1 (text/plain, inline)]
Currently there's no great way to perform a proper backup of a sqlite
database if you use the built-in sqlite in emacs 29.  If you just copy the
file, there's a chance another database user is in the middle of something,
and the database could be corrupted.

I've included a patch that fixes this. I would the sqlite-backup function
to exist so I can use it in the ELPA triples package.
[Message part 2 (text/html, inline)]
[0001-Add-sqlite-backup-a-function-to-backup-sqlite-databa.patch (application/octet-stream, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Fri, 18 Nov 2022 07:47:02 GMT) Full text and rfc822 format available.

Message #8 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrew Hyatt <ahyatt <at> gmail.com>
Cc: 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Fri, 18 Nov 2022 09:46:12 +0200
> From: Andrew Hyatt <ahyatt <at> gmail.com>
> Date: Thu, 17 Nov 2022 23:40:11 -0300
> 
> Currently there's no great way to perform a proper backup of a sqlite database if you use the built-in sqlite in
> emacs 29.  If you just copy the file, there's a chance another database user is in the middle of something,
> and the database could be corrupted.
> 
> I've included a patch that fixes this. I would the sqlite-backup function to exist so I can use it in the ELPA
> triples package.

Thanks, but I'm not sure Emacs should support DB administration
functions of sqlite.  Aren't there utilities out there which can be
used for this?  Why should we have this built-in in Emacs? why not
simply use shell-command or somesuch to invoke the necessary external
program?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Fri, 18 Nov 2022 12:07:02 GMT) Full text and rfc822 format available.

Message #11 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Hyatt <ahyatt <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Fri, 18 Nov 2022 09:05:58 -0300
[Message part 1 (text/plain, inline)]
On Fri, Nov 18, 2022 at 4:46 AM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Andrew Hyatt <ahyatt <at> gmail.com>
> > Date: Thu, 17 Nov 2022 23:40:11 -0300
> >
> > Currently there's no great way to perform a proper backup of a sqlite
> database if you use the built-in sqlite in
> > emacs 29.  If you just copy the file, there's a chance another database
> user is in the middle of something,
> > and the database could be corrupted.
> >
> > I've included a patch that fixes this. I would the sqlite-backup
> function to exist so I can use it in the ELPA
> > triples package.
>
> Thanks, but I'm not sure Emacs should support DB administration
> functions of sqlite.  Aren't there utilities out there which can be
> used for this?  Why should we have this built-in in Emacs? why not
> simply use shell-command or somesuch to invoke the necessary external
> program?
>

Good questions. Let me respond to your two questions: why does emacs need
to be involved in backups, and why can't it control backups some other way?

Emacs already has a file backup facility, but if emacs is primarily working
with data in sqlite, there is no mechanism for backups, which seems scary
to me.  I'd like modules that rely on sqlite for data to be able to back up
their data, because the user would like to have some security, knowing if
something goes wrong they can always restore a recent backup.

But why can't we do this by invoking backup via the binary?  Certainly a
possibility, and in fact that's how I would implement it if the sqlite
library was instead emacsql-sqlite.  However, I have no idea how to locate
the binary; that isn't part of the current built-in sqlite implementation.
For good reason, too, it's a built-in implementation, including a variable
holding the executable path seems odd.  I could add one, but this solution
seems better to me, since it doubles down on the built-in sqlite, and
doesn't provide an alternative mechanism for doing things with sqlite.

Hope this clarifies things, let me know if you have any other questions.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Fri, 18 Nov 2022 12:18:01 GMT) Full text and rfc822 format available.

Message #14 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrew Hyatt <ahyatt <at> gmail.com>
Cc: 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Fri, 18 Nov 2022 14:17:30 +0200
> From: Andrew Hyatt <ahyatt <at> gmail.com>
> Date: Fri, 18 Nov 2022 09:05:58 -0300
> Cc: 59346 <at> debbugs.gnu.org
> 
>  Thanks, but I'm not sure Emacs should support DB administration
>  functions of sqlite.  Aren't there utilities out there which can be
>  used for this?  Why should we have this built-in in Emacs? why not
>  simply use shell-command or somesuch to invoke the necessary external
>  program?
> 
> Good questions. Let me respond to your two questions: why does emacs need to be involved in backups,
> and why can't it control backups some other way?
> 
> Emacs already has a file backup facility, but if emacs is primarily working with data in sqlite, there is no
> mechanism for backups, which seems scary to me.  I'd like modules that rely on sqlite for data to be able to
> back up their data, because the user would like to have some security, knowing if something goes wrong
> they can always restore a recent backup.

A database is not like a normal file, and so the fact that Emacs has
backups doesn't seem to be a reason good enough to extend the backups
to DB operations.  We don't bother with this when we send email or do
other operations.  We also have auto-save and file-locks for normal
file, but not for DBs.  And a DB is not a file, it is a (large)
collection of tables and records, and Emacs deals with at most a
single table at a time, AFAIU.

More generally, DB administration is outside of the Emacs scope, and
how to do that properly is outside our expertise.  There's more to it
than just backing up the DB.

So I don't think we should extend the Emacs sqlite3 support in this
direction.

> But why can't we do this by invoking backup via the binary?  Certainly a possibility, and in fact that's how I
> would implement it if the sqlite library was instead emacsql-sqlite.  However, I have no idea how to locate the
> binary; that isn't part of the current built-in sqlite implementation.  For good reason, too, it's a built-in
> implementation, including a variable holding the executable path seems odd.  I could add one, but this
> solution seems better to me, since it doubles down on the built-in sqlite, and doesn't provide an alternative
> mechanism for doing things with sqlite.

This SO article:

  https://stackoverflow.com/questions/25675314/how-to-backup-sqlite-database

(which is the first hit I get if I "how to backup sqlite database"
into the browser search box) says that you can backup the DB by using
the sqlite3 executable.  I think it is reasonable to expect users who
want to backup their DB to have this executable and use it for that
purpose (and other purposes, as they need).  I do have this executable
here, FWIW.

So I think these needs should be fulfilled "by other means", not by
Emacs Lisp programs.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 02:06:01 GMT) Full text and rfc822 format available.

Message #17 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Hyatt <ahyatt <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Fri, 18 Nov 2022 23:05:20 -0300
[Message part 1 (text/plain, inline)]
On Fri, Nov 18, 2022 at 9:17 AM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Andrew Hyatt <ahyatt <at> gmail.com>
> > Date: Fri, 18 Nov 2022 09:05:58 -0300
> > Cc: 59346 <at> debbugs.gnu.org
> >
> >  Thanks, but I'm not sure Emacs should support DB administration
> >  functions of sqlite.  Aren't there utilities out there which can be
> >  used for this?  Why should we have this built-in in Emacs? why not
> >  simply use shell-command or somesuch to invoke the necessary external
> >  program?
> >
> > Good questions. Let me respond to your two questions: why does emacs
> need to be involved in backups,
> > and why can't it control backups some other way?
> >
> > Emacs already has a file backup facility, but if emacs is primarily
> working with data in sqlite, there is no
> > mechanism for backups, which seems scary to me.  I'd like modules that
> rely on sqlite for data to be able to
> > back up their data, because the user would like to have some security,
> knowing if something goes wrong
> > they can always restore a recent backup.
>
> A database is not like a normal file, and so the fact that Emacs has
> backups doesn't seem to be a reason good enough to extend the backups
> to DB operations.  We don't bother with this when we send email or do
> other operations.  We also have auto-save and file-locks for normal
> file, but not for DBs.  And a DB is not a file, it is a (large)
> collection of tables and records, and Emacs deals with at most a
> single table at a time, AFAIU.


> More generally, DB administration is outside of the Emacs scope, and
> how to do that properly is outside our expertise.  There's more to it
> than just backing up the DB.
>
> So I don't think we should extend the Emacs sqlite3 support in this
> direction.
>

I disagree, but I understand this is just a difference of opinion, so I'm
happy to let this patch sit here until there's more demand for this sort of
thing.

But if you are interested in furthering the conversation, which has a lot
to do with what I'm talking about in my upcoming (and already recorded)
Emacs conference talk, I don't think the distinction you are making between
files and databases is important.  Let's say I wanted to store, use and
otherwise manipulate contact information with emacs.  Right now that sort
of thing happens with a file with emacs-readable lists inside, but it's
really more natural to do it with a database.  The fact that it's done via
a file now seems historical, especially now that we have sqlite.  I expect
that sqlite will be used for this sort of thing more often.  However, if
there's no database option, then maybe not, since it won't be seen as
reliable as the filesystem.  I don't think it is reasonable to expect users
to figure out how to do this, even if the info is easy to find.  I'd like
us to be able to encourage the use of sqlite for data, and give the user a
good experience when sqlite is the backend.


>
> > But why can't we do this by invoking backup via the binary?  Certainly a
> possibility, and in fact that's how I
> > would implement it if the sqlite library was instead emacsql-sqlite.
> However, I have no idea how to locate the
> > binary; that isn't part of the current built-in sqlite implementation.
> For good reason, too, it's a built-in
> > implementation, including a variable holding the executable path seems
> odd.  I could add one, but this
> > solution seems better to me, since it doubles down on the built-in
> sqlite, and doesn't provide an alternative
> > mechanism for doing things with sqlite.
>
> This SO article:
>
>
> https://stackoverflow.com/questions/25675314/how-to-backup-sqlite-database
>
> (which is the first hit I get if I "how to backup sqlite database"
> into the browser search box) says that you can backup the DB by using
> the sqlite3 executable.  I think it is reasonable to expect users who
> want to backup their DB to have this executable and use it for that
> purpose (and other purposes, as they need).  I do have this executable
> here, FWIW.
>
> So I think these needs should be fulfilled "by other means", not by
> Emacs Lisp programs.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 05:05:02 GMT) Full text and rfc822 format available.

Message #20 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Andrew Hyatt <ahyatt <at> gmail.com>
Cc: 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Sat, 19 Nov 2022 07:52:33 +0300
* Andrew Hyatt <ahyatt <at> gmail.com> [2022-11-18 05:42]:
> Currently there's no great way to perform a proper backup of a sqlite
> database if you use the built-in sqlite in emacs 29.  If you just copy the
> file, there's a chance another database user is in the middle of something,
> and the database could be corrupted.
> 
> I've included a patch that fixes this. I would the sqlite-backup function
> to exist so I can use it in the ELPA triples package.

How I see those functions, that shall be included in Emacs as they are
standard part of SQLite.

SQLite Backup API:
https://www.sqlite.org/backup.html


-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 05:05:02 GMT) Full text and rfc822 format available.

Message #23 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Andrew Hyatt <ahyatt <at> gmail.com>, 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Sat, 19 Nov 2022 08:03:35 +0300
* Eli Zaretskii <eliz <at> gnu.org> [2022-11-18 10:48]:
> > From: Andrew Hyatt <ahyatt <at> gmail.com>
> > Date: Thu, 17 Nov 2022 23:40:11 -0300
> > 
> > Currently there's no great way to perform a proper backup of a sqlite database if you use the built-in sqlite in
> > emacs 29.  If you just copy the file, there's a chance another database user is in the middle of something,
> > and the database could be corrupted.
> > 
> > I've included a patch that fixes this. I would the sqlite-backup function to exist so I can use it in the ELPA
> > triples package.
> 
> Thanks, but I'm not sure Emacs should support DB administration
> functions of sqlite.  Aren't there utilities out there which can be
> used for this?  Why should we have this built-in in Emacs? why not
> simply use shell-command or somesuch to invoke the necessary external
> program?

sqlite functions in Emacs ARE database administration. Not only here
mentioned backup functions. I can read in the patch that it uses
proper way of backup for the SQLite.

And backup function is part of SQLite internals.

https://www.sqlite.org/backup.html

Using the SQLite Online Backup API

Historically, backups (copies) of SQLite databases have been created using the following method:

    Establish a shared lock on the database file using the SQLite API (i.e. the shell tool).
    Copy the database file using an external tool (for example the unix 'cp' utility or the DOS 'copy' command).
    Relinquish the shared lock on the database file obtained in step 1. 

This procedure works well in many scenarios and is usually very fast. However, this technique has the following shortcomings:

    Any database clients wishing to write to the database file while a backup is being created must wait until the shared lock is relinquished.
    It cannot be used to copy data to or from in-memory databases.
    If a power failure or operating system failure occurs while copying the database file the backup database may be corrupted following system recovery. 

The Online Backup API was created to address these concerns. The
online backup API allows the contents of one database to be copied
into another database file, replacing any original contents of the
target database. The copy operation may be done incrementally, in
which case the source database does not need to be locked for the
duration of the copy, only for the brief periods of time when it is
actually being read from. This allows other database users to continue
without excessive delays while a backup of an online database is made.

https://www.sqlite.org/c3ref/backup_finish.html#sqlite3backupinit

--
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 05:18:02 GMT) Full text and rfc822 format available.

Message #26 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Andrew Hyatt <ahyatt <at> gmail.com>, 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Sat, 19 Nov 2022 08:17:21 +0300
* Eli Zaretskii <eliz <at> gnu.org> [2022-11-18 15:18]:
> > From: Andrew Hyatt <ahyatt <at> gmail.com>
> > Date: Fri, 18 Nov 2022 09:05:58 -0300
> > Cc: 59346 <at> debbugs.gnu.org
> > 
> >  Thanks, but I'm not sure Emacs should support DB administration
> >  functions of sqlite.  Aren't there utilities out there which can be
> >  used for this?  Why should we have this built-in in Emacs? why not
> >  simply use shell-command or somesuch to invoke the necessary external
> >  program?
> > 
> > Good questions. Let me respond to your two questions: why does emacs need to be involved in backups,
> > and why can't it control backups some other way?
> > 
> > Emacs already has a file backup facility, but if emacs is primarily working with data in sqlite, there is no
> > mechanism for backups, which seems scary to me.  I'd like modules that rely on sqlite for data to be able to
> > back up their data, because the user would like to have some security, knowing if something goes wrong
> > they can always restore a recent backup.
> 
> A database is not like a normal file, and so the fact that Emacs has
> backups doesn't seem to be a reason good enough to extend the backups
> to DB operations.

In this case SQLite database is normal file. It is not text. But it is
definitely a file.

It requires usage of internal functions:

SQLite Backup API:
https://www.sqlite.org/backup.html

> We don't bother with this when we send email or do other operations.
> We also have auto-save and file-locks for normal file, but not for
> DBs.  And a DB is not a file, it is a (large) collection of tables
> and records, and Emacs deals with at most a single table at a time,
> AFAIU.

You mean it is not text file.

> More generally, DB administration is outside of the Emacs scope, and
> how to do that properly is outside our expertise.  There's more to it
> than just backing up the DB.

When there are sqlite functions included then so much of database
administration automatically becomes available to Emacs. Statement is
contradictory to the inclusion of SQLite.

> This SO article:
> 
>   https://stackoverflow.com/questions/25675314/how-to-backup-sqlite-database
> 
> (which is the first hit I get if I "how to backup sqlite database"
> into the browser search box) says that you can backup the DB by using
> the sqlite3 executable.  I think it is reasonable to expect users who
> want to backup their DB to have this executable and use it for that
> purpose (and other purposes, as they need).  I do have this executable
> here, FWIW.
> 
> So I think these needs should be fulfilled "by other means", not by
> Emacs Lisp programs.

That patch uses SQLite internals, without those, Emacs Lisp can't
properly backup the database. Without that patch, Emacs which does
support now SQLite would ask users to default to using external
program, like:

`sqlite3 currentDB.sqlite ".backup backuDB.sqlite"'

but how sure are you that you will have that external program
`sqlite3' in existence? 

When SQLite is already included in Emacs, it should not expect then
that external SQLite related software is available on the system.

It is logical that Emacs with SQLite included should have proper way
of doing backup without relying on external tools.

--
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 05:31:02 GMT) Full text and rfc822 format available.

Message #29 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Jean Louis <bugs <at> gnu.support>
To: Andrew Hyatt <ahyatt <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Sat, 19 Nov 2022 08:29:58 +0300
* Andrew Hyatt <ahyatt <at> gmail.com> [2022-11-19 05:07]:
> But if you are interested in furthering the conversation, which has a lot
> to do with what I'm talking about in my upcoming (and already recorded)
> Emacs conference talk, I don't think the distinction you are making between
> files and databases is important.  Let's say I wanted to store, use and
> otherwise manipulate contact information with emacs.  Right now that sort
> of thing happens with a file with emacs-readable lists inside, but it's
> really more natural to do it with a database.  The fact that it's done via
> a file now seems historical, especially now that we have sqlite.  I expect
> that sqlite will be used for this sort of thing more often.  However, if
> there's no database option, then maybe not, since it won't be seen as
> reliable as the filesystem.  I don't think it is reasonable to expect users
> to figure out how to do this, even if the info is easy to find.  I'd like
> us to be able to encourage the use of sqlite for data, and give the user a
> good experience when sqlite is the backend.

I totally agree on that.

I have already made SQLite version of CRM for Emacs by using SQLite,
but it is not polished for public, it will be soon.

Backing up database which does not run on the file system is
trivial. That often needs human interaction.

Though there are use cases when programs run continuously without
human interaction and where there are too many changes to the database
that one cannot just control by human.

Thus program itself should be able to reliably backup the database
while it is running without human supervision.

There are programs like sending of mailing list, sending thousands of
SMS messages, and such programs may run autonomously over days. That
is how my programs are designed. They may accept the sales lead and
re-check if any new person has subscribed, then dispatch e-mail and
SMS to that person.

Having reliable backup functions thus is necessary and useful in those
cases of running programs.

--
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/




Severity set to 'wishlist' from 'normal' Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 19 Nov 2022 07:47:02 GMT) Full text and rfc822 format available.

Added tag(s) wontfix. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 19 Nov 2022 07:47:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 07:53:02 GMT) Full text and rfc822 format available.

Message #36 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Jean Louis <bugs <at> gnu.support>
Cc: ahyatt <at> gmail.com, 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Sat, 19 Nov 2022 09:52:55 +0200
> Date: Sat, 19 Nov 2022 08:17:21 +0300
> From: Jean Louis <bugs <at> gnu.support>
> Cc: Andrew Hyatt <ahyatt <at> gmail.com>, 59346 <at> debbugs.gnu.org
> 
> When SQLite is already included in Emacs, it should not expect then
> that external SQLite related software is available on the system.

I disagree.  We included sqlite support in Emacs to let Lisp programs
gain access to databases, but we didn't intend to make Emacs a
platform for developing full-fledged sqlite applications.  And I see
nothing wrong with using external applications for DB administration,
especially since the tools to do that come with the same sqlite
installation as the library.

> It is logical that Emacs with SQLite included should have proper way
> of doing backup without relying on external tools.

You take that logic too far beyond our intent.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 08:08:02 GMT) Full text and rfc822 format available.

Message #39 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>, Andrew Hyatt <ahyatt <at> gmail.com>
Cc: 59346 <at> debbugs.gnu.org
Subject: Re: bug#59346: Adding sqlite-backup
Date: Sat, 19 Nov 2022 00:07:33 -0800
Eli Zaretskii <eliz <at> gnu.org> writes:

> A database is not like a normal file, and so the fact that Emacs has
> backups doesn't seem to be a reason good enough to extend the backups
> to DB operations.  We don't bother with this when we send email or do
> other operations.  We also have auto-save and file-locks for normal
> file, but not for DBs.  And a DB is not a file, it is a (large)
> collection of tables and records, and Emacs deals with at most a
> single table at a time, AFAIU.

IME, one key difference between sqlite and a more fully-featured RDBMS
like MySQL or PostgreSQL is that it is much easier to induce a
corruption.  It is true that, as long as we don't have bugs in Emacs or
sqlite, we should rarely see any issues.  (If anyone does run into any
bugs, they will thank us for providing a backup though.)

But since this is Emacs, and users are used to be able to just copy and
move files around inside of ~/.emacs.d, it is not unlikely that they
will treat the sqlite database file in the same way.  Especially if they
are not familiar with how sqlite works.  As we know, copying the file
around as its being written is one way of corrupting the database.[1]
This is just one example of how a corruption could happen.

Now, we could call this a "pilot error" and be done with it, or we could
try to provide some safety net.  I think the latter is preferable.

> More generally, DB administration is outside of the Emacs scope, and
> how to do that properly is outside our expertise.  There's more to it
> than just backing up the DB.

AFAIU, the concern here is data safety, for which backups should be good
enough.  But I don't know what other types of DB administration tasks
you have in mind.

> you can backup the DB by using the sqlite3 executable.  I think it is
> reasonable to expect users who want to backup their DB to have this
> executable and use it for that purpose

If it can be avoided, it would be better to not put that burden on
individual users.  For the same reasons we provide autosave files,
backup files, etc.

Footnotes:
[1]  https://www.sqlite.org/howtocorrupt.html




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 13:37:02 GMT) Full text and rfc822 format available.

Message #42 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Andrew Hyatt <ahyatt <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 59346 <at> debbugs.gnu.org, Jean Louis <bugs <at> gnu.support>
Subject: Re: bug#59346: Adding sqlite-backup
Date: Sat, 19 Nov 2022 10:36:39 -0300
[Message part 1 (text/plain, inline)]
On Sat, Nov 19, 2022 at 4:52 AM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > Date: Sat, 19 Nov 2022 08:17:21 +0300
> > From: Jean Louis <bugs <at> gnu.support>
> > Cc: Andrew Hyatt <ahyatt <at> gmail.com>, 59346 <at> debbugs.gnu.org
> >
> > When SQLite is already included in Emacs, it should not expect then
> > that external SQLite related software is available on the system.
>
> I disagree.  We included sqlite support in Emacs to let Lisp programs
> gain access to databases, but we didn't intend to make Emacs a
> platform for developing full-fledged sqlite applications.


I now see where you are coming from.  But I never knew your intentions and
have been working on SQLite-based applications. It seems I’m not the only
one. I think this represents a natural evolution where users are pushing
the system beyond what is intended. That’s not a bad thing, and I think
emacs should follow the desire paths carved out be users here.

It’s fine to wait until the trends are clearer, but I think this is a very
natural direction for module development, so its just a matter of time.

  And I see
> nothing wrong with using external applications for DB administration,
> especially since the tools to do that come with the same sqlite
> installation as the library.


>
> > It is logical that Emacs with SQLite included should have proper way
> > of doing backup without relying on external tools.
>
> You take that logic too far beyond our intent.
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59346; Package emacs. (Sat, 19 Nov 2022 13:52:01 GMT) Full text and rfc822 format available.

Message #45 received at 59346 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Andrew Hyatt <ahyatt <at> gmail.com>
Cc: 59346 <at> debbugs.gnu.org, bugs <at> gnu.support
Subject: Re: bug#59346: Adding sqlite-backup
Date: Sat, 19 Nov 2022 15:51:37 +0200
> From: Andrew Hyatt <ahyatt <at> gmail.com>
> Date: Sat, 19 Nov 2022 10:36:39 -0300
> Cc: 59346 <at> debbugs.gnu.org, Jean Louis <bugs <at> gnu.support>
> 
>  I disagree.  We included sqlite support in Emacs to let Lisp programs
>  gain access to databases, but we didn't intend to make Emacs a
>  platform for developing full-fledged sqlite applications.
> 
> I now see where you are coming from.  But I never knew your intentions and have been working on
> SQLite-based applications.

This is perfectly fine.  Emacs is Free Software: you can always patch
it to have the additional primitives you need, and develop any
applications you want based on that.  The issue being discussed here
is what should we provide in Emacs by default for all our users.
There's no intent to tell you what to do in your own projects.

> It seems I’m not the only one. I think this represents a natural evolution where
> users are pushing the system beyond what is intended. That’s not a bad thing, and I think emacs should
> follow the desire paths carved out be users here. 
> 
> It’s fine to wait until the trends are clearer, but I think this is a very natural direction for module development,
> so its just a matter of time.  

I'd rather wait for now.




This bug report was last modified 2 years and 210 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.