GNU logs - #75598, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#75598: [PATCH] Quote identifiers in SQL queries in sqlite-mode
Resent-From: git@HIDDEN
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 16 Jan 2025 04:16:02 +0000
Resent-Message-ID: <handler.75598.B.173700090810323 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 75598
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: 75598 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.173700090810323
          (code B ref -1); Thu, 16 Jan 2025 04:16:02 +0000
Received: (at submit) by debbugs.gnu.org; 16 Jan 2025 04:15:08 +0000
Received: from localhost ([127.0.0.1]:59496 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tYHHc-0002gK-Cb
	for submit <at> debbugs.gnu.org; Wed, 15 Jan 2025 23:15:07 -0500
Received: from lists.gnu.org ([2001:470:142::17]:33214)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <vladimir@HIDDEN>)
 id 1tY8RU-00075q-4H
 for submit <at> debbugs.gnu.org; Wed, 15 Jan 2025 13:48:43 -0500
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 <vladimir@HIDDEN>)
 id 1tY8RN-0004t1-Sk
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jan 2025 13:48:34 -0500
Received: from f1.1azy.net ([104.244.74.192] helo=home.thecybershadow.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vladimir@HIDDEN>)
 id 1tY8RK-0003pc-Df
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jan 2025 13:48:33 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=home.thecybershadow.net; s=home; h=Sender:Content-Type:MIME-Version:
 Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=TSGKkWkMBeNmXkcT6tT+0kza6TjiAJbxOP2QFuehHmw=; b=saIS8RlV1Qmtpya8TnQe1C9Tue
 Fh7tTfXDoXOKllba35i9d8Fw/91+AteSSSUo1qItZEal5amFenSvD22n90AsSsOgUvP7R6R1lrPpx
 ii3Yvt3gPInNtoHXa2ph6qawI9aS6wEAwDaxo0nLxeoGk6sxw3FDho1zvv6UKsoPT3Dk=;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cy.md;
 s=home; h=Sender:Content-Type:MIME-Version:Message-ID:Date:Subject:To:From:
 Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=TSGKkWkMBeNmXkcT6tT+0kza6TjiAJbxOP2QFuehHmw=; b=r5iDduy/1QJbArDcYEw9JTBv33
 oeh8VfphxlW7PKt0r37PkHUb033vFyB4QUsQjw6pGDIbOcbpd7/4F6+8WwOZOjpdLpmojq2AYufDn
 xjguOnwRDGwuVgY5GKNc40HQPnZOTyrBsl0kFeVabJbzHVVqs5Woz5+I+QH+yA+RC3F4=;
Received: from vladimir by home.thecybershadow.net with local (Exim 4.98)
 (envelope-from <vladimir@HIDDEN>)
 id 1tY8Hz-0000000FfLW-3Sxn for bug-gnu-emacs@HIDDEN;
 Wed, 15 Jan 2025 18:38:51 +0000
From: git@HIDDEN
Date: Wed, 15 Jan 2025 18:38:51 +0000
Message-ID: <87bjw77whw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=104.244.74.192;
 envelope-from=vladimir@HIDDEN; helo=home.thecybershadow.net
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.248,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.2 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Tags: patch The sqlite-mode package does not quote
 identifiers
 (table and column names) in the SQL queries it performs. As a result, it
 e.g. cannot open databases which have a table called "values". Here is a patch
 which fixes it for me. 
 Content analysis details:   (1.2 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
 mail domains are different
 0.9 SPF_FAIL               SPF: sender does not match SPF record (fail)
 [SPF failed: Please see http://www.openspf.org/Why?s=mfrom;
 id=vladimir%40home.thecybershadow.net; ip=2001%3A470%3A142%3A%3A17;
 r=debbugs.gnu.org]
X-Mailman-Approved-At: Wed, 15 Jan 2025 23:15:03 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.2 (/)

--=-=-=
Content-Type: text/plain

Tags: patch


The sqlite-mode package does not quote identifiers (table and column
names) in the SQL queries it performs. As a result, it e.g. cannot open
databases which have a table called "values".

Here is a patch which fixes it for me.

Reference: https://www.sqlite.org/lang_keywords.html

In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.0, Xaw3d scroll bars)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101015
System Description: Arch Linux

Configured using:
 'configure
 --prefix=/nix/store/mzdvpxzkhlryxmbxwbih7bgvkzkw1ly7-emacs-29.1
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-compress-install
 --with-toolkit-scroll-bars --with-native-compilation
 --without-imagemagick --without-small-ja-dic --with-tree-sitter
 --with-xinput2 --without-xwidgets'


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-Quote-identifiers-in-SQL-queries-in-sqlite-mode.patch

From 7f85812ae501cbf4e321717e7bc7319846c76fcf Mon Sep 17 00:00:00 2001
From: Vladimir Panteleev <git@HIDDEN>
Date: Wed, 15 Jan 2025 18:33:23 +0000
Subject: [PATCH] Quote identifiers in SQL queries in sqlite-mode

* lisp/sqlite-mode.el: Quote identifiers (table and column names) in the
SQL queries. Fixes e.g. opening databases which have a table called
"values".
---
 lisp/sqlite-mode.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/sqlite-mode.el b/lisp/sqlite-mode.el
index 5deb8c2d7bb..a4b96b02b48 100644
--- a/lisp/sqlite-mode.el
+++ b/lisp/sqlite-mode.el
@@ -76,7 +76,7 @@ sqlite-mode-list-tables
     (erase-buffer)
     (dolist (table (sqlite-select db "select name from sqlite_master where type = 'table' and name not like 'sqlite_%' order by name"))
       (push (list (car table)
-                  (caar (sqlite-select db (format "select count(*) from %s"
+                  (caar (sqlite-select db (format "select count(*) from \"%s\""
                                                   (car table)))))
             entries))
     (sqlite-mode--tablify '("Table Name" "Number of Rows")
@@ -137,7 +137,7 @@ sqlite-mode-list-columns
 
 (defun sqlite-mode--column-names (table)
   "Return a list of the column names for TABLE."
-  (mapcar (lambda (row) (nth 1 row)) (sqlite-select sqlite--db (format "pragma table_info(%s)" table))))
+  (mapcar (lambda (row) (nth 1 row)) (sqlite-select sqlite--db (format "pragma table_info(\"%s\")" table))))
 
 (defun sqlite-mode-list-data ()
   "List the data from the table under point."
@@ -171,7 +171,7 @@ sqlite--mode--list-data
           (setq stmt
                 (sqlite-select
                  sqlite--db
-                 (format "select rowid, * from %s where rowid >= ?" table)
+                 (format "select rowid, * from \"%s\" where rowid >= ?" table)
                  (list rowid)
                  'set))
           (sqlite-mode--tablify (sqlite-columns stmt)
@@ -201,11 +201,11 @@ sqlite-mode-delete
       (user-error "Not deleting"))
     (sqlite-execute
      sqlite--db
-     (format "delete from %s where %s"
+     (format "delete from \"%s\" where %s"
              (cdr table)
              (string-join
               (mapcar (lambda (column)
-                        (format "%s = ?" (car (split-string column " "))))
+                        (format "\"%s\" = ?" (car (split-string column " "))))
                       (cons "rowid" (sqlite-mode--column-names (cdr table))))
               " and "))
      row)
-- 
2.46.0


--=-=-=--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: git@HIDDEN
Subject: bug#75598: Acknowledgement ([PATCH] Quote identifiers in SQL
 queries in sqlite-mode)
Message-ID: <handler.75598.B.173700090810323.ack <at> debbugs.gnu.org>
References: <87bjw77whw.fsf@HIDDEN>
X-Gnu-PR-Message: ack 75598
X-Gnu-PR-Package: emacs
X-Gnu-PR-Keywords: patch
Reply-To: 75598 <at> debbugs.gnu.org
Date: Thu, 16 Jan 2025 04:16:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 75598 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
75598: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D75598
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 21 Jan 2025 02:26:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jan 20 21:26:46 2025
Received: from localhost ([127.0.0.1]:52625 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ta3yY-0004Rf-2K
	for submit <at> debbugs.gnu.org; Mon, 20 Jan 2025 21:26:46 -0500
Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]:52668)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.84_2) (envelope-from <stefankangas@HIDDEN>)
 id 1ta3yS-0004R4-Ng
 for control <at> debbugs.gnu.org; Mon, 20 Jan 2025 21:26:41 -0500
Received: by mail-ej1-x631.google.com with SMTP id
 a640c23a62f3a-aaedd529ba1so669892466b.1
 for <control <at> debbugs.gnu.org>; Mon, 20 Jan 2025 18:26:40 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20230601; t=1737426394; x=1738031194; darn=debbugs.gnu.org;
 h=to:subject:message-id:date:mime-version:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=Lt1WW2UHiFPfSkwc90gg6HE9IbIAPQAjj7yBWtPfNs0=;
 b=InBid5Lfu+2Cbn/znWXSUnfCw1RTQx+rzAjnrRgPwQS/Ms1fBMDU6zwX4+6hPZsiwS
 U4JcapDlUu2UFhNgjy2wR49mezOBppgIVRCD1STN6+j6wF5cSZ2o7yE5JUPpswVjkiyk
 ZPXvmYvQJ/jfJ0QPsD8HyfCXDCNlDux4LJLzqJARMw+gpgw9MEpgltvYTyaeaFXCXUQc
 ZfbcyxLf4i55uhx70uNgm88mKfs6wH7mM+S1/tbxrDyz2s6X9fVGC1cX0STnjwD4rZFO
 O2uc3z3vLP+ckNPFvMRLmFdYZXh8sc/8QGgeMvIYSVuWM6q9cZvRCELInCesIzvtJNJe
 LVKg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1737426394; x=1738031194;
 h=to:subject:message-id:date:mime-version:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=Lt1WW2UHiFPfSkwc90gg6HE9IbIAPQAjj7yBWtPfNs0=;
 b=EY3LEeebM/uyF6ZEkNtcdyoWSHtCVQ0zt0FQFocQLitpiDxgX4XupLC8dvFoYHU7jy
 qjAKuV77NEAktLsTzT9aiXgYhzS/DQ+lZ83mVLQH8E7PQRBvtO3eIWLqvhj8OAScqxiA
 RPUiTSXZYyXIQbsPChautj7faVAXd9Yoy8wsYqB/JA2cvsUOlQWDQ9T4UFCnwPvXzYav
 E/BxX8WtSC8mCkfCs91z05XCOqx2H7QPkd+Amm97UISd7zA52a1r3/SiOUed55UdRIWx
 ojCpr/L9At48QsHerXAT38aKRTrEDyLTtxx99GXEFE6qNemR0ZVR0pz/YxrkS8xhJouo
 vaPg==
X-Gm-Message-State: AOJu0Yy841m4gYjXNMi2wyUYW5k7/9sinMLWhHF8b49b133rCITE7ECh
 sRkfwVGgeAwWNs7vYo7EVE3mSbqI/Wnmap70iVb9lkF8WXmyZPTPr/fYbzpLm4fmQpXfaL2ht9n
 PFLXgzsQ29R30SAzf9PE+gsH1wuy7W5dx
X-Gm-Gg: ASbGnct1AwFGbwk7xaDR7XcwHASc4Fq1Nw29RY0+nNUpC3MLvuRn5QbcMFXrv05GQiT
 a493y3qCjJESUicRns0J181Dfj2vUTdI9d1jU92GJYhcHia0p0ra6KQ==
X-Google-Smtp-Source: AGHT+IHgDH2cFk1ZOnWjOPMxFG5Tzh5k9tp94hBYAuLXZjOO7lc/6RQR0Q07lJJQvF4f7zl84ii41HCU2qTXd+r3iTY=
X-Received: by 2002:a05:6402:4416:b0:5d0:d3eb:a78f with SMTP id
 4fb4d7f45d1cf-5db7d0eca61mr39237235a12.0.1737426394571; Mon, 20 Jan 2025
 18:26:34 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Mon, 20 Jan 2025 20:26:34 -0600
From: Stefan Kangas <stefankangas@HIDDEN>
MIME-Version: 1.0
Date: Mon, 20 Jan 2025 20:26:34 -0600
X-Gm-Features: AbW1kvb-WwBORL0RDSVpnYRqV0OaxLdvvIEVzukE5ag4QxO-gpaWzTnimjRwzac
Message-ID: <CADwFkmkOxk_GQnBEDB+r01ZSNrzkMXjOpo5h8Ogo+WXWqFX+pQ@HIDDEN>
Subject: control message for bug #75598
To: control <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

severity 75598 wishlist
quit




Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Eli Zaretskii <eliz@HIDDEN>
Subject: bug#75598: closed ([PATCH] Quote identifiers in SQL queries in
 sqlite-mode)
CC: tracker <at> debbugs.gnu.org
Message-ID: <handler.75598.D75598.173779660622802.ackdone <at> debbugs.gnu.org>
References: <865xm3w8wj.fsf@HIDDEN> <87bjw77whw.fsf@HIDDEN>
X-Gnu-PR-Message: closed 75598
X-Gnu-PR-Package: emacs
X-Gnu-PR-Keywords: patch
Date: Sat, 25 Jan 2025 09:17:02 +0000
Content-Type: multipart/mixed; boundary="----------=_1737796622-22832-0"

This is a multi-part message in MIME format...

------------=_1737796622-22832-0
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8

Your message dated Sat, 25 Jan 2025 11:16:28 +0200
with message-id <865xm3w8wj.fsf@HIDDEN>
and subject line Re: bug#75598: [PATCH] Quote identifiers in SQL queries in=
 sqlite-mode
has caused the debbugs.gnu.org bug report #75598,
regarding [PATCH] Quote identifiers in SQL queries in sqlite-mode
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@HIDDEN)


--=20
75598: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D75598
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1737796622-22832-0
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 16 Jan 2025 04:15:08 +0000
Received: from localhost ([127.0.0.1]:59496 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tYHHc-0002gK-Cb
	for submit <at> debbugs.gnu.org; Wed, 15 Jan 2025 23:15:07 -0500
Received: from lists.gnu.org ([2001:470:142::17]:33214)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <vladimir@HIDDEN>)
 id 1tY8RU-00075q-4H
 for submit <at> debbugs.gnu.org; Wed, 15 Jan 2025 13:48:43 -0500
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 <vladimir@HIDDEN>)
 id 1tY8RN-0004t1-Sk
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jan 2025 13:48:34 -0500
Received: from f1.1azy.net ([104.244.74.192] helo=home.thecybershadow.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vladimir@HIDDEN>)
 id 1tY8RK-0003pc-Df
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jan 2025 13:48:33 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=home.thecybershadow.net; s=home; h=Sender:Content-Type:MIME-Version:
 Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=TSGKkWkMBeNmXkcT6tT+0kza6TjiAJbxOP2QFuehHmw=; b=saIS8RlV1Qmtpya8TnQe1C9Tue
 Fh7tTfXDoXOKllba35i9d8Fw/91+AteSSSUo1qItZEal5amFenSvD22n90AsSsOgUvP7R6R1lrPpx
 ii3Yvt3gPInNtoHXa2ph6qawI9aS6wEAwDaxo0nLxeoGk6sxw3FDho1zvv6UKsoPT3Dk=;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cy.md;
 s=home; h=Sender:Content-Type:MIME-Version:Message-ID:Date:Subject:To:From:
 Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=TSGKkWkMBeNmXkcT6tT+0kza6TjiAJbxOP2QFuehHmw=; b=r5iDduy/1QJbArDcYEw9JTBv33
 oeh8VfphxlW7PKt0r37PkHUb033vFyB4QUsQjw6pGDIbOcbpd7/4F6+8WwOZOjpdLpmojq2AYufDn
 xjguOnwRDGwuVgY5GKNc40HQPnZOTyrBsl0kFeVabJbzHVVqs5Woz5+I+QH+yA+RC3F4=;
Received: from vladimir by home.thecybershadow.net with local (Exim 4.98)
 (envelope-from <vladimir@HIDDEN>)
 id 1tY8Hz-0000000FfLW-3Sxn for bug-gnu-emacs@HIDDEN;
 Wed, 15 Jan 2025 18:38:51 +0000
From: git@HIDDEN
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Quote identifiers in SQL queries in sqlite-mode
Date: Wed, 15 Jan 2025 18:38:51 +0000
Message-ID: <87bjw77whw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=104.244.74.192;
 envelope-from=vladimir@HIDDEN; helo=home.thecybershadow.net
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.248,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.2 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Tags: patch The sqlite-mode package does not quote
 identifiers
 (table and column names) in the SQL queries it performs. As a result, it
 e.g. cannot open databases which have a table called "values". Here is a patch
 which fixes it for me. 
 Content analysis details:   (1.2 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
 mail domains are different
 0.9 SPF_FAIL               SPF: sender does not match SPF record (fail)
 [SPF failed: Please see http://www.openspf.org/Why?s=mfrom;
 id=vladimir%40home.thecybershadow.net; ip=2001%3A470%3A142%3A%3A17;
 r=debbugs.gnu.org]
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 15 Jan 2025 23:15:03 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.2 (/)

--=-=-=
Content-Type: text/plain

Tags: patch


The sqlite-mode package does not quote identifiers (table and column
names) in the SQL queries it performs. As a result, it e.g. cannot open
databases which have a table called "values".

Here is a patch which fixes it for me.

Reference: https://www.sqlite.org/lang_keywords.html

In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.0, Xaw3d scroll bars)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101015
System Description: Arch Linux

Configured using:
 'configure
 --prefix=/nix/store/mzdvpxzkhlryxmbxwbih7bgvkzkw1ly7-emacs-29.1
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-compress-install
 --with-toolkit-scroll-bars --with-native-compilation
 --without-imagemagick --without-small-ja-dic --with-tree-sitter
 --with-xinput2 --without-xwidgets'


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-Quote-identifiers-in-SQL-queries-in-sqlite-mode.patch

From 7f85812ae501cbf4e321717e7bc7319846c76fcf Mon Sep 17 00:00:00 2001
From: Vladimir Panteleev <git@HIDDEN>
Date: Wed, 15 Jan 2025 18:33:23 +0000
Subject: [PATCH] Quote identifiers in SQL queries in sqlite-mode

* lisp/sqlite-mode.el: Quote identifiers (table and column names) in the
SQL queries. Fixes e.g. opening databases which have a table called
"values".
---
 lisp/sqlite-mode.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/sqlite-mode.el b/lisp/sqlite-mode.el
index 5deb8c2d7bb..a4b96b02b48 100644
--- a/lisp/sqlite-mode.el
+++ b/lisp/sqlite-mode.el
@@ -76,7 +76,7 @@ sqlite-mode-list-tables
     (erase-buffer)
     (dolist (table (sqlite-select db "select name from sqlite_master where type = 'table' and name not like 'sqlite_%' order by name"))
       (push (list (car table)
-                  (caar (sqlite-select db (format "select count(*) from %s"
+                  (caar (sqlite-select db (format "select count(*) from \"%s\""
                                                   (car table)))))
             entries))
     (sqlite-mode--tablify '("Table Name" "Number of Rows")
@@ -137,7 +137,7 @@ sqlite-mode-list-columns
 
 (defun sqlite-mode--column-names (table)
   "Return a list of the column names for TABLE."
-  (mapcar (lambda (row) (nth 1 row)) (sqlite-select sqlite--db (format "pragma table_info(%s)" table))))
+  (mapcar (lambda (row) (nth 1 row)) (sqlite-select sqlite--db (format "pragma table_info(\"%s\")" table))))
 
 (defun sqlite-mode-list-data ()
   "List the data from the table under point."
@@ -171,7 +171,7 @@ sqlite--mode--list-data
           (setq stmt
                 (sqlite-select
                  sqlite--db
-                 (format "select rowid, * from %s where rowid >= ?" table)
+                 (format "select rowid, * from \"%s\" where rowid >= ?" table)
                  (list rowid)
                  'set))
           (sqlite-mode--tablify (sqlite-columns stmt)
@@ -201,11 +201,11 @@ sqlite-mode-delete
       (user-error "Not deleting"))
     (sqlite-execute
      sqlite--db
-     (format "delete from %s where %s"
+     (format "delete from \"%s\" where %s"
              (cdr table)
              (string-join
               (mapcar (lambda (column)
-                        (format "%s = ?" (car (split-string column " "))))
+                        (format "\"%s\" = ?" (car (split-string column " "))))
                       (cons "rowid" (sqlite-mode--column-names (cdr table))))
               " and "))
      row)
-- 
2.46.0


--=-=-=--



------------=_1737796622-22832-0
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 75598-done) by debbugs.gnu.org; 25 Jan 2025 09:16:46 +0000
Received: from localhost ([127.0.0.1]:48478 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tbcHW-0005vi-B5
	for submit <at> debbugs.gnu.org; Sat, 25 Jan 2025 04:16:46 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:37892)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tbcHR-0005vL-3a
 for 75598-done <at> debbugs.gnu.org; Sat, 25 Jan 2025 04:16:44 -0500
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 <eliz@HIDDEN>)
 id 1tbcHK-0006Sw-1y; Sat, 25 Jan 2025 04:16:34 -0500
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=GhMj7R3W27bMm1EuhHPDR3PUSNDLU9ujEn6bCAJ0z9s=; b=E3L+tRK9/Gt6
 AGJB4yimVadjmCmbwla0fgMdV0g+pcPqLSib6pFOSYfAmJmag9DylYUqTuJ5fxlGKryWr6dytR5au
 jsdjFezLdcNmwIvd+Un48k+PP+dWfttjBybNXivA0scD1vdovAX6TOQithbtYz99lE3IEhSeMHED7
 VPqHPw487cbZzlFGwNyPVOACOLT16hC4Ztv1yZn4/g55LZoqF9v11Nj+lb9fyws/XptSrPPQpckbz
 xh3+/3g4KmS2NlC6ks2J7nAmpkS8b/N9AIjNOHR7oLo5My0nGmTdPAutm8zLxO+xas11ZY6ggqu9p
 nsovl6v9O0FHNsQMiKti8g==;
Date: Sat, 25 Jan 2025 11:16:28 +0200
Message-Id: <865xm3w8wj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: git@HIDDEN
In-Reply-To: <87bjw77whw.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#75598: [PATCH] Quote identifiers in SQL queries in sqlite-mode
References: <87bjw77whw.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 75598-done
Cc: 75598-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 15 Jan 2025 18:38:51 +0000
> From: git--- via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> The sqlite-mode package does not quote identifiers (table and column
> names) in the SQL queries it performs. As a result, it e.g. cannot open
> databases which have a table called "values".
> 
> Here is a patch which fixes it for me.
> 
> Reference: https://www.sqlite.org/lang_keywords.html

Thanks, installed on the master branch, and closing the bug.


------------=_1737796622-22832-0--


Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: git@HIDDEN
Subject: bug#75598: closed (Re: bug#75598: [PATCH] Quote identifiers in
 SQL queries in sqlite-mode)
Message-ID: <handler.75598.D75598.173779660622802.notifdone <at> debbugs.gnu.org>
References: <865xm3w8wj.fsf@HIDDEN> <87bjw77whw.fsf@HIDDEN>
X-Gnu-PR-Message: they-closed 75598
X-Gnu-PR-Package: emacs
X-Gnu-PR-Keywords: patch
Reply-To: 75598 <at> debbugs.gnu.org
Date: Sat, 25 Jan 2025 09:17:02 +0000
Content-Type: multipart/mixed; boundary="----------=_1737796622-22832-1"

This is a multi-part message in MIME format...

------------=_1737796622-22832-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

Your bug report

#75598: [PATCH] Quote identifiers in SQL queries in sqlite-mode

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 75598 <at> debbugs.gnu.org.

--=20
75598: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D75598
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1737796622-22832-1
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 75598-done) by debbugs.gnu.org; 25 Jan 2025 09:16:46 +0000
Received: from localhost ([127.0.0.1]:48478 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tbcHW-0005vi-B5
	for submit <at> debbugs.gnu.org; Sat, 25 Jan 2025 04:16:46 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:37892)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <eliz@HIDDEN>) id 1tbcHR-0005vL-3a
 for 75598-done <at> debbugs.gnu.org; Sat, 25 Jan 2025 04:16:44 -0500
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 <eliz@HIDDEN>)
 id 1tbcHK-0006Sw-1y; Sat, 25 Jan 2025 04:16:34 -0500
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=GhMj7R3W27bMm1EuhHPDR3PUSNDLU9ujEn6bCAJ0z9s=; b=E3L+tRK9/Gt6
 AGJB4yimVadjmCmbwla0fgMdV0g+pcPqLSib6pFOSYfAmJmag9DylYUqTuJ5fxlGKryWr6dytR5au
 jsdjFezLdcNmwIvd+Un48k+PP+dWfttjBybNXivA0scD1vdovAX6TOQithbtYz99lE3IEhSeMHED7
 VPqHPw487cbZzlFGwNyPVOACOLT16hC4Ztv1yZn4/g55LZoqF9v11Nj+lb9fyws/XptSrPPQpckbz
 xh3+/3g4KmS2NlC6ks2J7nAmpkS8b/N9AIjNOHR7oLo5My0nGmTdPAutm8zLxO+xas11ZY6ggqu9p
 nsovl6v9O0FHNsQMiKti8g==;
Date: Sat, 25 Jan 2025 11:16:28 +0200
Message-Id: <865xm3w8wj.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: git@HIDDEN
In-Reply-To: <87bjw77whw.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#75598: [PATCH] Quote identifiers in SQL queries in sqlite-mode
References: <87bjw77whw.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 75598-done
Cc: 75598-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Wed, 15 Jan 2025 18:38:51 +0000
> From: git--- via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> The sqlite-mode package does not quote identifiers (table and column
> names) in the SQL queries it performs. As a result, it e.g. cannot open
> databases which have a table called "values".
> 
> Here is a patch which fixes it for me.
> 
> Reference: https://www.sqlite.org/lang_keywords.html

Thanks, installed on the master branch, and closing the bug.


------------=_1737796622-22832-1
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 16 Jan 2025 04:15:08 +0000
Received: from localhost ([127.0.0.1]:59496 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1tYHHc-0002gK-Cb
	for submit <at> debbugs.gnu.org; Wed, 15 Jan 2025 23:15:07 -0500
Received: from lists.gnu.org ([2001:470:142::17]:33214)
 by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.84_2) (envelope-from <vladimir@HIDDEN>)
 id 1tY8RU-00075q-4H
 for submit <at> debbugs.gnu.org; Wed, 15 Jan 2025 13:48:43 -0500
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 <vladimir@HIDDEN>)
 id 1tY8RN-0004t1-Sk
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jan 2025 13:48:34 -0500
Received: from f1.1azy.net ([104.244.74.192] helo=home.thecybershadow.net)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vladimir@HIDDEN>)
 id 1tY8RK-0003pc-Df
 for bug-gnu-emacs@HIDDEN; Wed, 15 Jan 2025 13:48:33 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
 d=home.thecybershadow.net; s=home; h=Sender:Content-Type:MIME-Version:
 Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id:
 List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=TSGKkWkMBeNmXkcT6tT+0kza6TjiAJbxOP2QFuehHmw=; b=saIS8RlV1Qmtpya8TnQe1C9Tue
 Fh7tTfXDoXOKllba35i9d8Fw/91+AteSSSUo1qItZEal5amFenSvD22n90AsSsOgUvP7R6R1lrPpx
 ii3Yvt3gPInNtoHXa2ph6qawI9aS6wEAwDaxo0nLxeoGk6sxw3FDho1zvv6UKsoPT3Dk=;
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=cy.md;
 s=home; h=Sender:Content-Type:MIME-Version:Message-ID:Date:Subject:To:From:
 Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=TSGKkWkMBeNmXkcT6tT+0kza6TjiAJbxOP2QFuehHmw=; b=r5iDduy/1QJbArDcYEw9JTBv33
 oeh8VfphxlW7PKt0r37PkHUb033vFyB4QUsQjw6pGDIbOcbpd7/4F6+8WwOZOjpdLpmojq2AYufDn
 xjguOnwRDGwuVgY5GKNc40HQPnZOTyrBsl0kFeVabJbzHVVqs5Woz5+I+QH+yA+RC3F4=;
Received: from vladimir by home.thecybershadow.net with local (Exim 4.98)
 (envelope-from <vladimir@HIDDEN>)
 id 1tY8Hz-0000000FfLW-3Sxn for bug-gnu-emacs@HIDDEN;
 Wed, 15 Jan 2025 18:38:51 +0000
From: git@HIDDEN
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Quote identifiers in SQL queries in sqlite-mode
Date: Wed, 15 Jan 2025 18:38:51 +0000
Message-ID: <87bjw77whw.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=104.244.74.192;
 envelope-from=vladimir@HIDDEN; helo=home.thecybershadow.net
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.248,
 RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 1.2 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: Tags: patch The sqlite-mode package does not quote
 identifiers
 (table and column names) in the SQL queries it performs. As a result, it
 e.g. cannot open databases which have a table called "values". Here is a patch
 which fixes it for me. 
 Content analysis details:   (1.2 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level
 mail domains are different
 0.9 SPF_FAIL               SPF: sender does not match SPF record (fail)
 [SPF failed: Please see http://www.openspf.org/Why?s=mfrom;
 id=vladimir%40home.thecybershadow.net; ip=2001%3A470%3A142%3A%3A17;
 r=debbugs.gnu.org]
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Wed, 15 Jan 2025 23:15:03 -0500
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.2 (/)

--=-=-=
Content-Type: text/plain

Tags: patch


The sqlite-mode package does not quote identifiers (table and column
names) in the SQL queries it performs. As a result, it e.g. cannot open
databases which have a table called "values".

Here is a patch which fixes it for me.

Reference: https://www.sqlite.org/lang_keywords.html

In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.18.0, Xaw3d scroll bars)
Windowing system distributor 'The X.Org Foundation', version 11.0.12101015
System Description: Arch Linux

Configured using:
 'configure
 --prefix=/nix/store/mzdvpxzkhlryxmbxwbih7bgvkzkw1ly7-emacs-29.1
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-compress-install
 --with-toolkit-scroll-bars --with-native-compilation
 --without-imagemagick --without-small-ja-dic --with-tree-sitter
 --with-xinput2 --without-xwidgets'


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-Quote-identifiers-in-SQL-queries-in-sqlite-mode.patch

From 7f85812ae501cbf4e321717e7bc7319846c76fcf Mon Sep 17 00:00:00 2001
From: Vladimir Panteleev <git@HIDDEN>
Date: Wed, 15 Jan 2025 18:33:23 +0000
Subject: [PATCH] Quote identifiers in SQL queries in sqlite-mode

* lisp/sqlite-mode.el: Quote identifiers (table and column names) in the
SQL queries. Fixes e.g. opening databases which have a table called
"values".
---
 lisp/sqlite-mode.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/sqlite-mode.el b/lisp/sqlite-mode.el
index 5deb8c2d7bb..a4b96b02b48 100644
--- a/lisp/sqlite-mode.el
+++ b/lisp/sqlite-mode.el
@@ -76,7 +76,7 @@ sqlite-mode-list-tables
     (erase-buffer)
     (dolist (table (sqlite-select db "select name from sqlite_master where type = 'table' and name not like 'sqlite_%' order by name"))
       (push (list (car table)
-                  (caar (sqlite-select db (format "select count(*) from %s"
+                  (caar (sqlite-select db (format "select count(*) from \"%s\""
                                                   (car table)))))
             entries))
     (sqlite-mode--tablify '("Table Name" "Number of Rows")
@@ -137,7 +137,7 @@ sqlite-mode-list-columns
 
 (defun sqlite-mode--column-names (table)
   "Return a list of the column names for TABLE."
-  (mapcar (lambda (row) (nth 1 row)) (sqlite-select sqlite--db (format "pragma table_info(%s)" table))))
+  (mapcar (lambda (row) (nth 1 row)) (sqlite-select sqlite--db (format "pragma table_info(\"%s\")" table))))
 
 (defun sqlite-mode-list-data ()
   "List the data from the table under point."
@@ -171,7 +171,7 @@ sqlite--mode--list-data
           (setq stmt
                 (sqlite-select
                  sqlite--db
-                 (format "select rowid, * from %s where rowid >= ?" table)
+                 (format "select rowid, * from \"%s\" where rowid >= ?" table)
                  (list rowid)
                  'set))
           (sqlite-mode--tablify (sqlite-columns stmt)
@@ -201,11 +201,11 @@ sqlite-mode-delete
       (user-error "Not deleting"))
     (sqlite-execute
      sqlite--db
-     (format "delete from %s where %s"
+     (format "delete from \"%s\" where %s"
              (cdr table)
              (string-join
               (mapcar (lambda (column)
-                        (format "%s = ?" (car (split-string column " "))))
+                        (format "\"%s\" = ?" (car (split-string column " "))))
                       (cons "rowid" (sqlite-mode--column-names (cdr table))))
               " and "))
      row)
-- 
2.46.0


--=-=-=--



------------=_1737796622-22832-1--



Last modified: Sat, 25 Jan 2025 09:30:02 UTC

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