From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.bugs Subject: bug#59346: Adding sqlite-backup Date: Sat, 19 Nov 2022 08:03:35 +0300 Message-ID: References: <837czsd7sr.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27983"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02) Cc: Andrew Hyatt , 59346@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Nov 19 06:05:26 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1owG2g-00074U-Fc for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 19 Nov 2022 06:05:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1owG2M-0004QY-Kk; Sat, 19 Nov 2022 00:05:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1owG2K-0004QI-IG for bug-gnu-emacs@gnu.org; Sat, 19 Nov 2022 00:05:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1owG2J-00007p-5E for bug-gnu-emacs@gnu.org; Sat, 19 Nov 2022 00:05:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1owG2J-0002qC-0x for bug-gnu-emacs@gnu.org; Sat, 19 Nov 2022 00:05:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jean Louis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 Nov 2022 05:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59346 X-GNU-PR-Package: emacs Original-Received: via spool by 59346-submit@debbugs.gnu.org id=B59346.166883429810897 (code B ref 59346); Sat, 19 Nov 2022 05:05:02 +0000 Original-Received: (at 59346) by debbugs.gnu.org; 19 Nov 2022 05:04:58 +0000 Original-Received: from localhost ([127.0.0.1]:38705 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owG2D-0002pg-J1 for submit@debbugs.gnu.org; Sat, 19 Nov 2022 00:04:58 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:36779) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1owG2C-0002pF-5b for 59346@debbugs.gnu.org; Sat, 19 Nov 2022 00:04:56 -0500 Original-Received: from localhost ([::ffff:197.239.5.174]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 00000000000F612E.00000000637863F8.00000F06; Fri, 18 Nov 2022 22:04:56 -0700 Content-Disposition: inline In-Reply-To: <837czsd7sr.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:248297 Archived-At: * Eli Zaretskii [2022-11-18 10:48]: > > From: Andrew Hyatt > > 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/