From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#65998: Sqlite-mode issue deleting records and closing database Date: Sat, 16 Sep 2023 07:07:51 -0700 Message-ID: References: <125a2ffc4cc34a3eb03ecebb4dfc2f9f@rollomatic.ch> <83h6nuiffv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39153"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 65998@debbugs.gnu.org To: Eli Zaretskii , Thomas Hilke , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Sep 16 16:09:10 2023 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 1qhVyw-000A0y-2B for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Sep 2023 16:09:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qhVyj-0006sd-GZ; Sat, 16 Sep 2023 10:08:57 -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 1qhVyh-0006nV-Ib for bug-gnu-emacs@gnu.org; Sat, 16 Sep 2023 10:08:55 -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 1qhVyh-0006Mx-AX for bug-gnu-emacs@gnu.org; Sat, 16 Sep 2023 10:08:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qhVyo-0004hO-AO for bug-gnu-emacs@gnu.org; Sat, 16 Sep 2023 10:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Sep 2023 14:09:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65998 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 65998-submit@debbugs.gnu.org id=B65998.169487328817983 (code B ref 65998); Sat, 16 Sep 2023 14:09:02 +0000 Original-Received: (at 65998) by debbugs.gnu.org; 16 Sep 2023 14:08:08 +0000 Original-Received: from localhost ([127.0.0.1]:48200 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qhVxw-0004fx-HI for submit@debbugs.gnu.org; Sat, 16 Sep 2023 10:08:08 -0400 Original-Received: from mail-lj1-x22b.google.com ([2a00:1450:4864:20::22b]:55583) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qhVxt-0004fR-Ma for 65998@debbugs.gnu.org; Sat, 16 Sep 2023 10:08:06 -0400 Original-Received: by mail-lj1-x22b.google.com with SMTP id 38308e7fff4ca-2bcb89b4767so47543641fa.3 for <65998@debbugs.gnu.org>; Sat, 16 Sep 2023 07:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694873272; x=1695478072; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=UuVXDkzVV2P9Ugm2vDnU4/gJ6LwQuMYgND0InY9p7Qg=; b=Qdt6JTcjEMp4UIqiif1wvFUJ90+Q/WXPd8vVp9Dk6BvEv0BIEDiXS9OMbx07MOUl4G lV9rC2/WmXm+iLZ3EhnLHi+CKRKn48ft6jZpt0HaiwjCzr8910peljUSo4QPISiXti+v QyUBUgfOk0QQChuDwrTXu74S4RXJj4KNgCDKmZD80HB9gZoNRhLYYh5g880eXQu7Rlat 9osXnwrNtYzXLpiLkkBRLUL/CEAAJRpaH0vpdPhg65cmquv9o2Vtp205xmzp48turb6Q +br/+5XQBbVknk0kA0eTpWnBPwKpQZjzZHjZq574AojxXvyDhD3bC52NcsJQcb0usaAe WrWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694873272; x=1695478072; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UuVXDkzVV2P9Ugm2vDnU4/gJ6LwQuMYgND0InY9p7Qg=; b=AolPdwxoUlBGAT4NV23qS9V1sNh3frNPtFjoIcyOf+iCUXZj8ar5eJ3SXngd9jF9GQ gqrtT/CEPcnz6lX8q45gpFs6PjsSTr+3AsBq9mRtsEnF5V2SVid0jGqz20ck459HPAIk uQhLYmdurdm8REtCyaBh/LK0RFqqSZVOguzJsb09Roen84sWmnk0Ut1dCwHD3un0QY6L BclRTVaaAI483TABQfyiczPUvca6kVLDcrr73QMG4nUF01JPyh8feLanMpgyJkxOIxJl toFxPlHcdoYF32lLJZcni2+ohiiLZLpWHOrCAE+5l1WTeD9d9Ue+oH8Iy7J9mCf5Pbub TQLg== X-Gm-Message-State: AOJu0YxAwgXMf/IVsuhJeHZdAGYc5t10KGDaVdYqDgzSpNwNuShEXmXE 9YPyTLVbpHQIvIaB2JihQU34+vNwijAgs0+big4= X-Google-Smtp-Source: AGHT+IFjQ0BjIH0y/PTG/smY16x3P97RdYSM+VlRTgOouvlaICVzM9Y7Vt17zWTMSB4i+SROUmGKV1RectP1Li0UZaE= X-Received: by 2002:a2e:86c6:0:b0:2bd:58b:3a0b with SMTP id n6-20020a2e86c6000000b002bd058b3a0bmr3366069ljj.50.1694873272275; Sat, 16 Sep 2023 07:07:52 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 16 Sep 2023 07:07:51 -0700 In-Reply-To: <83h6nuiffv.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:270620 Archived-At: Eli Zaretskii writes: >> - The sql query built by sqlite-mode-delete is syntactically correct, >> but misinterpreted by sqlite, and eventually do nothing. The query >> is of the form "REMOVE FROM table_name WHERE rowid = ? and >> 'column_name_1' = ? and 'column_name_2' = ? and ..." From >> https://www.sqlite.org/lang_keywords.html, if I understand >> correctly, the quoted column names in the WHERE clause are >> interpreted as strings from sqlite, and as a result not a single row >> is ever matched and deleted. > > Thanks. I installed on the emacs-29 branch the first part of your > patch, which closes the DB when the buffer is killed. As for the > second part, I'd prefer that Lars or someone who knows SQL reviewed it > first, as I find it strange that Lars would code something so basic > which doesn't work at all. > > Could someone who knows SQL please review and chime in? Something like this in an SQL "REMOVE FROM table_name WHERE {foo}" clause 'column_name_1' = ? will check if the '?' part is equal to the string 'column_name_1', which is probably not what we want. Whereas this column_name_1 = ? will instead check if the '?' part is equal to the value of the column column_name_1 in table_name. (The "?" is just a placeholder that will be filled in with an actual value later.) So without having tested the code or studied it in detail, the analysis of the problem sounds right to me. Don't we have unit tests in place for this stuff, though? Perhaps we should see this as an opportunity to add some...