From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70145: [PATCH] Add sqlite-execute-batch command Date: Tue, 02 Apr 2024 19:21:52 +0300 Message-ID: <86bk6rag67.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36340"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70145@debbugs.gnu.org To: Javier Olaechea Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Apr 02 18:23:23 2024 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 1rrguv-0009Av-OG for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Apr 2024 18:23:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rrgue-0001NL-15; Tue, 02 Apr 2024 12:23:04 -0400 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 1rrguZ-0001MW-Lv for bug-gnu-emacs@gnu.org; Tue, 02 Apr 2024 12:23:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rrguZ-00021q-BW for bug-gnu-emacs@gnu.org; Tue, 02 Apr 2024 12:22:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rrguc-0008S4-Or for bug-gnu-emacs@gnu.org; Tue, 02 Apr 2024 12:23:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Apr 2024 16:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70145 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70145-submit@debbugs.gnu.org id=B70145.171207494832276 (code B ref 70145); Tue, 02 Apr 2024 16:23:02 +0000 Original-Received: (at 70145) by debbugs.gnu.org; 2 Apr 2024 16:22:28 +0000 Original-Received: from localhost ([127.0.0.1]:55840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrgu1-0008OB-Qf for submit@debbugs.gnu.org; Tue, 02 Apr 2024 12:22:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60394) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rrgty-0008NF-Pw for 70145@debbugs.gnu.org; Tue, 02 Apr 2024 12:22:24 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rrgto-0001ss-E2; Tue, 02 Apr 2024 12:22:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=dSkizMr+OF1g8oJeF372dxeaALzih7MEQAdbTV8/588=; b=cgZa5CqZkxIH I7lNhOLLvMO7dQYunApWprEPGwqOhNlxH+zuWOjEVi89RMQQq2Bzw1GmLfVAtXFyNX+67DmRK2Ysw 2li8jqrxs6dAV2Xy41l88bEh6qYkLc/6eOILCijyO5eCgonnBt90vXM6JrhI36WV/k2Dr5lcEY7lh zg4/WXJ3J0O9srDAa7B0T2YWKzZ6uOoTEN5JKPPHqmAT81pIB5/ECEY/xz7UnNAfkUXjXfK5SN3KT J5VW86eLH63s1tTedJhOiU+AadonP9Img/Nb4VIkRxkx/+WBzY4VusIrhTvUHe6aGLrysWDFVpEo0 Tdgm1WYGvUlrUBF58LV0lQ==; In-Reply-To: (message from Javier Olaechea on Tue, 2 Apr 2024 10:03:30 -0500) 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:282525 Archived-At: > From: Javier Olaechea > Date: Tue, 2 Apr 2024 10:03:30 -0500 > > Hi, while writing tests for an Emacs package I found myself needing to > execute multiple statements against an in-memory database, to initialize > the schema. Currently there is no easy way to do so as sqlite-execute > only executes the first command and ignores the rest. The reason most > likely being that accepting arguments for multiple statements and > properly preparing would be a tricky task. So instead I'm adding the > functionality as a new function that takes no arguments. Thanks. > +DEFUN ("sqlite-execute-batch", Fsqlite_execute_batch, Ssqlite_execute_batch, 2, 2, 0, > + doc: /* Execute multiple SQL statements. */) > + (Lisp_Object db, Lisp_Object query) > +{ > + check_sqlite (db, false); > + CHECK_STRING (query); > + return sqlite_exec (XSQLITE (db)->db, SSDATA (query)); > +} > + This has a subtle bug: it will only work correctly for plain-ASCII string in QUERY. If QUERY is allowed to included non-ASCII characters, you need to encode it using encode_string. Also, the doc string should mention the function's arguments, and it should say what kind of Lisp object is QUERY. > +@defun sqlite-execute-batch db statements > +Execute the @acronym{SQL} @var{statements}. This might be useful when we > +want to execute multiple @acronym{DDL} statements. Same here, and in addition please leave two spaces between sentences, per our conventions (in the commit log message as well).