From unknown Fri Jun 20 07:15:31 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#76025 <76025@debbugs.gnu.org> To: bug#76025 <76025@debbugs.gnu.org> Subject: Status: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting Reply-To: bug#76025 <76025@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:15:31 +0000 retitle 76025 [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting reassign 76025 emacs submitter 76025 Phil Estival severity 76025 wishlist tag 76025 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Feb 03 00:19:41 2025 Received: (at submit) by debbugs.gnu.org; 3 Feb 2025 05:19:41 +0000 Received: from localhost ([127.0.0.1]:37267 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1teory-0002Bd-FB for submit@debbugs.gnu.org; Mon, 03 Feb 2025 00:19:41 -0500 Received: from lists.gnu.org ([2001:470:142::17]:59008) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tecsd-0007BY-08 for submit@debbugs.gnu.org; Sun, 02 Feb 2025 11:31:32 -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 ) id 1tecsW-0008Vm-VB for bug-gnu-emacs@gnu.org; Sun, 02 Feb 2025 11:31:24 -0500 Received: from smtp-42ae.mail.infomaniak.ch ([84.16.66.174]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tecsU-0005Mn-DV for bug-gnu-emacs@gnu.org; Sun, 02 Feb 2025 11:31:24 -0500 Received: from smtp-3-0001.mail.infomaniak.ch (unknown [IPv6:2001:1600:4:17::246c]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4YmFW06vf8z99W for ; Sun, 2 Feb 2025 17:31:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1738513868; bh=2ktqhGGL/piya5+3T/+k5fP9UuQyO7MPYtBxC6xgjK0=; h=From:To:Subject:Date:From; b=lCEwcAacSBR3QYlnYIaELvZdlPGAFuIb9qAYStT4OzWMRa3K95ZJcZ3WJOaPB0xLF kMOJfJOUXMDPsPHfArYvSVC2Bie2emnDDdHdqEvbi0Zi+RfCQV/iaw1HYB5jXDEl4l bwQWQapZCqpV/dpw/ESZ9QBWdv+uacZQ2f00zidJOoH02k2ejE5057AP1svp3+j5xy kisd6LInzWHjZ0W7cSOnUq2iv4vtPM7rePVppiE3Ftmpx6KaqJrCO2b91L0hgxWoZm l2ikcdtBrKmJ3K9+migR/bsTlrrmy2OlruQHSLQcYZ37mjXmxXkgYMISVo/Vb1Csdy /N/oJp4Z1OlIA== Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4YmFW03PWqzD5w for ; Sun, 2 Feb 2025 17:31:08 +0100 (CET) From: Phil Estival To: bug-gnu-emacs@gnu.org Subject: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting User-Agent: mu4e 1.12.8; emacs 30.0.50 X-Debbugs-CC: Ihor Radchenko Date: Sun, 02 Feb 2025 17:31:08 +0100 Message-ID: <8734gws3zn.fsf@7d.nz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Infomaniak-Routing: alpha Received-SPF: pass client-ip=84.16.66.174; envelope-from=pe@7d.nz; helo=smtp-42ae.mail.infomaniak.ch X-Spam_score_int: -37 X-Spam_score: -3.8 X-Spam_bar: --- X-Spam_report: (-3.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=-1, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 03 Feb 2025 00:19:37 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) --=-=-= Content-Type: text/plain Tags: patch This is a patch of `sql-product-interactive' in order to connect without prompting for or asking to confirm connection parameters, using ones already set and stored in `sql-database', `sql-server', -user, etc. In GNU Emacs 30.0.50 Repository revision: f2bccae22bd47a2e7e0937b78ea06131711b935a Repository branch: master --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-lisp-progmodes-sql.el-login-without-prompting.patch >From 5e2e6b85482f0b83867a40db9f47abd98db76da6 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 22 Jan 2025 08:00:44 +0100 Subject: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting `sql-product-interactive' has a new optional argument 'no-prompt' in order to connect without opening the prompt by skipping its call to `sql-get-login' when all connection parameters are set. It will still prompt if any of these is missing, excepted for sqlite which doesn't need any to open a transient in-memory database. --- lisp/progmodes/sql.el | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index a1c50a06990..79f6cf0e243 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -4524,5 +4524,5 @@ sql-connection-menu-filter ;;; Entry functions for different SQL interpreters. ;;;###autoload -(defun sql-product-interactive (&optional product new-name) - "Run PRODUCT interpreter as an inferior process. +(defun sql-product-interactive (&optional product new-name no-prompt) + "Run PRODUCT interpreter as an inferior process in a NEW-NAME'd buffer. If buffer `*SQL*' exists but no process is running, make a new process. If buffer exists and a process is running, just make sure buffer `*SQL*' is displayed. +When NO-PROMPT is set, try to connect without prompting +with the already supplied parameters. To specify the SQL product, prefix the call with \\[universal-argument]. To set the buffer name as well, prefix the call to \\[sql-product-interactive] with @@ -4572,9 +4574,15 @@ sql-product-interactive new-sqli-buffer rpt) ;; Get credentials. - (apply #'sql-get-login - (sql-get-product-feature product :sqli-login)) + (when (or (not no-prompt) ; default + (and no-prompt + (cl-some #'string-or-null-p + (list sql-server sql-user sql-password sql-database)) + ;; sqlite allows in-memory db, w/o login + (not (and (string-or-null-p sql-database) + (eq product 'sqlite))))) + (apply #'sql-get-login + (sql-get-product-feature product :sqli-login))) ;; Connect to database. (setq rpt (sql-make-progress-reporter nil "Login")) -- 2.39.5 --=-=-= Content-Type: text/plain -- Phil Estival --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 06 14:12:49 2025 Received: (at 76025) by debbugs.gnu.org; 6 Feb 2025 19:12:49 +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 ) id 1tg7Iu-0006N4-Lz for submit@debbugs.gnu.org; Thu, 06 Feb 2025 14:12:48 -0500 Received: from mout01.posteo.de ([185.67.36.65]:32941) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tg7Ir-0006Mm-I8 for 76025@debbugs.gnu.org; Thu, 06 Feb 2025 14:12:47 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 26D17240028 for <76025@debbugs.gnu.org>; Thu, 6 Feb 2025 20:12:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1738869157; bh=G5vt/ofYhzSipNaKXeXSK9WKyTxgcn7Lm/AVBWWzD0U=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=H5boMmiFaAJMbLZRkVdBSTI/ei0zqAtD4hGW1ui2n/bj4tOQSDBJVerj20TWgsgsT IQu08hNvLGtWSxGOATZ36X+HsKtgYsNLOeByo5VyX8zsWzD5Iv94xNDuM0I2gxe8UR cehVMKL10d9YXg1cqFUyTCIcKOtC0OCbaGFZXllnvFcodLA3qZaZsDQlihCAEJsqfe 3vTG+GqWdCj85NV1aYKGyCy/HUOp9qJeywOZN/pPUx3Ati9zuF/vShdDDUbJHxQZvG gv/PcAf+aTzh68Vzae2sjD5zPnPHfN8q1pWAvI66OhLhKIMFVOuy2qUDq2qCKuUfhp f0rS63/GAd4Tg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YpmvS0PrXz6tsb; Thu, 6 Feb 2025 20:12:35 +0100 (CET) From: Ihor Radchenko To: Phil Estival Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting In-Reply-To: <8734gws3zn.fsf@7d.nz> References: <8734gws3zn.fsf@7d.nz> Date: Thu, 06 Feb 2025 19:14:50 +0000 Message-ID: <87ikpmvqad.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, Michael Mauger X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Phil Estival writes: > This is a patch of `sql-product-interactive' in order to connect without > prompting for or asking to confirm connection parameters, using ones > already set and stored in `sql-database', `sql-server', -user, etc. For context, we want this feature to improve Org babel's sql library (ob-sql) where we need to run session programmatically. See https://list.orgmode.org/orgmode/646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz/ CCing sql.el maintainer. -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 06 21:42:37 2025 Received: (at 76025) by debbugs.gnu.org; 7 Feb 2025 02:42:37 +0000 Received: from localhost ([127.0.0.1]:60105 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tgEKC-0005Nq-In for submit@debbugs.gnu.org; Thu, 06 Feb 2025 21:42:37 -0500 Received: from mail-4316.protonmail.ch ([185.70.43.16]:30055) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tgEK7-0005NP-8i for 76025@debbugs.gnu.org; Thu, 06 Feb 2025 21:42:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1738896144; x=1739155344; bh=12gE8NnjbicKy8fWxqjlovlHLdgM19svthFwUyGgkRQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=bvy89jc7eNzW+gsHnd1DlaOLEFALttHU0lGdIiWWHZAAoesjJm2XdYnLynD99nFtv edm+bNnoHF+0TDKNW7zDfjCZ18OmdUeHb+hpYcRzwsCEV5VYiwzQXLti+pErZtzEba jVDw3E/CkbGnCW3MBSWTNnbLhq3Fx1VuI2H3LCoTEk85YUfquCqUiFrvTVZC0oWeP5 lKF0/fblF9T4GLn5Liw8WD0G4m7Jb9k1iBYkzoGhbsWUAEpAN4qWGICIBPyb0kMoVQ fWSKBMKMhUG12rnckymBKyp3YHGz8lIVvvhSfaQDCwg+J4HJRpH6g9cpIPMRUGlV6M /zKqWjVj4DWOA== Date: Fri, 07 Feb 2025 02:42:19 +0000 To: Ihor Radchenko From: Michael Mauger Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting Message-ID: In-Reply-To: <87ikpmvqad.fsf@localhost> References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> Feedback-ID: 119932:user:proton X-Pm-Message-ID: beadaa7837fbb8a5f93aa2b5ae6a5ec60b32b93c MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: Phil Estival , 76025@debbugs.gnu.org, Michael Mauger X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Thursday, February 6th, 2025 at 7:12 PM, Ihor Radchenko wrote: > Phil Estival pe@7d.nz writes: >=20 > > This is a patch of `sql-product-interactive' in order to connect withou= t prompting for or asking to confirm connection parameters, using ones alre= ady set and stored in` sql-database', `sql-server', -user, etc. >=20 >=20 > For context, we want this feature to improve Org babel's sql library > (ob-sql) where we need to run session programmatically. See > https://list.orgmode.org/orgmode/646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.= nz/ >=20 > CCing sql.el maintainer. >=20 Okay, a lot here... =F0=9F=A4=94 For my context, how are ob-sql "sessions" different from what is provided b= y `sql-product-interactive` buffers? I see you avoiding `sql-product-intera= ctive` buffers but the result is that you are duplicating a lot of logic al= ready present in `sql.el`. I have used babel to drive a sqlite3 in-memory d= atabase without the ob-sql machinery, so I'm wondering how I must warp my o= ld batch card deck way of thinking to understand the problem you are trying= to solve. I do see that you are supporting "engines" not present in `sql.el`; have in= teractive support for these engines been made available as ELPA/MELPA/... m= odules? Should they be? I also see hardcoding of sql command processor cli names; why not use the n= ame already customized in sql.el? I am very interested in supporting this effort within sql.el if I can. I in= herited sql.el a couple of decades ago and other than adding support for us= ing multiple dialects within the same Emacs instance, the feature set is pr= etty bare-bones. I have some time rn to focus on this, so if someone has th= e time/inclination to expand my vision, I'd appreciate it. --=20 MICHAEL@MAUGER.COM // FSF and SFConservancy // GNU Emacs sql.el maintainer From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 07 02:14:41 2025 Received: (at 76025) by debbugs.gnu.org; 7 Feb 2025 07:14:41 +0000 Received: from localhost ([127.0.0.1]:60644 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tgIZV-0001Xf-GP for submit@debbugs.gnu.org; Fri, 07 Feb 2025 02:14:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53900) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tgIZS-0001XP-NY for 76025@debbugs.gnu.org; Fri, 07 Feb 2025 02:14:39 -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 ) id 1tgIZK-0001Zt-28; Fri, 07 Feb 2025 02:14:30 -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=34P/qSPH8W5WTcOk5dLSGvnwk6Tsr8pT3aMAuYdwuGg=; b=WPAUEojgVyoe RhHYZXd3WWBcozqVGm9MbNiuDPHBYB53uu2cGgP0OT25TpAtNNRauQMPcpLfRTt7gLn2FLpB62gJ0 He8rIcKGRFAIqNL28jw8LuMu/Oc/zm8BN61F18G6hw8Xjh8WM97t25Tb23Gfrd/rU8YB05sUFJ/Ug RU7jrc+ymyZ8+kPOdiQwrxx2GdccqBjZHywcgjmRROO3siiuNqe4WoYnIDpj9GRVHI04+5BzyG05d Ic772YrQFPrdoR+a6+h7u5cdn711BozympQ/UL6yFU2+auwns58M/AT6W7IezhHADsoI8x9J3vrH1 NTQZOIogyYOBEsUON8A3Bg==; Date: Fri, 07 Feb 2025 09:14:28 +0200 Message-Id: <86v7tm5iqz.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <87ikpmvqad.fsf@localhost> (message from Ihor Radchenko on Thu, 06 Feb 2025 19:14:50 +0000) Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: pe@7d.nz, 76025@debbugs.gnu.org, michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Cc: 76025@debbugs.gnu.org, Michael Mauger > From: Ihor Radchenko > Date: Thu, 06 Feb 2025 19:14:50 +0000 > > Phil Estival writes: > > > This is a patch of `sql-product-interactive' in order to connect without > > prompting for or asking to confirm connection parameters, using ones > > already set and stored in `sql-database', `sql-server', -user, etc. > > For context, we want this feature to improve Org babel's sql library > (ob-sql) where we need to run session programmatically. See > https://list.orgmode.org/orgmode/646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz/ > > CCing sql.el maintainer. Thanks. >From my POV, this change needs a NEWS entry, and I think Phil needs to do the legal paperwork of assigning the copyright to the FSF (I can send the form and the instructions if that's okay with Phil). From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 09 08:02:08 2025 Received: (at 76025) by debbugs.gnu.org; 9 Feb 2025 13:02:08 +0000 Received: from localhost ([127.0.0.1]:43538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1th6wp-0003qN-KV for submit@debbugs.gnu.org; Sun, 09 Feb 2025 08:02:08 -0500 Received: from smtp-42a8.mail.infomaniak.ch ([84.16.66.168]:59415) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1th6wl-0003pl-C0 for 76025@debbugs.gnu.org; Sun, 09 Feb 2025 08:02:05 -0500 Received: from smtp-3-0000.mail.infomaniak.ch (smtp-3-0000.mail.infomaniak.ch [10.4.36.107]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4YrSXN4My1zK7s; Sun, 9 Feb 2025 14:01:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1739106116; bh=oV9kA0q4b8cCqhKTZ2Sly0v64x3AJhbCQPjDsFWR8SM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=PlH8s41ymFKJlFnRIDX30CHBkXTPjzO8yvXe2Fucgn0Uz3FX6igY4aqaARH60d9/s 7zj1bIxVCEqAz0gmUaQ1LZ9OrmZhUNjOnWQMyQxiUvGqxcINSblWxG6HWSR1pFymvy XCqCVZY8GpZORHwH+wIpSn0TRJGr014/6rrjkEJxyOpzeGrAK3nGQ7QRmmntNFnB9r loP0tSMHMd2tvRz/MIXq/Rk5XcqJ3FFE7XjW5N+prUa/83MRAM7XDAS1WuzF5MyH4c gOlnbsVdG1lbL5Wk+oDRqayGD+OpphMEwbZbSSnLtAk2zXUf/HeYJByJlZdQHrl74Z NMFZEeMwzVfeQ== Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4YrSXH6YhQzYhv; Sun, 9 Feb 2025 14:01:51 +0100 (CET) From: Phil Estival To: Michael Mauger Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting In-Reply-To: (Michael Mauger's message of "Fri, 07 Feb 2025 02:42:19 +0000") References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> User-Agent: mu4e 1.12.8; emacs 30.0.50 Date: Sun, 09 Feb 2025 14:01:51 +0100 Message-ID: <877c5z8e68.fsf@7d.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76025 Cc: Daniel Kraus , 76025@debbugs.gnu.org, Ihor Radchenko , Michael Mauger X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * [2025-02-07 02:42 +0000] Michael Mauger : > On Thursday, February 6th, 2025 at 7:12 PM, Ihor Radchenko wrote: >> Phil Estival pe@7d.nz writes: >> >> > This is a patch of `sql-product-interactive' in order to connect >> > without prompting for or asking to confirm connection parameters, >> > using ones already set and stored in` sql-database', `sql-server', >> > -user, etc. >> >> >> For context, we want this feature to improve Org babel's sql library >> (ob-sql) where we need to run session programmatically. See >> https://list.orgmode.org/orgmode/646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d= .nz/ >> >> CCing sql.el maintainer. >> Hello Michael, > For my context, how are ob-sql "sessions" different from what is > provided by `sql-product-interactive` buffers? Similar to other channels org-babel can communicate through, an ob-sql session (info "(org) Environment of a Code Block") can be characterized as a channel to an interpreter process through a comint shell buffer, shared among source blocks in a notebook. > I see you avoiding `sql-product-interactive` buffers but the result is > that you are duplicating a lot of logic already present in `sql.el`. This duplicated logic is the connection to the database server, modified to avoid the prompts asking to confirm the parameters, except if one is missing, since these parameters are already written in fields describing, above the sql commands, what the session is: a named connection to a database. These parameters can be variables, expressions, global to a document or locally scoped to a section, a paragraph or a single code block. Bypassing this prompts is necessary to automate the tests of the ob-sql machinery. If completion, coloring or additional interactions with the shell are needed, then `sql-interactive-mode' could be set in the shell ob-sql is communicating with. "Could", because, this connection's function was "borrowed" from sql.el with these slight modifications: not prompting for parameters, no syntax coloring or completion, which make sense if no direct interaction is expected in such buffers. Ihor identified the connection's function as a duplication, and proposed we streamline the code by relying on the existing function in sql.el. Now ob-sql sessions do call `sql-product-interactive', hence this proposal for a patch skipping the prompts. Asking additional confirmations could be fine as a safeguard, but as I said /supra/, it's an obstacle for automation and not a necessity when describing a database in a notebook since these information are already present in the environment of code blocks. > I have used babel to drive a sqlite3 in-memory database without the > ob-sql machinery, so I'm wondering how I must warp my old batch card > deck way of thinking to understand the problem you are trying to > solve. One may need of a few stateful variables to designate schema or to give names to roles, and so on. These variables exists in the environment of the SQL shell. One way to apply changes of values is to reset the db, before providing a new environment to a next run of the entire program. But we can also change those values from inside a running environment and recall only the code blocks that refers to these variables. This is what a "session" covers. Org-mode, as a programming notebook is a convenient way to work on small units of code, the blocks, organized in sections, and to combine their execution. In many situations, it's more operable and more maneuverable than the files and folders we are used to think in, and that, in many ways, we still conform to, due to their presence rooted at the core of our systems. As for the in-memory sqlite3 DB, it is an appropriate candidate to test the correctness of the ob-sql sessions behavior: it's a standard lightweight package assumed to be /de facto/ available on our operating systems. > I do see that you are supporting "engines" not present in `sql.el`; > have interactive support for these engines been made available as > ELPA/MELPA/... modules? Should they be? Which ones? CC'ing Daniel to possibly get more advice on the matter. > I also see hardcoding of sql command processor cli names; why not use > the name already customized in sql.el? Because sql.el was not a requirement to ob-sql.el, but you're right, when it will be one, we can bind these to the sql-[db]-program. The probability for someone to need two different cli programs, one in an interactive shell and a different one in a notebook, for a same database system is very low, and in such case he or she would still be capable to set local values to adapt the situation. > I am very interested in supporting this effort within sql.el if I > can. I inherited sql.el a couple of decades ago and other than adding > support for using multiple dialects within the same Emacs instance, > the feature set is pretty bare-bones. I have some time rn to focus on > this, so if someone has the time/inclination to expand my vision, I'd > appreciate it. I will add that a single interface to all these DB systems=C2=A0helps to underline common requirements expected from these sql cli. The case of table formatting on MariaDB, configurable only at startup through a command line parameter -- and not as a state variable -- is one such requirement. Thanks. -- Phil Estival From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 11 02:13:20 2025 Received: (at control) by debbugs.gnu.org; 11 Feb 2025 07:13:20 +0000 Received: from localhost ([127.0.0.1]:53902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1thkSO-0007Jg-4b for submit@debbugs.gnu.org; Tue, 11 Feb 2025 02:13:20 -0500 Received: from mail-ed1-x533.google.com ([2a00:1450:4864:20::533]:55763) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1thkSM-0007JO-FR for control@debbugs.gnu.org; Tue, 11 Feb 2025 02:13:18 -0500 Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-5de3c29e9b3so7412007a12.3 for ; Mon, 10 Feb 2025 23:13:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739257992; x=1739862792; darn=debbugs.gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=1M90f9gsI1f48Hqjb2BLQB6BstLpjEMs52h9ixJ5wrI=; b=Auz07tNtWBn35M+fAkH9LI30oHghT8DpV1hxjgmtYz/X8ho9FyVMQhEtaGqtzS4tyG 6xaVw4Qz0+Uep+TC4ADZscgf9gxWGZ0lYLVodw5ACoPQnLsiHvFvwwv9e7iJmXkoO+xt ept5zApld0eBB897QiY80VUW9jZVBmfxyIoB/idhXX+f8nerbc9q1/3gW8lBeUuyuxdu hhWP/WnxjSfKYZuYYf6gp/cYKXlEQP3r5jdX9ahzUl123QlhU3/PPbbPQQ3jCPSqspYB 2Dl9zNO3rzaUpGIvZbqvOj01pLwZpsGFJ3BDSOVJQjj9njGqpgS+e/sIv1Mrcq1rFjoa YbCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739257992; x=1739862792; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=1M90f9gsI1f48Hqjb2BLQB6BstLpjEMs52h9ixJ5wrI=; b=dkyU5aADaNV/51mhNpftZlhxNrSyxba7D4vlz1l+lZWISFOQygAm4wZaEwQRtwBHt0 ICTQ4XsHotLcd2DyKomkHIoens2SK3wzJwP/0TXfxW5b5c3y46p9BQyRXo9HCGdLvzuk B6ixUMKbuGxG0lVS1KPRzYfhcEZTBQl3IRnp+x7qkwCzKWc8xsjnoeK7gAk9OTkJzSrS CSoGQvwMaePhjTP/NHsQYrrMPUyYWDGDoJAQ0rWJ2+w61GgT7Qtp8qMtu/rcemI1qG5r X6IGtV1UYC4oxrHKw9bLjv4WQJYCjxctB+RTO1o9h/04r+EzRbnSeEBhwJjjvBN6muN4 NR+A== X-Gm-Message-State: AOJu0Yzu0W4Y3jshyWfulhAlwuimTYTkHc7Xsaw2czUkUZgprNPR2TRW kNUY07rYDf5/ZXm0ion6LhFrvtg4Z/kNewszrtuQZO6ig0HfJpTZR9vQrbLGucKytcQK2lObvWL lMzZ2DJoYCYMKagE+DetFtbLE+tPlyf0EaB4= X-Gm-Gg: ASbGnct3n3Hsben7WNs/utHsicks9uRnhZ+mZNwAHcgLK9hrNl4LPcB4rlv08aLicfQ DthxZtRjreamzRWiamcS6TB/0OYekfQooYF5l9BXO8YDd/SeFqThdwEW6t23QYwyl4NY1Za2V6Q == X-Google-Smtp-Source: AGHT+IEk5++vnDcx9eHyD1LqAcketiMvayO8u13Hn56T8EDvxIHvOIAOGRSG7Jq6vsuM+BrT0X6YGQdBmLWaDLg+77E= X-Received: by 2002:a05:6402:354c:b0:5de:4acc:8a97 with SMTP id 4fb4d7f45d1cf-5de4acc8d20mr14345581a12.8.1739257992155; Mon, 10 Feb 2025 23:13:12 -0800 (PST) Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 10 Feb 2025 23:13:11 -0800 From: Stefan Kangas MIME-Version: 1.0 Date: Mon, 10 Feb 2025 23:13:11 -0800 X-Gm-Features: AWEUYZnKk1YgiOfdRLcZ3gnGTla_JqjxeaFbN9UmvTy9w7ZU-CV3v86RZR97vNw Message-ID: Subject: control message for bug #76025 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 76025 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 15 11:26:01 2025 Received: (at 76025) by debbugs.gnu.org; 15 Feb 2025 16:26:02 +0000 Received: from localhost ([127.0.0.1]:57512 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tjKzR-0001qV-CQ for submit@debbugs.gnu.org; Sat, 15 Feb 2025 11:26:01 -0500 Received: from mout01.posteo.de ([185.67.36.65]:51613) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tjKzN-0001qC-ID for 76025@debbugs.gnu.org; Sat, 15 Feb 2025 11:25:59 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 9FB7A240027 for <76025@debbugs.gnu.org>; Sat, 15 Feb 2025 17:25:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1739636750; bh=C8CQMLmqGAMgTgsYgcDsZ8YVqOSZSKB/0qnEhxndvE4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=jNfqrywt0N5ojXeUkpt6kYyHHGJW6GksfPvRUOpmlZC+Lz+Eg6qxsJnB8vighXLYM +oaNflFjkt+PJUJVhw9kT9DVUI7xH63+QQEbCa2K6tkfU1EdyomNj4UKc+IQUch388 eWq30JbxKpGY2+pGMNjRrkw/tampfYRyzyTaWC3IPfN7P6ntFeTe6Pe7EowaL4wNo3 PkXpm3Yea6+vlBemiryAVM/L/FNprpg9uyeotVbAXAAyVuUNOWOJSM81Il/FDsgcOV gcGr62ihxi8AP9cl9o5patqmza9xbn45qUWtkOjssB7t82PsIYRQ0gnKaye3HDQVR5 96gnPGWpZ2s9Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4YwDms6nC5z6tvk; Sat, 15 Feb 2025 17:25:49 +0100 (CET) From: Ihor Radchenko To: Phil Estival Subject: Re: [PATCH] ob-sql: session + sql.el w/o prompt In-Reply-To: <87ikq9qpcc.fsf@localhost> References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> Date: Sat, 15 Feb 2025 16:25:25 +0000 Message-ID: <87r03zcgzu.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: Michael Mauger , Org Mode List , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ihor Radchenko writes: > May you please post the patch on Emacs bug tracker? (M-x > submit-emacs-patch) and X-Debbugs-CC me? > That way, we get the Emacs maintainers involved into the discussion. The patch is in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=76025 There are no major objections to the patch other than the maintainer being interested to coordinate ob-sql improvements and sql.el changes. I am CCing the feature request thread so that we can discuss everything together. May you please update your latest patch for ob-sql.el, converting it into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes to sql.el? -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Tue Feb 18 15:47:39 2025 Received: (at 76025) by debbugs.gnu.org; 18 Feb 2025 20:47:40 +0000 Received: from localhost ([127.0.0.1]:34324 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tkUVH-0006TM-Ae for submit@debbugs.gnu.org; Tue, 18 Feb 2025 15:47:39 -0500 Received: from smtp-42af.mail.infomaniak.ch ([2001:1600:7:10::42af]:39033) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tkUVB-0006S4-IM for 76025@debbugs.gnu.org; Tue, 18 Feb 2025 15:47:34 -0500 Received: from smtp-4-0001.mail.infomaniak.ch (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4YyBRK195CzNQR; Tue, 18 Feb 2025 21:47:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1739911645; bh=3bHhpFvaZKAmKCEl25vzNUR/PZboFqUuxq4xfdAfylY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=VRYi19XrQgRNf2lR9rUag1OhoNxFylm0XZ/W8uh7p1+YKoY6VOq/8z3W4t3tKb4A3 WVqtbEDLazLo5HMTV6gp6Qc4Usxe4Szn1UjtwSlNs+xrJZovksTjAanH7vSF/nXoIC dFUaSPxEbTVQwpOlPSBEI2ZGJdePYJ5c1C65Mz4X8XvCtt9pRyN2nb03V1gdZsvMnI D2zaV+Rvhbxny56ElCg5flurTuO3Mq3utTN6DVj16oJsvh79xV5dbTQeunXBL6UPHr DoOrOSAoU0XYVB3b4bWRhCx8QphReRUTLKQlpmSVKJSmyq1Xx+qzAd/G3467DRpABe KkT2C3CewHxRA== Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4YyBRH65fwz9lC; Tue, 18 Feb 2025 21:47:23 +0100 (CET) From: Phil Estival To: Eli Zaretskii Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting In-Reply-To: <86v7tm5iqz.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 07 Feb 2025 09:14:28 +0200") References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> User-Agent: mu4e 1.12.8; emacs 30.0.50 Date: Tue, 18 Feb 2025 21:47:23 +0100 Message-ID: <87ikp7nfok.fsf@7d.nz> MIME-Version: 1.0 Content-Type: text/plain X-Infomaniak-Routing: alpha X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, Ihor Radchenko , michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * [2025-02-07 09:14 +0200] Eli Zaretskii : >> Cc: 76025@debbugs.gnu.org, Michael Mauger >> From: Ihor Radchenko >> Date: Thu, 06 Feb 2025 19:14:50 +0000 >> >> Phil Estival writes: >> >> > This is a patch of `sql-product-interactive' in order to connect without >> > prompting for or asking to confirm connection parameters, using ones >> > already set and stored in `sql-database', `sql-server', -user, etc. >> >> For context, we want this feature to improve Org babel's sql library >> (ob-sql) where we need to run session programmatically. See >> https://list.orgmode.org/orgmode/646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz/ >> >> CCing sql.el maintainer. > > Thanks. > > From my POV, this change needs a NEWS entry, and I think Phil needs to > do the legal paperwork of assigning the copyright to the FSF (I can > send the form and the instructions if that's okay with Phil). I asked assign@gnu.org for a pgp pub key last Wednesday but no response so far. Is there any? -- Phil Estival From debbugs-submit-bounces@debbugs.gnu.org Wed Feb 19 07:11:39 2025 Received: (at 76025) by debbugs.gnu.org; 19 Feb 2025 12:11:40 +0000 Received: from localhost ([127.0.0.1]:44143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tkivT-00080j-FQ for submit@debbugs.gnu.org; Wed, 19 Feb 2025 07:11:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35286) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tkivO-0007zm-OO for 76025@debbugs.gnu.org; Wed, 19 Feb 2025 07:11:36 -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 ) id 1tkivI-0006Pe-55; Wed, 19 Feb 2025 07:11:28 -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=XCltb2X5rjFnw/45oh9Jc1nZEgDqcvUr3wOWXGkf0h4=; b=CMbhfhUqu4xC DLLRmYnPGHu/NW0a9hk6CKBdQ0Advo4sHgY4ZJW7wjV30Zb3F2bBmHTYSyluIcWl4lfpkmP56mXXc mxrWYISs/UoT5hY6Vr+TM9ejOFHkZB+35RrLON+HbE7ki9fI+C2wXuYUSGBc628dlT8R2YtnxBLWa 1x6uOO/FaSps+eMR/f+cBUFdB2TDn6gCzD9+Wonl20VUQSjKhKS+c4gYnjP/RWDbvn13I8qGoVjAi bRa+mimfSpo2Jw/G4644t2NHoNk6M9z/9PZm1P/M+u/9EZv1jhS00F2d+KOdx3911MxHCZXeY1jPw VhMTr1HZ7LNrXYBe3cRXRg==; Date: Wed, 19 Feb 2025 14:11:25 +0200 Message-Id: <86a5ai6snm.fsf@gnu.org> From: Eli Zaretskii To: Phil Estival In-Reply-To: <87ikp7nfok.fsf@7d.nz> (message from Phil Estival on Tue, 18 Feb 2025 21:47:23 +0100) Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> <87ikp7nfok.fsf@7d.nz> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, yantar92@posteo.net, michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Phil Estival > Cc: Ihor Radchenko , 76025@debbugs.gnu.org, > michael@mauger.com > Date: Tue, 18 Feb 2025 21:47:23 +0100 > > * [2025-02-07 09:14 +0200] Eli Zaretskii : > >> Cc: 76025@debbugs.gnu.org, Michael Mauger > >> From: Ihor Radchenko > >> Date: Thu, 06 Feb 2025 19:14:50 +0000 > >> > >> Phil Estival writes: > >> > >> > This is a patch of `sql-product-interactive' in order to connect without > >> > prompting for or asking to confirm connection parameters, using ones > >> > already set and stored in `sql-database', `sql-server', -user, etc. > >> > >> For context, we want this feature to improve Org babel's sql library > >> (ob-sql) where we need to run session programmatically. See > >> https://list.orgmode.org/orgmode/646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz/ > >> > >> CCing sql.el maintainer. > > > > Thanks. > > > > From my POV, this change needs a NEWS entry, and I think Phil needs to > > do the legal paperwork of assigning the copyright to the FSF (I can > > send the form and the instructions if that's okay with Phil). > > I asked assign@gnu.org for a pgp pub key last Wednesday > but no response so far. Is there any? I don't know, I never send any encrypted messages to them. In any case, please wait for a few more days, and then ping them and CC me. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 18 13:59:46 2025 Received: (at 76025) by debbugs.gnu.org; 18 Mar 2025 17:59:46 +0000 Received: from localhost ([127.0.0.1]:43130 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tubEA-0000N9-4H for submit@debbugs.gnu.org; Tue, 18 Mar 2025 13:59:46 -0400 Received: from mout02.posteo.de ([185.67.36.66]:54561) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tubE5-0000Lb-KQ for 76025@debbugs.gnu.org; Tue, 18 Mar 2025 13:59:43 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B2F2B240103 for <76025@debbugs.gnu.org>; Tue, 18 Mar 2025 18:59:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1742320775; bh=p8I1O7NnvFlvcmWrAQpyVFbN8tnHBz1+R65jmKCPk2M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=nVKC6Q+HlNXjSjKGPxjczlmhW2v+mttSpx2rK/rp8UDbUpfzSyTZV3sczoeJio5Bv 0NUEElNqxZK5rCY9l2ASNzGJ2sh/EvzLYOpltvCz9o4p5TYLIo9xY2hjseVS/bwFW5 hwId2C/82iqq1xVRnG9b3Zi/eYvWoMn8m4Ns9GmdexSCmdQNg+fEvxdayHENQvQtqV ZhCf7s7QllJ/TtLz20u8ulNT1LkjMEV7feFcSaqS+cISbIRNgC3/Oj+t6nUHgzFnVT ey3eIqYAQJVoE1fuu4kLBhfcmN169XqVW0fZ/bI/n3bjDkQWK/XeaA83I0YzguwR8c pjBCHblOrgTsg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4ZHKNl0hhWz9rxD; Tue, 18 Mar 2025 18:59:35 +0100 (CET) From: Ihor Radchenko To: Phil Estival Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting In-Reply-To: <87ikp7nfok.fsf@7d.nz> References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> <87ikp7nfok.fsf@7d.nz> Date: Tue, 18 Mar 2025 17:58:56 +0000 Message-ID: <87jz8m9q5b.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, Eli Zaretskii , michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Phil Estival writes: >> From my POV, this change needs a NEWS entry, and I think Phil needs to >> do the legal paperwork of assigning the copyright to the FSF (I can >> send the form and the instructions if that's okay with Phil). > > I asked assign@gnu.org for a pgp pub key last Wednesday > but no response so far. Is there any? May I know if there is any progress? -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 18 16:48:43 2025 Received: (at 76025) by debbugs.gnu.org; 18 Mar 2025 20:48:43 +0000 Received: from localhost ([127.0.0.1]:43501 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tudre-00026L-L8 for submit@debbugs.gnu.org; Tue, 18 Mar 2025 16:48:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37098) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tudrb-00024z-9h for 76025@debbugs.gnu.org; Tue, 18 Mar 2025 16:48:41 -0400 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 1tudrU-000341-7J; Tue, 18 Mar 2025 16:48:32 -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=FCHz5ujYVif1ipW6b2GnOF07jSjH/DMN2yks8RRRxG4=; b=OeyCBqdGhAQ2 xYIoMAVoPFInxnc7kkoeYloX5+JLGgYpy2gdTeMe/o8c7/kbirwQ4TXa/YLbl2xxS778i0ioIThE6 mZwZss1mNYemon11CYzJH+XcIXeDWn9U/yJASJmtZJI0NZfuIlLu9S5DDGp82HiW4gqGmumwvAcl6 om9pQI2h7gPFRN17H40Iab6yez/GRqWO6ItAfDfeb04hapWp8b659OAqgAYtkEqBuRXu6rnkaF+3S PMYY08kYFYZtV/Bm1tXRHNnsenRjE8QCWJOBFDI4UJIwZXUMU6+PfrU7F7WR5DGXzeVJPT9NrO862 kNZFNPT3cxF8HtNSARwyuQ==; Date: Tue, 18 Mar 2025 22:48:28 +0200 Message-Id: <861puuqd43.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <87jz8m9q5b.fsf@localhost> (message from Ihor Radchenko on Tue, 18 Mar 2025 17:58:56 +0000) Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> <87ikp7nfok.fsf@7d.nz> <87jz8m9q5b.fsf@localhost> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: pe@7d.nz, 76025@debbugs.gnu.org, michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Ihor Radchenko > Cc: Eli Zaretskii , 76025@debbugs.gnu.org, michael@mauger.com > Date: Tue, 18 Mar 2025 17:58:56 +0000 > > Phil Estival writes: > > >> From my POV, this change needs a NEWS entry, and I think Phil needs to > >> do the legal paperwork of assigning the copyright to the FSF (I can > >> send the form and the instructions if that's okay with Phil). > > > > I asked assign@gnu.org for a pgp pub key last Wednesday > > but no response so far. Is there any? > > May I know if there is any progress? Not that I know of, no. I also didn't see any correspondence between Phil and the copyright clerk, although usually the copyright clerk CC's me on his responses. Phil, did you send the form to the FSF? Or are you still waiting for their PGP key? From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 07 08:00:06 2025 Received: (at 76025) by debbugs.gnu.org; 7 Apr 2025 12:00:06 +0000 Received: from localhost ([127.0.0.1]:53173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u1l93-000772-M5 for submit@debbugs.gnu.org; Mon, 07 Apr 2025 08:00:06 -0400 Received: from smtp-42ad.mail.infomaniak.ch ([2001:1600:7:10::42ad]:45149) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u1l8u-000741-7N for 76025@debbugs.gnu.org; Mon, 07 Apr 2025 07:59:57 -0400 Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4ZWSSP0nzgzGMK; Mon, 7 Apr 2025 13:59:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1744027189; bh=8JYQKwQ3uaYbR106b2pQ0VAIQja2i9cu1nfFt65jA5o=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=tT5aU/sWGLCHF4emV9dBBg4OMv+QXwp/VtVNnr0r+V9cFUdXBoAj12TV9LUtwlYYf CVeRkIFsydoibRV5uQ0wDRCees5zxSeg92mGaqA+L8bXS5jKZhxFjJ/rXyEIz44dWt 2aCG4gzBnKaUHrR/cIAWdTkM7v8pwyZgXQA8T8ulobBgH+SOJyxrJtdKoxxTbf1z4p TIbxw0naQQoPyLQgyK4kgi/qzP8qGnYMX9xPbg6FGleQiDxBSlhwXpZHUcrcZc/dIN 9KlctwOewNxF8kAYKk/tlRbwpA3ulqmTYjgWC/l+Fe5Pl3xDnBi5xtjtgbh91U+Bol TYd4I92LkiG7Q== Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4ZWSSN1Qq2zWWc; Mon, 7 Apr 2025 13:59:48 +0200 (CEST) From: Phil Estival To: Eli Zaretskii Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting In-Reply-To: <861puuqd43.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 18 Mar 2025 22:48:28 +0200") References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> <87ikp7nfok.fsf@7d.nz> <87jz8m9q5b.fsf@localhost> <861puuqd43.fsf@gnu.org> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Mon, 07 Apr 2025 13:59:47 +0200 Message-ID: <87h63018ss.fsf@7d.nz> MIME-Version: 1.0 Content-Type: text/plain X-Infomaniak-Routing: alpha X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, Ihor Radchenko , michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * [2025-03-18 22:48 +0200] Eli Zaretskii : >> From: Ihor Radchenko >> Cc: Eli Zaretskii , 76025@debbugs.gnu.org, michael@mauger.com >> Date: Tue, 18 Mar 2025 17:58:56 +0000 >> >> Phil Estival writes: >> >> >> From my POV, this change needs a NEWS entry, and I think Phil needs to >> >> do the legal paperwork of assigning the copyright to the FSF (I can >> >> send the form and the instructions if that's okay with Phil). >> > >> > I asked assign@gnu.org for a pgp pub key last Wednesday >> > but no response so far. Is there any? >> >> May I know if there is any progress? > > Not that I know of, no. > > I also didn't see any correspondence between Phil and the copyright > clerk, although usually the copyright clerk CC's me on his responses. > > Phil, did you send the form to the FSF? Or are you still waiting for > their PGP key? I'm writing to them again to ask if there is one. -- Phil Estival From debbugs-submit-bounces@debbugs.gnu.org Tue Apr 15 12:30:09 2025 Received: (at 76025) by debbugs.gnu.org; 15 Apr 2025 16:30:10 +0000 Received: from localhost ([127.0.0.1]:54384 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u4jAl-0004zb-8X for submit@debbugs.gnu.org; Tue, 15 Apr 2025 12:30:09 -0400 Received: from mout01.posteo.de ([185.67.36.65]:36019) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u4jAg-0004wU-Br for 76025@debbugs.gnu.org; Tue, 15 Apr 2025 12:30:04 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 78FD5240028 for <76025@debbugs.gnu.org>; Tue, 15 Apr 2025 18:29:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1744734595; bh=+DTV/mxdLJEIrNoJgM8bPV0hXBBaJjGy/D+c8ZeumOk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=Za6AvaukJarb964i9dFK2IlDM1S4hetbCDAYVJrIuRTP8axD3Ueci4Q0oEcMxqcjn xjwxPdVKHM0FwN0OTaEWHJIZz2SEJlmWRn1yr3oknP3/3wgZSCjoAccZM7+stmbmsh YOrZIl35r1Cd1YIXkVv9o9aWQEQq0oJKIzpePf6aMjV2MYgGon3YFYlv5CMzhaXMRC 8sagtw31sR26oPbLNXCXDfSP6PTh/ZfmjqmEd+S1yJtJH2QByQT/HpQaOc5C5Mmyuk boXSFJhSQ81zdgmgRh6XUGrjwURvAdjBzKx/tmVVATEAWKlbllnW0F7bPdVmeX7rEi Pgayh6exGKY8w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4ZcV4L6TP8z6v0b; Tue, 15 Apr 2025 18:29:54 +0200 (CEST) From: Ihor Radchenko To: Phil Estival Subject: Re: bug#76025: [PATCH] ob-sql: session + sql.el w/o prompt In-Reply-To: <87r03zcgzu.fsf@localhost> References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> Date: Tue, 15 Apr 2025 16:29:07 +0000 Message-ID: <87v7r51j8s.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: Org Mode List , Michael Mauger , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ihor Radchenko writes: > May you please update your latest patch for ob-sql.el, converting it > into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes > to sql.el? It has been a while since the last message in this thread. Phil, do you need any help on this? -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 16 12:24:34 2025 Received: (at 76025) by debbugs.gnu.org; 16 Apr 2025 16:24:35 +0000 Received: from localhost ([127.0.0.1]:40799 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u55Yt-00079f-J0 for submit@debbugs.gnu.org; Wed, 16 Apr 2025 12:24:34 -0400 Received: from smtp-8fa9.mail.infomaniak.ch ([2001:1600:7:10::8fa9]:58231) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u55Yo-00077t-4o for 76025@debbugs.gnu.org; Wed, 16 Apr 2025 12:24:28 -0400 Received: from smtp-4-0001.mail.infomaniak.ch (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4Zd5vP6dfzzKt2; Wed, 16 Apr 2025 18:24:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1744820657; bh=CjYMBThOpb45DCS2EqjQnyDe2yK6eaIV/rk1E3ian6U=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Jkm8+CKsie8SaTUiU0Y257eYGRVC8MRb2Npi7Zon6M+2b1Nr5FEQr+5VdEDI+FfBg SQzsheJMXuBgTxj5XijU/aLPVU9EdBCXyKCm8Ke8EepA8bmpo5MJrtyYyfMFuprIGn /WECq646fprULRykfgjUbbPKd9yjGxhzb9ON0wr1ynpLTjyIl+OrMYURyRoHvT9m0e vPSXIiXKgWL9E6fdTDkGVOg2kP3+h/lR6wXDZax4EyYz1FkfnXNWstrWuTTRQQSME0 uPtARXXPMh8/UfTe8LRdsJtTLIJr+BxHorqwcKo5s+vjcDgBe9mQMRTWcDKxlovlNN +pp1pqDaTqnuQ== Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4Zd5vN73x4z98m; Wed, 16 Apr 2025 18:24:16 +0200 (CEST) From: Phil Estival To: Ihor Radchenko Subject: Re: bug#76025: [PATCH] ob-sql: session + sql.el w/o prompt In-Reply-To: <87v7r51j8s.fsf@localhost> (Ihor Radchenko's message of "Tue, 15 Apr 2025 16:29:07 +0000") References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87v7r51j8s.fsf@localhost> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Wed, 16 Apr 2025 18:24:16 +0200 Message-ID: <875xj4jcr3.fsf@7d.nz> MIME-Version: 1.0 Content-Type: text/plain X-Infomaniak-Routing: alpha X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: Org Mode List , Michael Mauger , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) * [2025-04-15 16:29 +0000] Ihor Radchenko : > Ihor Radchenko writes: > >> May you please update your latest patch for ob-sql.el, converting it >> into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes >> to sql.el? > > It has been a while since the last message in this thread. > Phil, do you need any help on this? I'm on it. I planned last monday to provide a release of this contribution this week and the next one. I've been using it as a work configuration lately and brought a few changes. -- Phil Estival From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 19 09:56:51 2025 Received: (at 76025) by debbugs.gnu.org; 19 Apr 2025 13:56:52 +0000 Received: from localhost ([127.0.0.1]:60874 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u68gc-0005zF-CK for submit@debbugs.gnu.org; Sat, 19 Apr 2025 09:56:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33006) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u68gD-0005rT-Oa for 76025@debbugs.gnu.org; Sat, 19 Apr 2025 09:56:26 -0400 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 1u68g4-0002Mt-Un; Sat, 19 Apr 2025 09:56:19 -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=hIjFbzFetqiuBRGe2ci8Bly6EpeVwwoblKQm7xR/Y+U=; b=afgO22n+xr3f agH1bQaO+cKrBb25BZ2TR9jw3vqqcVRT/TPpJTr/x2wgQiNujFqsG/Xx2AC2CIWLioDm70nRhJsQZ 2ufHlvcqbILmBuu9ZenjJwnKhFxWXZxgEARLIOADgRqDBTH3nE78kp0DVGb/whvc06kXcWE+sn6GY 0jL3UE/ZNIXUC7VBatuEvKDbhw8HWYr+aZ1FQEG1YHgskASybMvX606RGkxLIms7utEuWfPjamvko ZnTPeEvKMBIlo5NpnDUU76Mv0ghwnnURcP+8e/RrQsGdGvYPiqItP4mJ+Ai7VrH3S/h23uzT+Ljhn WSbw6mh1dyr2o6H0hAy3Yw==; Date: Sat, 19 Apr 2025 16:56:14 +0300 Message-Id: <865xj08dc1.fsf@gnu.org> From: Eli Zaretskii To: Phil Estival In-Reply-To: <87h63018ss.fsf@7d.nz> (message from Phil Estival on Mon, 07 Apr 2025 13:59:47 +0200) Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> <87ikp7nfok.fsf@7d.nz> <87jz8m9q5b.fsf@localhost> <861puuqd43.fsf@gnu.org> <87h63018ss.fsf@7d.nz> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, yantar92@posteo.net, michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Phil Estival > Cc: Ihor Radchenko , 76025@debbugs.gnu.org, > michael@mauger.com > Date: Mon, 07 Apr 2025 13:59:47 +0200 > > * [2025-03-18 22:48 +0200] Eli Zaretskii : > >> From: Ihor Radchenko > >> Cc: Eli Zaretskii , 76025@debbugs.gnu.org, michael@mauger.com > >> Date: Tue, 18 Mar 2025 17:58:56 +0000 > >> > >> Phil Estival writes: > >> > >> >> From my POV, this change needs a NEWS entry, and I think Phil needs to > >> >> do the legal paperwork of assigning the copyright to the FSF (I can > >> >> send the form and the instructions if that's okay with Phil). > >> > > >> > I asked assign@gnu.org for a pgp pub key last Wednesday > >> > but no response so far. Is there any? > >> > >> May I know if there is any progress? > > > > Not that I know of, no. > > > > I also didn't see any correspondence between Phil and the copyright > > clerk, although usually the copyright clerk CC's me on his responses. > > > > Phil, did you send the form to the FSF? Or are you still waiting for > > their PGP key? > > I'm writing to them again to ask if there is one. Any progress with this issue? From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 28 11:53:13 2025 Received: (at 76025) by debbugs.gnu.org; 28 Apr 2025 15:53:14 +0000 Received: from localhost ([127.0.0.1]:60367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1u9Qn7-0006lX-8l for submit@debbugs.gnu.org; Mon, 28 Apr 2025 11:53:13 -0400 Received: from smtp-bc0e.mail.infomaniak.ch ([45.157.188.14]:46235) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1u9Qn1-0006k8-Bx for 76025@debbugs.gnu.org; Mon, 28 Apr 2025 11:53:05 -0400 Received: from smtp-3-0000.mail.infomaniak.ch (unknown [IPv6:2001:1600:4:17::246b]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4ZmSdh0VGdz1lV; Mon, 28 Apr 2025 17:52:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1745855575; bh=v8Sr7Jym6lfnzBuB388Z5fpUgqMKl0aVsHdrlNnyQj0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=EJT32hyuqbhZsvzHDELqmCPBbsy38Tdl5qesfIhjn170UIaacFaubqNeIsyBZ2XT7 n0poekcnt72eyjQISuHzu2VurGFTKR6ugn/WZ0tp5AuY8odQMXLPVA3UjDO+j4irNf mMZ2VN26PbTvwGpEUSFM/MO4zGI20TM4CMpyue7ErYnhvBhKV3oyvOPHkpHOH5I56s zMvHskFRaH4ynEt8YbIr2rRVQB+LI7nnDnV6QeUNhbNrQyQM0aXIe8+VBvLYFAYGlF +2xp6fpg7pmzWtFrzlCcatRVY5QydAZ7MlRF4Azg2fQ5TB1NV2Tyg4SZw8Y+ldgyrS 05ITN/oGJvXXA== Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4ZmSdg2bmHztdh; Mon, 28 Apr 2025 17:52:55 +0200 (CEST) From: Phil Estival To: Eli Zaretskii Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting In-Reply-To: <865xj08dc1.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 19 Apr 2025 16:56:14 +0300") References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> <87ikp7nfok.fsf@7d.nz> <87jz8m9q5b.fsf@localhost> <861puuqd43.fsf@gnu.org> <87h63018ss.fsf@7d.nz> <865xj08dc1.fsf@gnu.org> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Mon, 28 Apr 2025 17:52:54 +0200 Message-ID: <874iy8ffl5.fsf@7d.nz> MIME-Version: 1.0 Content-Type: text/plain X-Infomaniak-Routing: alpha X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, yantar92@posteo.net, michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * [2025-04-19 16:56 +0300] Eli Zaretskii : >> From: Phil Estival >> Cc: Ihor Radchenko , 76025@debbugs.gnu.org, >> michael@mauger.com >> Date: Mon, 07 Apr 2025 13:59:47 +0200 >> >> * [2025-03-18 22:48 +0200] Eli Zaretskii : >> >> From: Ihor Radchenko >> >> Cc: Eli Zaretskii , 76025@debbugs.gnu.org, michael@mauger.com >> >> Date: Tue, 18 Mar 2025 17:58:56 +0000 >> >> >> >> Phil Estival writes: >> >> >> >> >> From my POV, this change needs a NEWS entry, and I think Phil needs to >> >> >> do the legal paperwork of assigning the copyright to the FSF (I can >> >> >> send the form and the instructions if that's okay with Phil). >> >> > >> >> > I asked assign@gnu.org for a pgp pub key last Wednesday >> >> > but no response so far. Is there any? >> >> >> >> May I know if there is any progress? >> > >> > Not that I know of, no. >> > >> > I also didn't see any correspondence between Phil and the copyright >> > clerk, although usually the copyright clerk CC's me on his responses. >> > >> > Phil, did you send the form to the FSF? Or are you still waiting for >> > their PGP key? >> >> I'm writing to them again to ask if there is one. > > Any progress with this issue? The ticketing system does not support encryption but they answered positively, I received a key and the ball's in my court now. There was less room in my schedule than I expected, but I'll finally get back to you these days with the contribution, this time for real. -- Phil Estival From debbugs-submit-bounces@debbugs.gnu.org Tue May 13 10:04:04 2025 Received: (at 76025) by debbugs.gnu.org; 13 May 2025 14:04:05 +0000 Received: from localhost ([127.0.0.1]:60698 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uEqEl-0008LA-VV for submit@debbugs.gnu.org; Tue, 13 May 2025 10:04:04 -0400 Received: from smtp-190f.mail.infomaniak.ch ([2001:1600:7:10::190f]:32861) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uEqEh-0008KS-2T for 76025@debbugs.gnu.org; Tue, 13 May 2025 10:04:01 -0400 Received: from smtp-4-0001.mail.infomaniak.ch (unknown [IPv6:2001:1600:7:10::a6c]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4ZxdVt4ty3zPR3; Tue, 13 May 2025 16:03:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1747145030; bh=/IbfQ79swkpYrPmUkILSJRHfnnxBbTzDQb8gEkEGAws=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=skXyTDHA1LhTkm4ihe5eDA8NatFdW8rOpCzCJ4Z/Rh93TPoXXZ4oPYPzadi0muUrY 5H333KfvIR6o6odsuzW8dhHnKSNW/YeTK54J3/Nu7kOOoogFRQdLaaRgsy8IZS8ZLa wQRyJvRPhglIzxs7oWmThaZCCsiDZL6C+D3sCEOBD1Nz8b5htOh5OsBfpHcH+QfxKZ PWgbXqMm+bfr/3acH5lAUCzZNZOYRq3X0z7whPM1slTmhO7g45rvk+AWIIy4ewuQXX HrBr3lXGqeM3uQ4RLTuv01HebOMXoDcsAGJTIOITsnLYtZJFhB8HwcIAVDQ4u0Ohpp cCVy8fUruT1AQ== Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4ZxdVt1G8Lz2Bw; Tue, 13 May 2025 16:03:49 +0200 (CEST) From: Phil Estival To: Ihor Radchenko Subject: Re: [PATCH] ob-sql: session + sql.el w/o prompt In-Reply-To: <87r03zcgzu.fsf@localhost> (Ihor Radchenko's message of "Sat, 15 Feb 2025 16:25:25 +0000") References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Tue, 13 May 2025 16:03:49 +0200 Message-ID: <87y0v0mwu2.fsf@7d.nz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Infomaniak-Routing: alpha X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, Michael Mauger X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain * [2025-02-15 16:25 +0000] Ihor Radchenko : > Ihor Radchenko writes: > > May you please update your latest patch for ob-sql.el, converting it > into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes > to sql.el? I'm submitting again the patch to sql.el with two additionnal modifications. This replaces the previous one. -- Phil Estival --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-progmodes-sql.el-login-without-prompting.patch >From d83ee2c93d249673281c401bb78eb0569cd17e07 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Tue, 13 May 2025 15:39:51 +0200 Subject: [PATCH 1/2] * lisp/progmodes/sql.el: login without prompting New optional parameter 'no-prompt' to `sql-product-interactive'. When set with all connection parameters provided, skip the call to `sql-get-login' to connect without opening the prompt, but still prompt if any required parameter is missing. Also skip the prompt for SQLite when no database name is provided in order to connect to the in-memory transient database. --- lisp/progmodes/sql.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 58fbf3c51e7..af5b1a399cb 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -4524,13 +4524,15 @@ sql-connection-menu-filter ;;; Entry functions for different SQL interpreters. ;;;###autoload -(defun sql-product-interactive (&optional product new-name) - "Run PRODUCT interpreter as an inferior process. +(defun sql-product-interactive (&optional product new-name no-prompt) + "Run PRODUCT interpreter as an inferior process in a NEW-NAME buffer. If buffer `*SQL*' exists but no process is running, make a new process. If buffer exists and a process is running, just make sure buffer `*SQL*' is displayed. +When NO-PROMPT is set, try to connect without prompting +with the already supplied parameters. To specify the SQL product, prefix the call with \\[universal-argument]. To set the buffer name as well, prefix the call to \\[sql-product-interactive] with @@ -4572,8 +4574,16 @@ sql-product-interactive new-sqli-buffer rpt) ;; Get credentials. - (apply #'sql-get-login - (sql-get-product-feature product :sqli-login)) + (when (or (not no-prompt) ; default + (and no-prompt ; or a parameter missing + (cl-some #'(lambda (s) (or (null s) (string= (format "%s" s) ""))) + (list sql-server sql-user sql-password sql-database)) + ;; sqlite allows in-memory db, w/o login + (not (and (or (null sql-database) + (string= "" sql-database)) + (eq product 'sqlite))))) + (apply #'sql-get-login + (sql-get-product-feature product :sqli-login))) ;; Connect to database. (setq rpt (sql-make-progress-reporter nil "Login")) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-lisp-progmodes-sql.el-sql-comint-sqlite-allows-nil-d.patch >From 18c84feeb1d3f368a7e0e90692efe7a6a5b7c64f Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Tue, 13 May 2025 15:57:24 +0200 Subject: [PATCH 2/2] * lisp/progmodes/sql.el: sql-comint-sqlite allows nil database name Connecting to SQLite with no database name provided (be it nil or empty string), means to connect to the in-memory transient database. Since no parameter can be given, they are made optional. --- lisp/progmodes/sql.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index af5b1a399cb..296f0336081 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -5075,13 +5075,15 @@ sql-sqlite (interactive "P") (sql-product-interactive 'sqlite buffer)) -(defun sql-comint-sqlite (product options &optional buf-name) - "Create comint buffer and connect to SQLite." +(defun sql-comint-sqlite (product &optional options buf-name) + "Create a comint buffer and connect to SQLite (PRODUCT). +See `sql-comint' for the OPTIONS and BUF-NAME parameters." ;; Put all parameters to the program (if defined) in a list and call ;; make-comint. (let ((params (append options - (if (not (string= "" sql-database)) + (if (and sql-database + (not (string= "" sql-database))) `(,(expand-file-name sql-database)))))) (sql-comint product params buf-name))) -- 2.39.5 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed May 14 10:29:49 2025 Received: (at 76025) by debbugs.gnu.org; 14 May 2025 14:29:50 +0000 Received: from localhost ([127.0.0.1]:44229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uFD7E-0004fU-3S for submit@debbugs.gnu.org; Wed, 14 May 2025 10:29:49 -0400 Received: from smtp-190c.mail.infomaniak.ch ([2001:1600:4:17::190c]:58537) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uFD77-0004fA-Vo for 76025@debbugs.gnu.org; Wed, 14 May 2025 10:29:45 -0400 Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4ZyG2720bCz14sj; Wed, 14 May 2025 16:29:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1747232975; bh=zKg+gZURmjtl+Ym6AN/3naasYzs7RBEpb3p8JQwTSEo=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=OoKsR+SzWn8r1USeK6KGmqSloJOUqCMwj3uSh7lFznjk02+NhytudefX9p6OL4oJ6 g9hhfnFrZ1Jf065oq9lZpZyjhXVPJlDO2zpmpOuvi67ongKq5u3WbiR77o5R2SEn0d mxwMK03LsMQ4jceU7W8A/Ml1O2IslKS/GuCh9yMG1gBL+/7dtuBVekfRUm+veQwmTC /X4BBmAYpzrpU576JrraFi+dmgQwUkMqwqkPA6rm7xpoLaP0qCjIpOvZaO/BwzGPYV +LYRa0Y9XkVBewE6q5rRG+JhbPo7YAcm9gyc9PlQBfk3k8u81WA50Pc7xZVaz0YbeR JzYuyOWsca5mw== Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4ZyG264XWpzy0f; Wed, 14 May 2025 16:29:34 +0200 (CEST) From: Phil Estival To: Ihor Radchenko Subject: Re: [PATCH] ob-sql: session + sql.el w/o prompt In-Reply-To: <87r03zcgzu.fsf@localhost> (Ihor Radchenko's message of "Sat, 15 Feb 2025 16:25:25 +0000") References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Wed, 14 May 2025 16:29:34 +0200 Message-ID: <87sel7mfjl.fsf@7d.nz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Infomaniak-Routing: alpha X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76025 Cc: Michael Mauger , Org Mode List , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable * [2025-02-15 16:25 +0000] Ihor Radchenko : > Ihor Radchenko writes: > > May you please update your latest patch for ob-sql.el, converting it > into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes > to sql.el? Here they are 1) the patch of sql.el 2) the list of changes in ob-sql.el against release_9.7.30. The patch that assumes the change in sql.el is n=C2=B013. Cheers -- Phil Estival --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-lisp-progmodes-sql.el-login-without-prompting.patch >From d83ee2c93d249673281c401bb78eb0569cd17e07 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Tue, 13 May 2025 15:39:51 +0200 Subject: [PATCH 1/2] * lisp/progmodes/sql.el: login without prompting New optional parameter 'no-prompt' to `sql-product-interactive'. When set with all connection parameters provided, skip the call to `sql-get-login' to connect without opening the prompt, but still prompt if any required parameter is missing. Also skip the prompt for SQLite when no database name is provided in order to connect to the in-memory transient database. --- lisp/progmodes/sql.el | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index 58fbf3c51e7..af5b1a399cb 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -4524,13 +4524,15 @@ sql-connection-menu-filter ;;; Entry functions for different SQL interpreters. ;;;###autoload -(defun sql-product-interactive (&optional product new-name) - "Run PRODUCT interpreter as an inferior process. +(defun sql-product-interactive (&optional product new-name no-prompt) + "Run PRODUCT interpreter as an inferior process in a NEW-NAME buffer. If buffer `*SQL*' exists but no process is running, make a new process. If buffer exists and a process is running, just make sure buffer `*SQL*' is displayed. +When NO-PROMPT is set, try to connect without prompting +with the already supplied parameters. To specify the SQL product, prefix the call with \\[universal-argument]. To set the buffer name as well, prefix the call to \\[sql-product-interactive] with @@ -4572,8 +4574,16 @@ sql-product-interactive new-sqli-buffer rpt) ;; Get credentials. - (apply #'sql-get-login - (sql-get-product-feature product :sqli-login)) + (when (or (not no-prompt) ; default + (and no-prompt ; or a parameter missing + (cl-some #'(lambda (s) (or (null s) (string= (format "%s" s) ""))) + (list sql-server sql-user sql-password sql-database)) + ;; sqlite allows in-memory db, w/o login + (not (and (or (null sql-database) + (string= "" sql-database)) + (eq product 'sqlite))))) + (apply #'sql-get-login + (sql-get-product-feature product :sqli-login))) ;; Connect to database. (setq rpt (sql-make-progress-reporter nil "Login")) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-lisp-progmodes-sql.el-sql-comint-sqlite-allows-nil-d.patch >From 18c84feeb1d3f368a7e0e90692efe7a6a5b7c64f Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Tue, 13 May 2025 15:57:24 +0200 Subject: [PATCH 2/2] * lisp/progmodes/sql.el: sql-comint-sqlite allows nil database name Connecting to SQLite with no database name provided (be it nil or empty string), means to connect to the in-memory transient database. Since no parameter can be given, they are made optional. --- lisp/progmodes/sql.el | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/sql.el b/lisp/progmodes/sql.el index af5b1a399cb..296f0336081 100644 --- a/lisp/progmodes/sql.el +++ b/lisp/progmodes/sql.el @@ -5075,13 +5075,15 @@ sql-sqlite (interactive "P") (sql-product-interactive 'sqlite buffer)) -(defun sql-comint-sqlite (product options &optional buf-name) - "Create comint buffer and connect to SQLite." +(defun sql-comint-sqlite (product &optional options buf-name) + "Create a comint buffer and connect to SQLite (PRODUCT). +See `sql-comint' for the OPTIONS and BUF-NAME parameters." ;; Put all parameters to the program (if defined) in a list and call ;; make-comint. (let ((params (append options - (if (not (string= "" sql-database)) + (if (and sql-database + (not (string= "" sql-database))) `(,(expand-file-name sql-database)))))) (sql-comint product params buf-name))) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-ob-sql-session-support.-Introduces-new-variables-and.patch >From ec8ebf2cad6a6ca20596e85d38f68c5c75d34f1f Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:31:35 +0200 Subject: [PATCH 01/14] ob-sql: session support. Introduces new variables and functions * lisp/ob-sql.el: new variables and functions for session support for postgres and sqlite. Requires sql.el for a connection to a session. SQL clients are configured by a preamble of commands given to the SQL shell. Custom variables are declared in a new sub-group ob-babel-sql. The echo of an SQL ANSI comment is to be appended to the source block of SQL commands for comint to detect when the commands terminate, instead of relying on prompt detection. --- lisp/ob-sql.el | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index ca6512783..3552d46da 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -4,6 +4,7 @@ ;; Author: Eric Schulte ;; Maintainer: Daniel Kraus +;; Maintainer: Philippe Estival ;; Keywords: literate programming, reproducible research ;; URL: https://orgmode.org @@ -75,6 +76,33 @@ (org-assert-version) (require 'ob) +(require 'sql) + +(defvar org-babel-sql-session-start-time) +(defvar org-sql-session-preamble + (list + 'postgres "\\set ON_ERROR_STOP 1 +\\pset footer off +\\pset pager off +\\pset format unaligned" ) + "Command preamble to run upon shell start.") +(defvar org-sql-session-command-terminated nil) +(defvar org-sql-session--batch-terminate "---#" "To print at the end of a command batch.") +(defvar org-sql-batch-terminate + (list 'sqlite (format ".print %s\n" org-sql-session--batch-terminate) + 'postgres (format "\\echo %s\n" org-sql-session--batch-terminate)) + "Print the command batch termination as last command.") +(defvar org-sql-terminal-command-prefix + (list 'sqlite "\\." + 'postgres "\\\\") + "Identify a command for the SQL shell.") +(defvar org-sql-environment + (list 'postgres '(("PGPASSWORD" sql-password)))) +(defvar org-sql-session-clean-output nil + "Store the regexp used to clear output (prompt1|termination|prompt2).") +(defvar org-sql-session-start-time) +(defvar org-sql-session-command-terminated nil) +(defvar org-sql-session--batch-terminate "---#" "To print at the end of a command batch.") (declare-function org-table-import "org-table" (file arg)) (declare-function orgtbl-to-csv "org-table" (table params)) @@ -85,6 +113,25 @@ (defvar sql-connection-alist) (defvar org-babel-default-header-args:sql '()) +(defcustom org-sql-run-comint-p 'nil + "Run non-session SQL commands through comint if not nil." + :type '(boolean) + :group 'org-babel-sql + :safe t) + +(defcustom org-sql-timeout '5.0 + "Abort on timeout." + :type '(number) + :group 'org-babel-sql + :safe t) + +(defcustom org-sql-close-out-temp-buffer-p 'nil + "To automatically close sql-out-temp buffer." + :type '(boolean) + :group 'org-babel-sql + :safe t) + + (defconst org-babel-header-args:sql '((engine . :any) (out-file . :any) @@ -419,6 +466,29 @@ argument mechanism." "Raise an error because Sql sessions aren't implemented." (error "SQL sessions not yet implemented")) + +(defun org-sql-session-comint-output-filter (_proc string) + "Process output STRING of PROC gets redirected to a temporary buffer. +It is called several times consecutively as the shell outputs and flush +its message buffer" + + ;; Inserting a result in the sql process buffer (to read it as a + ;; regular prompt log) inserts it to the terminal, and as a result the + ;; ouput would get passed as input onto the next command line; See + ;; `comint-redirect-setup' to possibly fix that, + ;; (with-current-buffer (process-buffer proc) (insert output)) + + (when (or (string-match org-sql-session--batch-terminate string) + (> (time-to-seconds + (time-subtract (current-time) + org-sql-session-start-time)) + org-sql-timeout)) + (setq org-sql-session-command-terminated t)) + + (with-current-buffer (get-buffer-create "*ob-sql-result*") + (insert string))) + + (provide 'ob-sql) ;;; ob-sql.el ends here -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-ob-sql-default-header-arguments-are-declared-in-a-cu.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:32:59 +0200 Subject: [PATCH 02/14] ob-sql: default header arguments are declared in a custom variable * lisp/ob-sql.el: default header arguments are declared in a custom variable with :options of composite types. --- lisp/ob-sql.el | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 3552d46da..51f029b36 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -111,7 +111,13 @@ (declare-function sql-set-product "sql" (product)) (defvar sql-connection-alist) -(defvar org-babel-default-header-args:sql '()) +(defcustom org-babel-default-header-args:sql '((:engine . "unset")) + "Default header args." + :type '(alist :key-type symbol :value-type string + :options ("dbi" "sqlite" "mysql" "postgres" + "sqsh" "mssql" "vertica" "oracle" "saphana" )) + :group 'org-babel-sql + :safe t) (defcustom org-sql-run-comint-p 'nil "Run non-session SQL commands through comint if not nil." -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-ob-sql-remove-org-assert-version-to-stay-compatible-.patch >From 5ea82bf324bfd147aa5ed9a6dd8df0c39539b167 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:34:27 +0200 Subject: [PATCH 03/14] ob-sql: remove org-assert-version to stay compatible with org 9.5 * lisp/ob-sql.el: removal of org-assert-version makes org-macs no longer needed. --- lisp/ob-sql.el | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 51f029b36..5ef4bd014 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -71,10 +71,6 @@ ;; ;;; Code: - -(require 'org-macs) -(org-assert-version) - (require 'ob) (require 'sql) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-ob-sql-realign-variables-for-improved-readability.patch >From 0b1adbbfc7c52f70dd5156c2b5cdf30757ae6682 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:35:59 +0200 Subject: [PATCH 04/14] ob-sql: realign variables for improved readability. --- lisp/ob-sql.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 5ef4bd014..194c3941b 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -288,12 +288,12 @@ database connections." This function is called by `org-babel-execute-src-block'." (let* ((result-params (cdr (assq :result-params params))) (cmdline (cdr (assq :cmdline params))) - (dbhost (org-babel-find-db-connection-param params :dbhost)) - (dbport (org-babel-find-db-connection-param params :dbport)) - (dbuser (org-babel-find-db-connection-param params :dbuser)) + (dbhost (org-babel-find-db-connection-param params :dbhost)) + (dbport (org-babel-find-db-connection-param params :dbport)) + (dbuser (org-babel-find-db-connection-param params :dbuser)) (dbpassword (org-babel-find-db-connection-param params :dbpassword)) (dbinstance (org-babel-find-db-connection-param params :dbinstance)) - (database (org-babel-find-db-connection-param params :database)) + (database (org-babel-find-db-connection-param params :database)) (engine (cdr (assq :engine params))) (colnames-p (not (equal "no" (cdr (assq :colnames params))))) (in-file (org-babel-temp-file "sql-in-")) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0005-ob-sql-fix-docstring.patch >From 3f28c76f9c29d175d0543a2ce7dfbe3aaa03454f Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:43:31 +0200 Subject: [PATCH 05/14] ob-sql: fix docstring. --- lisp/ob-sql.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 194c3941b..7abdf608c 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -284,7 +284,7 @@ database connections." (cdr (assoc-string dbconnection sql-connection-alist t)))))))) (defun org-babel-execute:sql (body params) - "Execute a block of Sql code with Babel. + "Execute a BODY of SQL code with given PARAMS. This function is called by `org-babel-execute-src-block'." (let* ((result-params (cdr (assq :result-params params))) (cmdline (cdr (assq :cmdline params))) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0006-ob-sql-turn-a-unique-cond-expression-to-a-when-expre.patch >From 7f32afffc89ea2442b6e9ec9f4697641c2078755 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:45:44 +0200 Subject: [PATCH 06/14] ob-sql: turn a unique (cond expression) to a (when expression) --- lisp/ob-sql.el | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 7abdf608c..568de9bf6 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -401,15 +401,13 @@ SET COLSEP '|' (cond ((memq (intern engine) '(dbi mysql postgresql postgres saphana sqsh vertica)) ;; Add header row delimiter after column-names header in first line - (cond - (colnames-p - (with-temp-buffer - (insert-file-contents out-file) - (goto-char (point-min)) - (forward-line 1) - (insert "-\n") - (setq header-delim "-") - (write-file out-file))))) + (when colnames-p (with-temp-buffer + (insert-file-contents out-file) + (goto-char (point-min)) + (forward-line 1) + (insert "-\n") + (setq header-delim "-") + (write-file out-file)))) (t ;; Need to figure out the delimiter for the header row (with-temp-buffer -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0007-ob-sql-new-function-for-session-and-db-connection-in.patch >From dfbd8cb3834a9efc24a66ff153d0e8a456fd1136 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:49:52 +0200 Subject: [PATCH 07/14] ob-sql: new function for session and db connection initiation * lisp/ob-sql.el: introduces `org-babel-sql-session-connect'. It calls the updated `sql-product-interactive' which accept 3 arguments in order to connect without prompting when all parameters are provided in the code block header. --- lisp/ob-sql.el | 58 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 568de9bf6..880e8cdba 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -462,10 +462,60 @@ argument mechanism." vars) body) -(defun org-babel-prep-session:sql (_session _params) - "Raise an error because Sql sessions aren't implemented." - (error "SQL sessions not yet implemented")) - +(defun org-babel-sql-session-connect (in-engine params session) + "Start the SQL client of IN-ENGINE if it has not. +PARAMS provides the sql connection parameters for a new or +existing SESSION. Clear the intermediate buffer from previous +output, and set the process filter. Return the comint process +buffer." + (let* ((buffer-name (format "%s" (if (string= session "none") "" + (format "[%s]" session)))) + (ob-sql-buffer (format "*SQL: %s*" buffer-name))) + + ;; initiate a new connection + (when (not (org-babel-comint-buffer-livep ob-sql-buffer)) + ;; store the regexp used to clear output (prompt1|indicator|prompt2) + (let ((prompt-regexp (sql-get-product-feature in-engine :prompt-regexp )) + (prompt-cont-regexp (sql-get-product-feature in-engine :prompt-cont-regexp))) + (setq org-sql-session-clean-output + (plist-put org-sql-session-clean-output in-engine + (concat "\\(" prompt-regexp "\\)" + "\\|\\(" org-sql-session--batch-terminate "\n\\)" + (when prompt-cont-regexp + (concat "\\|\\(" prompt-cont-regexp "\\)")))))) + + (let ((sql-server (cdr (assoc :dbhost params))) + (port (cdr (assoc :port params))) + (sql-database (cdr (assoc :database params))) + (sql-user (cdr (assoc :dbuser params))) + (sql-password (cdr (assoc :dbpassword params)))) + (when port (setq-local sql-port port)) + (save-window-excursion + ;; provides environment expressions to the comint service + (let ((process-environment (copy-sequence process-environment)) + (variables (sql-get-product-feature in-engine :sql-environment))) + (mapc (lambda (elem) ; evaluate environment expressions + (setenv (car elem) (eval (cadr elem)))) + variables) + (sql-product-interactive in-engine buffer-name t))) + + (let ((sql-term-proc (get-buffer-process ob-sql-buffer))) + (unless sql-term-proc + (user-error (format "SQL %s didn't start" in-engine))) + + (with-current-buffer (get-buffer ob-sql-buffer) + ;; preamble commands + (let ((preamble (plist-get org-sql-session-preamble in-engine))) + (when preamble + (process-send-string ob-sql-buffer preamble) + (comint-send-input)))) + ;; let the preamble execution finish and be filtered + (sleep-for 0.1)))) + + ;; set the redirection filter and return the SQL client buffer + (set-process-filter (get-buffer-process ob-sql-buffer) + #'org-sql-session-comint-output-filter) + (get-buffer ob-sql-buffer))) (defun org-sql-session-comint-output-filter (_proc string) "Process output STRING of PROC gets redirected to a temporary buffer. -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0008-ob-sql-simplify-docstring.patch >From dfe081ced1410e128d83393fb044149051e7b63f Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:54:06 +0200 Subject: [PATCH 08/14] ob-sql: simplify docstring. --- lisp/ob-sql.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 880e8cdba..6fa4d38b3 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -284,7 +284,7 @@ database connections." (cdr (assoc-string dbconnection sql-connection-alist t)))))))) (defun org-babel-execute:sql (body params) - "Execute a BODY of SQL code with given PARAMS. + "Execute SQL BODY with PARAMS. This function is called by `org-babel-execute-src-block'." (let* ((result-params (cdr (assq :result-params params))) (cmdline (cdr (assq :cmdline params))) -- 2.39.5 --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0009-ob-sql-add-support-for-sessions-in-org-babel-execute.patch Content-Transfer-Encoding: quoted-printable >From 53052417c00d3d1464d0823adee4d637b16b8fea Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 14:57:33 +0200 Subject: [PATCH 09/14] ob-sql: add support for sessions in `org-babel-execute:sql' MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/ob-sql.el: regular code block execution can also be run through the same path as sessions =E2=80=94 e.g. functions of sql.el and a comint buffer =E2=80=94 when the custom predicate `org-sql-run-comint-p' is set. --- lisp/ob-sql.el | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 6fa4d38b3..42b30b85c 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -295,11 +295,52 @@ This function is called by `org-babel-execute-src-blo= ck'." (dbinstance (org-babel-find-db-connection-param params :dbinstanc= e)) (database (org-babel-find-db-connection-param params :database)) (engine (cdr (assq :engine params))) + (in-engine (intern (or engine (user-error "Missing :engine")))) (colnames-p (not (equal "no" (cdr (assq :colnames params))))) (in-file (org-babel-temp-file "sql-in-")) (out-file (or (cdr (assq :out-file params)) (org-babel-temp-file "sql-out-"))) (header-delim "") + (session (cdr (assoc :session params))) + (session-p (not (string=3D session "none")))) + + (if (or session-p org-sql-run-comint-p) ; run through comint + (let ((sql--buffer + (org-babel-sql-session-connect in-engine params session))) + (with-current-buffer (get-buffer-create "*ob-sql-result*") + (erase-buffer)) + (setq org-sql-session-start-time (current-time)) + (setq org-sql-session-command-terminated nil) + + (with-current-buffer (get-buffer sql--buffer) + (process-send-string (current-buffer) + (org-sql-session-format-query + (org-babel-expand-body:sql body par= ams) + in-engine)) + (while (or (not org-sql-session-command-terminated) + (> (time-to-seconds + (time-subtract (current-time) + org-sql-session-start-time)) + org-sql-timeout)) + (sleep-for 0.03)) + ;; command finished, remove filter + (set-process-filter (get-buffer-process sql--buffer) nil) + + (when (not session-p) + (comint-quit-subjob) + ;; despite this quit signal, the process may not be finished yet + (let ((kill-buffer-query-functions nil)) + (kill-this-buffer)))) + + (with-current-buffer (get-buffer-create "*ob-sql-result*") + (goto-char (point-min)) + ;; clear the output or prompt and termination + (let ((clean-output (plist-get org-sql-session-clean-output in-engine))) + (while (re-search-forward clean-output nil t) + (replace-match ""))) + (write-file out-file))) + + (let ( ; else run one command line (command (cl-case (intern engine) (dbi (format "dbish --batch %s < %s | sed '%s' > %s" (or cmdline "") @@ -393,7 +434,7 @@ SET COLSEP '|' (org-babel-expand-body:sql body params) ;; "sqsh" requires "go" inserted at EOF. (if (string=3D engine "sqsh") "\ngo" ""))) - (org-babel-eval command "") + (org-babel-eval command ""))) (org-babel-result-cond result-params (with-temp-buffer (progn (insert-file-contents-literally out-file) (buffer-string))) @@ -423,6 +464,8 @@ SET COLSEP '|' (forward-char -1)) (write-file out-file)))) (org-table-import out-file (if (string=3D engine "sqsh") '(4) '(16))) + (when org-sql-close-out-temp-buffer-p + (kill-buffer (get-file-buffer out-file))) (org-babel-reassemble-table (mapcar (lambda (x) (if (string=3D (car x) header-delim) --=20 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0010-ob-sql-Fix-org-babel-expand-body-returning-extra-n.patch >From 95ad7b5797c6efc924fa2bd2bf995a5b786f1943 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 15:00:24 +0200 Subject: [PATCH 10/14] ob-sql: Fix `org-babel-expand-body' returning extra \n * lisp/ob-sql.el: empty prologue or epilogue or expanded variables are no longer replaced by a newline. --- lisp/ob-sql.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 42b30b85c..8cdb0848a 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -150,11 +150,11 @@ (let ((prologue (cdr (assq :prologue params))) (epilogue (cdr (assq :epilogue params)))) (mapconcat 'identity - (list + (delq nil (list prologue (org-babel-sql-expand-vars body (org-babel--get-vars params)) - epilogue) + epilogue)) "\n"))) (defun org-babel-edit-prep:sql (info) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0011-ob-sql-replace-call-to-intern-engine-by-the-previous.patch >From 92e8201e4ee8d4d1f16740d9b8ba23590eec0810 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 15:01:48 +0200 Subject: [PATCH 11/14] ob-sql: replace call to (intern engine) by the previously declared in-engine TINYCHANGE --- lisp/ob-sql.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 8cdb0848a..7ee6b1a9c 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -341,7 +341,7 @@ This function is called by `org-babel-execute-src-block'." (write-file out-file))) (let ( ; else run one command line - (command (cl-case (intern engine) + (command (cl-case in-engine (dbi (format "dbish --batch %s < %s | sed '%s' > %s" (or cmdline "") (org-babel-process-file-name in-file) @@ -410,7 +410,7 @@ footer=off -F \"\t\" %s -f %s -o %s %s" (t (user-error "No support for the %s SQL engine" engine))))) (with-temp-file in-file (insert - (pcase (intern engine) + (pcase in-engine (`dbi "/format partbox\n") (`oracle "SET PAGESIZE 50000 SET NEWPAGE 0 @@ -440,7 +440,7 @@ SET COLSEP '|' (progn (insert-file-contents-literally out-file) (buffer-string))) (with-temp-buffer (cond - ((memq (intern engine) '(dbi mysql postgresql postgres saphana sqsh vertica)) + ((memq in-engine '(dbi mysql postgresql postgres saphana sqsh vertica)) ;; Add header row delimiter after column-names header in first line (when colnames-p (with-temp-buffer (insert-file-contents out-file) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0012-ob-sql-restore-support-for-sqlite.patch >From 69f06cc99636312198c767f25f4ca8bec477081f Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 15:05:28 +0200 Subject: [PATCH 12/14] ob-sql: restore support for sqlite --- lisp/ob-sql.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 7ee6b1a9c..671097b47 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -347,6 +347,9 @@ This function is called by `org-babel-execute-src-block'." (org-babel-process-file-name in-file) "/^+/d;s/^|//;s/(NULL)/ /g;$d" (org-babel-process-file-name out-file))) + (sqlite (format "sqlite3 < %s > %s" + (org-babel-process-file-name in-file) + (org-babel-process-file-name out-file))) (monetdb (format "mclient -f tab %s < %s > %s" (or cmdline "") (org-babel-process-file-name in-file) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0013-ob-sql-code-block-in-run-by-interacting-in-the-comin.patch >From 581eafcfa39dd9ffd07f0e5c3f295b7afb26e1f3 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 15:13:18 +0200 Subject: [PATCH 13/14] ob-sql: code block in run by interacting in the comint buffer * lisp/ob-sql.el: replaces `process-send-string' by an `insert-for-yank' followed by `comint-send-input'. Tabs are removed or else would be interpreted as interactives tabs in the shell buffer. --- lisp/ob-sql.el | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 671097b47..b03a71bae 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -313,10 +313,14 @@ This function is called by `org-babel-execute-src-block'." (setq org-sql-session-command-terminated nil) (with-current-buffer (get-buffer sql--buffer) - (process-send-string (current-buffer) - (org-sql-session-format-query - (org-babel-expand-body:sql body params) - in-engine)) + (progn + (goto-char (point-max)) + (insert-for-yank + (format "%s\n;\n%s" + (org-babel-expand-body:sql + (replace-regexp-in-string "[\t]" "" body) params) + (plist-get org-sql-batch-terminate in-engine))) + (comint-send-input nil t)) (while (or (not org-sql-session-command-terminated) (> (time-to-seconds (time-subtract (current-time) -- 2.39.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0014-ob-sql-update-commentary-reflecting-recent-changes-o.patch >From 49a162ee264ef6f1d8cfa6119c089b9757207ff6 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 14 May 2025 16:03:14 +0200 Subject: [PATCH 14/14] ob-sql: update commentary reflecting recent changes on session * lisp/ob-sql.el: mentions support for session in commentary. SQLite engine support. Current limitations in sessions: only sqlite and postgres are configured yet. Error line number count starts as LINE 1 on each instructions. --- lisp/ob-sql.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index b03a71bae..980e11395 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -36,6 +36,7 @@ ;; ;; Header args used: ;; - engine +;; - session ;; - cmdline ;; - dbhost ;; - dbport @@ -63,11 +64,15 @@ ;; - vertica ;; - saphana ;; -;; TODO: +;; Limitation: +;; - in sessions: +;; - engines configured: sqlite, postgres +;; - no error line number ;; -;; - support for sessions +;; TODO: ;; - support for more engines -;; - what's a reasonable way to drop table data into SQL? +;; - babel tables as input +;; - raw replace result ;; ;;; Code: -- 2.39.5 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Wed May 14 12:10:22 2025 Received: (at 76025) by debbugs.gnu.org; 14 May 2025 16:10:23 +0000 Received: from localhost ([127.0.0.1]:44570 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uFEgY-0001hB-Du for submit@debbugs.gnu.org; Wed, 14 May 2025 12:10:22 -0400 Received: from smtp-8faa.mail.infomaniak.ch ([2001:1600:4:17::8faa]:34251) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uFEgV-0001gs-5C for 76025@debbugs.gnu.org; Wed, 14 May 2025 12:10:19 -0400 Received: from smtp-3-0000.mail.infomaniak.ch (smtp-3-0000.mail.infomaniak.ch [10.4.36.107]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4ZyJGC0Zlkzq8J; Wed, 14 May 2025 18:10:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1747239010; bh=/8alGtMv7cHCl8VbKn67fKXz6XXB2D3qKXUzmadE7WA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=F5k/IdTmr7dXyREM1CIeTtusxZO4lj6Q29g/y+MxzbXOuRkPK3k2cpcML86gAwXfC NTqVM+gt8wO0MygciOZK2KwwN90M0z+uenr44gCPDec+kwDxlfXsxM6W2+MO74IxRf StB320f5k6ADG0YmbEUFthZt2hCPZwKV9wjX/1+IylGb+6HSzL68o3Xhra2vY2IRGS +oq7yKse6lWCG0frp/j79Pi1bXWAV4bBvrSCDDoU50yPVdYiAK2aukZmyLz18lEG8X f49h5KkVFMRiKn7pHw+ocR23Hs7e2zR2dF+w4AnJQZ6Dstsh3BkHfQc6Wea+piBy1v 8s0bwI70226mw== Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4ZyJGB47pvzFnS; Wed, 14 May 2025 18:10:09 +0200 (CEST) From: Phil Estival To: Ihor Radchenko Subject: Re: [PATCH] ob-sql: session + sql.el w/o prompt In-Reply-To: <87sel7mfjl.fsf@7d.nz> (Phil Estival's message of "Wed, 14 May 2025 16:29:34 +0200") References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Wed, 14 May 2025 18:10:09 +0200 Message-ID: <87msbfmavy.fsf@7d.nz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Infomaniak-Routing: alpha X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76025 Cc: Michael Mauger , Org Mode List , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * [2025-05-14 16:29 +0200] Phil Estival : > * [2025-02-15 16:25 +0000] Ihor Radchenko : >> Ihor Radchenko writes: >> >> May you please update your latest patch for ob-sql.el, converting it >> into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes >> to sql.el? > > Here they are > 1) the patch of sql.el > 2) the list of changes in ob-sql.el against release_9.7.30. > The patch that assumes the change in sql.el is n=C2=B013. Erratum : it's already in n=C2=B07, where sql-product-interactive is beeing called with 3 arguments. From debbugs-submit-bounces@debbugs.gnu.org Sat May 17 14:06:29 2025 Received: (at 76025) by debbugs.gnu.org; 17 May 2025 18:06:29 +0000 Received: from localhost ([127.0.0.1]:50812 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uGLvY-0007K8-Ao for submit@debbugs.gnu.org; Sat, 17 May 2025 14:06:29 -0400 Received: from mout02.posteo.de ([185.67.36.66]:46623) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uGLvV-0007JY-6M for 76025@debbugs.gnu.org; Sat, 17 May 2025 14:06:26 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id BD7B4240101 for <76025@debbugs.gnu.org>; Sat, 17 May 2025 20:06:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1747505178; bh=/plXeAnX39dOJNk/7ohvMjaq3drRM1/9LEVUm2rZxbE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding:From; b=or5dUwOW4/8bf4WBgEcQagd+vsabPtLrQzMrbZLxevyygV2IEdxpEh8ufblNiB+h1 kD45XIi6XULX+OKuGxWRewEkJRHluSUQa35Jxmn0XGeqSWRWK1ipQim1V383KCxJE+ 3Hpm/iLb2SWEYx0mod60n39V+ulOh9DG5v1dMjTm8KxR6uqxqrXaVk7hCof/HXPQtc RE15g0adFNdby2PPhmmdr46mAl340sIY+C1W/AA8Q1qQWlvFvd6xnLHmM0m+3nIXq8 kzXByaal3lMtUfxaeEry/FTcqUKXLCtWS75hdl/gUGtM5FBd4aXsFjzySMvqbLaou4 0YzmYLn+ghrCA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4b0Bhn4sv1z9rxB; Sat, 17 May 2025 20:06:17 +0200 (CEST) From: Ihor Radchenko To: Phil Estival Subject: Re: [PATCH] ob-sql: session + sql.el w/o prompt In-Reply-To: <87sel7mfjl.fsf@7d.nz> References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> Date: Sat, 17 May 2025 18:05:11 +0000 Message-ID: <87o6vrkt9k.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: Michael Mauger , Org Mode List , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Phil Estival writes: >> May you please update your latest patch for ob-sql.el, converting it >> into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes >> to sql.el? > > Here they are > 1) the patch of sql.el > 2) the list of changes in ob-sql.el against release_9.7.30. > The patch that assumes the change in sql.el is n=C2=B013. Thanks! I will comment on the Org-related part. > Subject: [PATCH 01/14] ob-sql: session support. Introduces new variables = and > functions > > * lisp/ob-sql.el: new variables and functions for session support for > postgres and sqlite. Requires sql.el for a connection to a session. > SQL clients are configured by a preamble of commands given to the SQL > shell. Custom variables are declared in a new sub-group ob-babel-sql. > The echo of an SQL ANSI comment is to be appended to the source block > of SQL commands for comint to detect when the commands terminate, > instead of relying on prompt detection. This is not a complete changelog of your changes. Please check out https://orgmode.org/worg/org-contribute.html#commit-messages and follow the format. In general, because you plan to be the maintainer, please familiarize yourself with all the conventions discussed in https://orgmode.org/worg/org-contribute.html and https://orgmode.org/worg/org-maintenance.html > ;; Author: Eric Schulte > ;; Maintainer: Daniel Kraus > +;; Maintainer: Philippe Estival > ;; Keywords: literate programming, reproducible research > ;; URL: https://orgmode.org I think adding you as a maintainer should be a separate patch to make the change distinct. =20=20 > (require 'ob) > +(require 'sql) Do we need to load sql.el early? May we do it dynamically instead? > +(defvar org-babel-sql-session-start-time) This variable is unused. What is it for? > +(defvar org-sql-session-preamble > + (list > + 'postgres "\\set ON_ERROR_STOP 1 > +\\pset footer off > +\\pset pager off > +\\pset format unaligned" ) > + "Command preamble to run upon shell start.") Should it be a defcustom? > +(defvar org-sql-session-command-terminated nil) AFAIU, this is some kind of flag to be used inside sql comit buffer. Should it be buffer-local? Also, please add a docstring. > +(defvar org-sql-session--batch-terminate "---#" "To print at the end o= f a command batch.") This is a bit weird formatting. In Elisp, the docstring is usually placed on a separate line. Also, please check out https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Tip= s.html Your docstring here reads confusing. > +(defvar org-sql-batch-terminate > + (list 'sqlite (format ".print %s\n" org-sql-session--batch-terminate) > + 'postgres (format "\\echo %s\n" org-sql-session--batch-terminate= )) > + "Print the command batch termination as last command.") This implies that you treat `org-sql-session--batch-terminate' as a constant. If so, maybe declare it as such. Also, should it be a defcustom? > +(defvar org-sql-terminal-command-prefix > + (list 'sqlite "\\." > + 'postgres "\\\\") > + "Identify a command for the SQL shell.") This variable is unused. > +(defvar org-sql-environment > + (list 'postgres '(("PGPASSWORD" sql-password)))) Also unused. > +(defvar org-sql-session-clean-output nil > + "Store the regexp used to clear output (prompt1|termination|prompt2).") Should it be buffer-local in session buffer? > +(defvar org-sql-session-start-time) > +(defvar org-sql-session-command-terminated nil) Same question. > +(defvar org-sql-session--batch-terminate "---#" "To print at the end o= f a command batch.") Duplicate defvar. =20=20 > +(defcustom org-sql-run-comint-p 'nil There is no need to quote nil and numbers. They are self-quoting. > + "Run non-session SQL commands through comint if not nil." > + :type '(boolean) :type 'boolean > +(defcustom org-sql-timeout '5.0 > + "Abort on timeout." > + :type '(number) :type 'number > +(defcustom org-sql-close-out-temp-buffer-p 'nil > + "To automatically close sql-out-temp buffer." The docstring is not very clear. > + :type '(boolean) :type 'boolean > +(defun org-sql-session-comint-output-filter (_proc string) > + "Process output STRING of PROC gets redirected to a temporary buffer. > +It is called several times consecutively as the shell outputs and flush > +its message buffer" > + > + ;; Inserting a result in the sql process buffer (to read it as a > + ;; regular prompt log) inserts it to the terminal, and as a result the > + ;; ouput would get passed as input onto the next command line; See > + ;; `comint-redirect-setup' to possibly fix that, > + ;; (with-current-buffer (process-buffer proc) (insert output)) > + > + (when (or (string-match org-sql-session--batch-terminate string) > + (> (time-to-seconds > + (time-subtract (current-time) > + org-sql-session-start-time)) > + org-sql-timeout)) > + (setq org-sql-session-command-terminated t)) > + > + (with-current-buffer (get-buffer-create "*ob-sql-result*") > + (insert string))) Using global `org-sql-session-command-terminated', `org-sql-session-start-time', and "*ob-sql-result*" buffer will not be reliable when there are multiple comint sessions. It will also make it impossible to implement async sessions. Please use some other approach (for example, buffer-local or process-local variables) > * lisp/ob-sql.el: removal of org-assert-version makes org-macs no > longer needed. > ... > - > -(require 'org-macs) > -(org-assert-version) > - (org-assert-version) is needed to detect mixed Org versions. (require 'org-macs) there is mostly to provide `org-assert-version'. > Subject: [PATCH 04/14] ob-sql: realign variables for improved readability. We do not allow whitespace-only commits. See https://orgmode.org/worg/org-contribute.html#orgbbd6fd6 > + (when colnames-p (with-temp-buffer nitpick: It is unusual to place (when condition body-line1 ...) The common practice is (when condition body) > + (setq org-sql-session-clean-output > + (plist-put org-sql-session-clean-output in-engine > + (concat "\\(" prompt-regexp "\\)" > + "\\|\\(" org-sql-session--batch-termina= te "\n\\)" > + (when prompt-cont-regexp > + (concat "\\|\\(" prompt-cont-regexp "= \\)")))))) This will be broken when multiple sessions for different engines are used in parallel. Please avoid global state. > + (let ((sql--buffer > + (org-babel-sql-session-connect in-engine params session))) Why `sql--bufer'? (double slash) It is not a variable sql.el uses. > + (with-current-buffer (get-buffer-create "*ob-sql-result*") > + (erase-buffer)) > + (setq org-sql-session-start-time (current-time)) > + (setq org-sql-session-command-terminated nil) > + > + (with-current-buffer (get-buffer sql--buffer) > + (process-send-string (current-buffer) > + (org-sql-session-format-query > + (org-babel-expand-body:sql body p= arams) > + in-engine)) > + (while (or (not org-sql-session-command-terminated) > + (> (time-to-seconds > + (time-subtract (current-time) > + org-sql-session-start-tim= e)) > + org-sql-timeout)) > + (sleep-for 0.03)) > + ;; command finished, remove filter > + (set-process-filter (get-buffer-process sql--buffer) nil) This looks repetitive with the code in `org-sql-session-comint-output-filter'. Could it be possible to avoid code duplication? > + (when (not session-p) > + (comint-quit-subjob) > + ;; despite this quit signal, the process may not be finished yet > + (let ((kill-buffer-query-functions nil)) > + (kill-this-buffer)))) Maybe we should wait until it is finished then? You can check `process-stat= us'. > Subject: [PATCH 11/14] ob-sql: replace call to (intern engine) by the=20 > previously declared in-engine > > TINYCHANGE TINYCHANGE is unnecessary after you get the copyright assignment. (which do you need to get) > + (insert-for-yank Why do you need `insert-for-yank'? --=20 Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Sun May 18 21:36:28 2025 Received: (at 76025) by debbugs.gnu.org; 19 May 2025 01:36:29 +0000 Received: from localhost ([127.0.0.1]:34493 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uGpQZ-0005cY-LC for submit@debbugs.gnu.org; Sun, 18 May 2025 21:36:28 -0400 Received: from mail-24416.protonmail.ch ([109.224.244.16]:27087) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uGpQO-0005bk-Fq for 76025@debbugs.gnu.org; Sun, 18 May 2025 21:36:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1747618569; x=1747877769; bh=UQPLtRMzvNJzBUZi3Rw+79Gm4Nz8fWydWnxJhV/w9uE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=qOvAXDea3qFXEPDhqaiGqnvSgMKWjnii0A70wN0ZG+z9KxyNs9aUio4bRxLZfU5eb c3luk/CCUCDDs0sQqBViZbp53NCojmQ1rEogj+O5B3e72lfTj52U8hsrDpCgCAUsNK YaQuM9gF3rVQSVQFVgpBkVPGfQLqVPfV7n4LFL6JDCFOOaMFLzquu8m5XWZmK/oMzV 87/IfIFRIlzqQrI82yRmDsekLx25ENHPB1Oc4BMv9/3TuE6dxLG5r1xU0sAYCYFmpf qKCd07UtzP5P20jgcgQAPwuCNbBkMLLAed2Cxh4miMQzF/k1XbQXbrNzBpfR3iC+hd 01Bef9EWk9FUw== Date: Mon, 19 May 2025 01:36:05 +0000 To: Ihor Radchenko From: Michael Mauger Subject: Re: [PATCH] ob-sql: session + sql.el w/o prompt Message-ID: In-Reply-To: <87r03zcgzu.fsf@localhost> References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> Feedback-ID: 119932:user:proton X-Pm-Message-ID: 6483df48f271d6dc9872ae466e22171c98bbe936 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -1.0 (-) X-Debbugs-Envelope-To: 76025 Cc: Phil Estival , 76025@debbugs.gnu.org, Org Mode List X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.0 (--) On Saturday, February 15th, 2025 at 4:25 PM, Ihor Radchenko wrote: > Ihor Radchenko yantar92@posteo.net writes: >=20 > > May you please post the patch on Emacs bug tracker? (M-x > > submit-emacs-patch) and X-Debbugs-CC me? > > That way, we get the Emacs maintainers involved into the discussion. >=20 >=20 > The patch is in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D76025 >=20 > There are no major objections to the patch other than the maintainer > being interested to coordinate ob-sql improvements and sql.el > changes. >=20 > I am CCing the feature request thread so that we can discuss everything > together. >=20 > May you please update your latest patch for ob-sql.el, converting it > into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes > to sql.el? >=20 > -- > Ihor Radchenko // yantar92, I'm sorry to be late to this party, but this is the first real description = of what features were needed from sql.el.=20 Based on what I'm seeing, I think the feature you want is already present (= but can be made simpler for you to use). And the support for the empty name= sqlite database is similar to in-memory databases that I have in a local d= evelopment branch that hasn't been merged/pushed. The `sql-connect' machinery suppresses prompts for parameters in the connec= tion alist already. There are two ways to take advantage of that: install c= onnection parameters in `sql-connection-alist' with an ob-sql specific conn= ection name and then `sql-connect' to it, or allow `sql-connect' to be call= ed with a complete connection alist entry in place of the connection name. = I think the latter option is a better choice, and easy to incorporate into = the code; the former option would be a total ob-sql solution. Id be cautiou= s modifying `sql-product-interactive' directly since so much passes thru th= ere and `sql-connect' already implements the logic you want around it. For sqlite, I've added support for an in-memory database using the name ":m= emory:" in my local repo. Obviously an empty name indicates a temporary dat= abase which may be in-memory, or if larger, in temporary disk space. I'll t= ake a look at adding support for temporary databases but I'm not a huge fan= of an empty database name option. Maybe support ":tempdb:" (or similar)? I am looking to cleanup sql.el (some of it's code is 20+ years old) and has= some very broken pieces in it. Changing it to simplify support from treesi= t and eglot exposes rough edges that will break things for existing users. = `sql-connect' is the intended interface for programmatic invocation of SQL-= interactive processes. -- MICHAEL@MAUGER.COM // FSF and SFConservancy // GNU Emacs sql.el maintainer From debbugs-submit-bounces@debbugs.gnu.org Sat May 24 04:42:47 2025 Received: (at 76025) by debbugs.gnu.org; 24 May 2025 08:42:47 +0000 Received: from localhost ([127.0.0.1]:56706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uIkSs-0005fj-CW for submit@debbugs.gnu.org; Sat, 24 May 2025 04:42:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41770) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uIkSo-0005fG-OK for 76025@debbugs.gnu.org; Sat, 24 May 2025 04:42:43 -0400 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 1uIkSi-0006BZ-Tx; Sat, 24 May 2025 04:42:36 -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=PZ2HOeLlrJ7hGZb8k/oL4Lg+I8JLjQHWqZB05+g+1UU=; b=AHPYITuZN8z/ TFxZ1Zvo9facj/wBSc1XI2liYZ2LbGzVC4fveHGJ+Oaeeoi6ibotNnKSlj5RQ2nqGHsXhio9hbd9f HXaH6WWmPk668Cf2ZrV/KnUDvcW1CL4FTsFmY0gFi39wX1CY71PTAVTyzqWsNudpRKKwAGeoLV2G3 +scKOQvhwIWUZdb7B8qSIa7DxDTzD/OxAGX8Ec9qBDUs1if+2zqc40Qs/zgtcdmKZhhfSsz5Db9va KCD1De8nZkq4bREr56i1KU8/Hs1BdnIAHCRYoVbg5wH7zrMG9Tz9ddTLlpCqikT3+KZby9u0n2SMH OftYU/y/9TPs9JjjGYqFjQ==; Date: Sat, 24 May 2025 11:42:34 +0300 Message-Id: <86seku2ydh.fsf@gnu.org> From: Eli Zaretskii To: Phil Estival In-Reply-To: <874iy8ffl5.fsf@7d.nz> (message from Phil Estival on Mon, 28 Apr 2025 17:52:54 +0200) Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> <87ikp7nfok.fsf@7d.nz> <87jz8m9q5b.fsf@localhost> <861puuqd43.fsf@gnu.org> <87h63018ss.fsf@7d.nz> <865xj08dc1.fsf@gnu.org> <874iy8ffl5.fsf@7d.nz> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, yantar92@posteo.net, michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Phil Estival > Cc: yantar92@posteo.net, 76025@debbugs.gnu.org, michael@mauger.com > Date: Mon, 28 Apr 2025 17:52:54 +0200 > > * [2025-04-19 16:56 +0300] Eli Zaretskii : > >> From: Phil Estival > >> Cc: Ihor Radchenko , 76025@debbugs.gnu.org, > >> michael@mauger.com > >> Date: Mon, 07 Apr 2025 13:59:47 +0200 > >> > >> * [2025-03-18 22:48 +0200] Eli Zaretskii : > >> >> From: Ihor Radchenko > >> >> Cc: Eli Zaretskii , 76025@debbugs.gnu.org, michael@mauger.com > >> >> Date: Tue, 18 Mar 2025 17:58:56 +0000 > >> >> > >> >> Phil Estival writes: > >> >> > >> >> >> From my POV, this change needs a NEWS entry, and I think Phil needs to > >> >> >> do the legal paperwork of assigning the copyright to the FSF (I can > >> >> >> send the form and the instructions if that's okay with Phil). > >> >> > > >> >> > I asked assign@gnu.org for a pgp pub key last Wednesday > >> >> > but no response so far. Is there any? > >> >> > >> >> May I know if there is any progress? > >> > > >> > Not that I know of, no. > >> > > >> > I also didn't see any correspondence between Phil and the copyright > >> > clerk, although usually the copyright clerk CC's me on his responses. > >> > > >> > Phil, did you send the form to the FSF? Or are you still waiting for > >> > their PGP key? > >> > >> I'm writing to them again to ask if there is one. > > > > Any progress with this issue? > > The ticketing system does not support encryption but they answered > positively, I received a key and the ball's in my court now. There was > less room in my schedule than I expected, but I'll finally get back to > you these days with the contribution, this time for real. Hi, Any progress with this? From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 07 04:13:05 2025 Received: (at 76025) by debbugs.gnu.org; 7 Jun 2025 08:13:05 +0000 Received: from localhost ([127.0.0.1]:46672 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uNofp-0004AH-15 for submit@debbugs.gnu.org; Sat, 07 Jun 2025 04:13:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49500) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uNofm-00049g-1y for 76025@debbugs.gnu.org; Sat, 07 Jun 2025 04:13:02 -0400 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 1uNofe-0002bd-VG; Sat, 07 Jun 2025 04:12:54 -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=xxwZJABGUkxyRgWZUovmXBOrxA0SL5SHb97eknzfXuI=; b=HSsFethYf9K2 X97HwUfrZ/6ZZHdWDlCvpPO8nVQi4oJ4/WUe4SHgCwGPm7cwHHvfVkhfioqFfA3Ajkdg5Z4sj6lbt sES8C6281r1EgQTY8Hg9yxQ+YEbCF8dcKo23V1btDsjXwogT8vJrqG6g0HuTG7/2Kat8GoWgkUSNW 5B4JcClxh3JXJ6UYs6gxDRbf0Tah6FSc2/KI/kzz3HjGyBZe+MOzvuj+11ccZfJFVGpXbs3xsxZtd ScPa2KnW2EV5AtLEVM3MIPNIIHI5flqySzQ4v2jassFVQDkxhU2qUeT3C8+JvnHkLboEbfLNPcsIv tYCOELuzLYH8Sq2lHbUEwA==; Date: Sat, 07 Jun 2025 11:12:51 +0300 Message-Id: <86msakj7gc.fsf@gnu.org> From: Eli Zaretskii To: pe@7d.nz In-Reply-To: <86seku2ydh.fsf@gnu.org> (message from Eli Zaretskii on Sat, 24 May 2025 11:42:34 +0300) Subject: Re: bug#76025: [PATCH 1/1] * lisp/progmodes/sql.el: login without prompting References: <8734gws3zn.fsf@7d.nz> <87ikpmvqad.fsf@localhost> <86v7tm5iqz.fsf@gnu.org> <87ikp7nfok.fsf@7d.nz> <87jz8m9q5b.fsf@localhost> <861puuqd43.fsf@gnu.org> <87h63018ss.fsf@7d.nz> <865xj08dc1.fsf@gnu.org> <874iy8ffl5.fsf@7d.nz> <86seku2ydh.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, yantar92@posteo.net, michael@mauger.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ping! Phil, any progress with the copyright assignment? > Cc: 76025@debbugs.gnu.org, yantar92@posteo.net, michael@mauger.com > Date: Sat, 24 May 2025 11:42:34 +0300 > From: Eli Zaretskii > > > From: Phil Estival > > Cc: yantar92@posteo.net, 76025@debbugs.gnu.org, michael@mauger.com > > Date: Mon, 28 Apr 2025 17:52:54 +0200 > > > > * [2025-04-19 16:56 +0300] Eli Zaretskii : > > >> From: Phil Estival > > >> Cc: Ihor Radchenko , 76025@debbugs.gnu.org, > > >> michael@mauger.com > > >> Date: Mon, 07 Apr 2025 13:59:47 +0200 > > >> > > >> * [2025-03-18 22:48 +0200] Eli Zaretskii : > > >> >> From: Ihor Radchenko > > >> >> Cc: Eli Zaretskii , 76025@debbugs.gnu.org, michael@mauger.com > > >> >> Date: Tue, 18 Mar 2025 17:58:56 +0000 > > >> >> > > >> >> Phil Estival writes: > > >> >> > > >> >> >> From my POV, this change needs a NEWS entry, and I think Phil needs to > > >> >> >> do the legal paperwork of assigning the copyright to the FSF (I can > > >> >> >> send the form and the instructions if that's okay with Phil). > > >> >> > > > >> >> > I asked assign@gnu.org for a pgp pub key last Wednesday > > >> >> > but no response so far. Is there any? > > >> >> > > >> >> May I know if there is any progress? > > >> > > > >> > Not that I know of, no. > > >> > > > >> > I also didn't see any correspondence between Phil and the copyright > > >> > clerk, although usually the copyright clerk CC's me on his responses. > > >> > > > >> > Phil, did you send the form to the FSF? Or are you still waiting for > > >> > their PGP key? > > >> > > >> I'm writing to them again to ask if there is one. > > > > > > Any progress with this issue? > > > > The ticketing system does not support encryption but they answered > > positively, I received a key and the ball's in my court now. There was > > less room in my schedule than I expected, but I'll finally get back to > > you these days with the contribution, this time for real. > > Hi, > > Any progress with this? > > > > From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 15 11:16:24 2025 Received: (at 76025) by debbugs.gnu.org; 15 Jun 2025 15:16:24 +0000 Received: from localhost ([127.0.0.1]:58538 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uQp5q-0000nB-KL for submit@debbugs.gnu.org; Sun, 15 Jun 2025 11:16:24 -0400 Received: from smtp-42ab.mail.infomaniak.ch ([2001:1600:7:10::42ab]:45799) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uQp5m-0000mi-DF for 76025@debbugs.gnu.org; Sun, 15 Jun 2025 11:16:20 -0400 Received: from smtp-4-0001.mail.infomaniak.ch (unknown [IPv6:2001:1600:7:10::a6c]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4bKxY627QKzBd7; Sun, 15 Jun 2025 17:16:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1750000570; bh=kjw+YAMoLM6E8ZzqjcaJ0Z4Vn/b8Aj68NDB7snhm7e0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=nMf97M6xKIfKwDRSQtflSp9CX4yDVThNOME1uhY+NR7OPF/9qGmjojwxzVpwG9qYR a0otM10nt2tSDYRPCGw4C2CQJNRTTEndqvibvSS44Euvyq5ThmFfRh12A+6dII1Aq4 F+3lycmZdLV+0eB3s1oWQmUwiOU9rAPJmivZZ7hSs2bUWtfgZiYWCUA+0GaifHAsPb afpb1EPa8s8X6XYzn78lhf72xchP4bpI+FbKm9ghI1+kJhx1295rqfb1vrYQNndf2Q 9JACdSQAOfYbvGkiUeoI0wriwzggndwZY8Ay+7AdXPPfv4WDTOGCkaV11Ippc3Rgmy azLKuD72zZc3g== Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4bKxY54lPXzrCP; Sun, 15 Jun 2025 17:16:09 +0200 (CEST) From: Phil Estival To: Ihor Radchenko Subject: Re: [PATCH] ob-sql: session In-Reply-To: <87o6vrkt9k.fsf@localhost> (Ihor Radchenko's message of "Sat, 17 May 2025 18:05:11 +0000") References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> <87o6vrkt9k.fsf@localhost> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Sun, 15 Jun 2025 17:16:08 +0200 Message-ID: <87msa96nnr.fsf@7d.nz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Infomaniak-Routing: alpha X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: Michael Mauger , Org Mode List , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable I'm submitting again the patches for ob-sql.el, taking into considerations the previous review, commented below. I also took good note of Michael remarks. The attached series of patches will work without any modification to sql.el. I'll introduce later a local `sql-connection' bound to the session name. In the absence of it, sessions will work, but will ask to confirm provided connection parameter upon establishing connection. * [2025-05-17 18:05 +0000] Ihor Radchenko : > Phil Estival writes: > >>> May you please update your latest patch for ob-sql.el, converting it >>> into (1) patch to sql.el; (2) patch for ob-sql.el that assumes changes >>> to sql.el? >> >> Here they are >> 1) the patch of sql.el >> 2) the list of changes in ob-sql.el against release_9.7.30. >> The patch that assumes the change in sql.el is n=C2=B013. > > Thanks! I will comment on the Org-related part. > >> Subject: [PATCH 01/14] ob-sql: session support. Introduces new variables= and >> functions >> >> * lisp/ob-sql.el: new variables and functions for session support for >> postgres and sqlite. Requires sql.el for a connection to a session. >> SQL clients are configured by a preamble of commands given to the SQL >> shell. Custom variables are declared in a new sub-group ob-babel-sql. >> The echo of an SQL ANSI comment is to be appended to the source block >> of SQL commands for comint to detect when the commands terminate,l >> instead of relying on prompt detection. > > This is not a complete changelog of your changes. Please check out > https://orgmode.org/worg/org-contribute.html#commit-messages and follow > the format. > > In general, because you plan to be the maintainer, please familiarize > yourself with all the conventions discussed in > https://orgmode.org/worg/org-contribute.html and > https://orgmode.org/worg/org-maintenance.html > >> ;; Author: Eric Schulte >> ;; Maintainer: Daniel Kraus >> +;; Maintainer: Philippe Estival >> ;; Keywords: literate programming, reproducible research >> ;; URL: https://orgmode.org > > I think adding you as a maintainer should be a separate patch to make > the change distinct. Patch follows > >> (require 'ob) >> +(require 'sql) > > Do we need to load sql.el early? May we do it dynamically instead? > I see that calling `org-require-package' when establishing a new connection is more rational. Changed in the following patch. >> +(defvar org-babel-sql-session-start-time) > > This variable is unused. What is it for? > Starting time of one session block execution, used to exit on timeout. Fixed in the following patch. What naming convention to opt for ? org-babel-[lang]-var ? or ob-[lang]-var ? >> +(defvar org-sql-session-preamble >> + (list >> + 'postgres "\\set ON_ERROR_STOP 1 >> +\\pset footer off >> +\\pset pager off >> +\\pset format unaligned" ) >> + "Command preamble to run upon shell start.") > > Should it be a defcustom? > Yes. It is now in the next patch. >> +(defvar org-sql-session-command-terminated nil) > > AFAIU, this is some kind of flag to be used inside sql comit buffer. > Should it be buffer-local? Yes, it is now too. > Also, please add a docstring. > >> +(defvar org-sql-session--batch-terminate "---#" "To print at the end = of a command batch.") > > This is a bit weird formatting. In Elisp, the docstring is usually > placed on a separate line. Also, please check out > https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-T= ips.html > Your docstring here reads confusing. I hope the formatting and style of the others docstrings is now fine. > >> +(defvar org-sql-batch-terminate >> + (list 'sqlite (format ".print %s\n" org-sql-session--batch-terminate) >> + 'postgres (format "\\echo %s\n" org-sql-session--batch-terminat= e)) >> + "Print the command batch termination as last command.") > > This implies that you treat `org-sql-session--batch-terminate' as a > constant. If so, maybe declare it as such. > > Also, should it be a defcustom? > >> +(defvar org-sql-terminal-command-prefix >> + (list 'sqlite "\\." >> + 'postgres "\\\\") >> + "Identify a command for the SQL shell.") > > This variable is unused. > Right, it is no longer in the present mileage. >> +(defvar org-sql-environment >> + (list 'postgres '(("PGPASSWORD" sql-password)))) > > Also unused. > removed. >> +(defvar org-sql-session-clean-output nil >> + "Store the regexp used to clear output (prompt1|termination|prompt2).= ") > > Should it be buffer-local in session buffer? > Yes. >> +(defvar org-sql-session-start-time) >> +(defvar org-sql-session-command-terminated nil) > > Same question. > >> +(defvar org-sql-session--batch-terminate "---#" "To print at the end = of a command batch.") > > Duplicate defvar. > >> +(defcustom org-sql-run-comint-p 'nil > > There is no need to quote nil and numbers. > They are self-quoting. > >> + "Run non-session SQL commands through comint if not nil." >> + :type '(boolean) > > :type 'boolean > >> +(defcustom org-sql-timeout '5.0 >> + "Abort on timeout." >> + :type '(number) > > :type 'number > >> +(defcustom org-sql-close-out-temp-buffer-p 'nil >> + "To automatically close sql-out-temp buffer." > > The docstring is not very clear. > Changed to "When non-nil, close the temporary buffer holding output results= ." >> + :type '(boolean) > > :type 'boolean > >> +(defun org-sql-session-comint-output-filter (_proc string) >> + "Process output STRING of PROC gets redirected to a temporary buffer. >> +It is called several times consecutively as the shell outputs and flush >> +its message buffer" >> + >> + ;; Inserting a result in the sql process buffer (to read it as a >> + ;; regular prompt log) inserts it to the terminal, and as a result the >> + ;; ouput would get passed as input onto the next command line; See >> + ;; `comint-redirect-setup' to possibly fix that, >> + ;; (with-current-buffer (process-buffer proc) (insert output)) >> + >> + (when (or (string-match org-sql-session--batch-terminate string) >> + (> (time-to-seconds >> + (time-subtract (current-time) >> + org-sql-session-start-time)) >> + org-sql-timeout)) >> + (setq org-sql-session-command-terminated t)) >> + >> + (with-current-buffer (get-buffer-create "*ob-sql-result*") >> + (insert string))) > > Using global `org-sql-session-command-terminated', > `org-sql-session-start-time', and "*ob-sql-result*" buffer will not be > reliable when there are multiple comint sessions. It will also make it > impossible to implement async sessions. > Please use some other approach (for example, buffer-local or > process-local variables) > >> * lisp/ob-sql.el: removal of org-assert-version makes org-macs no >> longer needed. >> ... >> - >> -(require 'org-macs) >> -(org-assert-version) >> - > > (org-assert-version) is needed to detect mixed Org versions. > (require 'org-macs) there is mostly to provide `org-assert-version'. > I reintroduced `org-macs to provide `org-require-package in the following patches. But shouldn't `org-assert-version be checked only once when org core loads instead of subsequent modules? >> Subject: [PATCH 04/14] ob-sql: realign variables for improved readabilit= y. > > We do not allow whitespace-only commits. See > https://orgmode.org/worg/org-contribute.html#orgbbd6fd6 > >> + (when colnames-p (with-temp-buffer > > nitpick: It is unusual to place > (when condition body-line1 > ...) > > The common practice is > (when condition > body) > Ok, fixed. >> + (setq org-sql-session-clean-output >> + (plist-put org-sql-session-clean-output in-engine >> + (concat "\\(" prompt-regexp "\\)" >> + "\\|\\(" org-sql-session--batch-termin= ate "\n\\)" >> + (when prompt-cont-regexp >> + (concat "\\|\\(" prompt-cont-regexp = "\\)")))))) > > This will be broken when multiple sessions for different engines are > used in parallel. Please avoid global state. > Set as local now. >> + (let ((sql--buffer >> + (org-babel-sql-session-connect in-engine params session))) > > Why `sql--bufer'? (double slash) It is not a variable sql.el uses. > Replaced by `ob-sql-buffer'. IIUC, a double dash indicates a variable used by the prefixed package? >> + (with-current-buffer (get-buffer-create "*ob-sql-result*") >> + (erase-buffer)) >> + (setq org-sql-session-start-time (current-time)) >> + (setq org-sql-session-command-terminated nil) >> + >> + (with-current-buffer (get-buffer sql--buffer) >> + (process-send-string (current-buffer) >> + (org-sql-session-format-query >> + (org-babel-expand-body:sql body = params) >> + in-engine)) >> + (while (or (not org-sql-session-command-terminated) >> + (> (time-to-seconds >> + (time-subtract (current-time) >> + org-sql-session-start-ti= me)) >> + org-sql-timeout)) >> + (sleep-for 0.03)) >> + ;; command finished, remove filter >> + (set-process-filter (get-buffer-process sql--buffer) nil) > > This looks repetitive with the code in > `org-sql-session-comint-output-filter'. Could it be possible to avoid > code duplication? > True, the evaluation of the timeout was dup. >> + (when (not session-p) >> + (comint-quit-subjob) >> + ;; despite this quit signal, the process may not be finished yet >> + (let ((kill-buffer-query-functions nil)) >> + (kill-this-buffer)))) > > Maybe we should wait until it is finished then? You can check > `process-status'. To be fixed next time >> + (insert-for-yank > > Why do you need `insert-for-yank'? No need. It's rather insert instead. Cheers, -- Phil --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-ob-sql-maintainer.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 01/08] ob-sql: add session support lisp/ob-sql.el: add session support to ob-sql * ob-sql.el: declare the maintainer of the following changes --- diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 14ca6bc48..caee4502a 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -4,5 +4,6 @@ ;; Author: Eric Schulte ;; Maintainer: Daniel Kraus +;; Maintainer: Philippe Estival ;; Keywords: literate programming, reproducible research ;; URL: https://orgmode.org --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-ob-sql-vars-local.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 02/08] ob-sql: add session support lisp/ob-sql.el: variables for session support to ob-sql * ob-sql.el: declare variables and local variables for termination of a command batch, starting time of command execution for timeout, regexp to clear returned output --- diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 14ca6bc48..caee4502a 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -76,6 +77,23 @@ (require 'ob) +(defvar org-sql-session--batch-terminate "---#" + "String echoed by the SQL at the end of a command batch.") + +(defvar org-sql-batch-terminate + (list 'sqlite (format ".print %s\n" org-sql-session--batch-terminate) + 'postgres (format "\\echo %s\n" org-sql-session--batch-terminate)) + "Print the command batch termination as last command.") + +(defvar-local org-sql-session-command-terminated nil + "Non-nil when a command batch has completed.") + +(defvar-local org-sql-session-start-time nil + "Starting time of a session code block execution, used to exit on timeout.") + +(defvar-local org-sql-session-clean-output nil + "Store the regexp used to clear output (prompt1|termination|prompt2).") + (declare-function org-table-import "org-table" (file arg)) (declare-function orgtbl-to-csv "org-table" (table params)) (declare-function org-table-to-lisp "org-table" (&optional txt)) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0003-ob-sql-custom-vars.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 03/08] ob-sql: add session support lisp/ob-sql.el: custom variables for session support to ob-sql * ob-sql.el: declare custom variables default header argument per SQL engine, if non-session commands should also be run through comint, timeout duration of commands in seconds, if the temporary buffers of results are closed automatically --- diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 14ca6bc48..caee4502a 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -83,7 +99,49 @@ (declare-function sql-set-product "sql" (product)) (defvar sql-connection-alist) -(defvar org-babel-default-header-args:sql '()) + +(defcustom org-babel-default-header-args:sql '((:engine . "unset")) + "Default header args." + :type '(alist :key-type symbol :value-type string + :options ("dbi" "sqlite" "mysql" "postgres" + "sqsh" "mssql" "vertica" "oracle" "saphana" )) + :group 'org-babel-sql + :safe t) + +(defcustom org-sql-session-preamble + (list + 'postgres " +\\set ON_ERROR_STOP 1 +\\pset footer off +\\pset pager off +\\pset format unaligned" + 'sqlite " +.header off") + "Command preamble to run upon shell start." + + :type '(plist :key-type symbol :value-type string + :options ('postgres 'sqlite 'dbi 'mysql + 'sqsh 'mssql 'vertica 'oracle 'saphana )) + :group 'org-babel-sql + :safe t) + +(defcustom org-sql-run-comint-p nil + "Run non-session SQL commands through comint if not nil." + :type 'boolean + :group 'org-babel-sql + :safe t) + +(defcustom org-sql-timeout 5.0 + "Abort on timeout." + :type 'number + :group 'org-babel-sql + :safe t) + +(defcustom org-sql-close-out-temp-buffer-p nil + "When non-nil, close the temporary buffer holding output results." + :type 'boolean + :group 'org-babel-sql + :safe t) (defconst org-babel-header-args:sql '((engine . :any) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0004-ob-sql-fix-prologue-epilogue.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 04/08] ob-sql: clear nil values from prologue and epilogue --- diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el index 14ca6bc48..caee4502a 100644 --- a/lisp/ob-sql.el +++ b/lisp/ob-sql.el @@ -101,11 +159,11 @@ (let ((prologue (cdr (assq :prologue params))) (epilogue (cdr (assq :epilogue params)))) (mapconcat 'identity - (list + (delq nil (list prologue (org-babel-sql-expand-vars body (org-babel--get-vars params)) - epilogue) + epilogue)) "\n"))) (defun org-babel-edit-prep:sql (info) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0005-ob-sql-factorize-shell-quoting.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 05/08] ob-sql: add session support lisp/ob-sql.el: factorize shell quoting of connection parameters to SQL clients @@ -117,11 +175,10 @@ corresponding :engine source block header argument." (defun org-babel-sql-dbstring-mysql (host port user password database) "Make MySQL cmd line args for database connection. Pass nil to omit that arg." - (mapconcat - #'identity + (combine-and-quote-strings (delq nil - (list (when host (concat "-h" (shell-quote-argument host))) + (list (when host (concat "-h" host)) (when port (format "-P%d" port)) - (when user (concat "-u" (shell-quote-argument user))) - (when password (concat "-p" (shell-quote-argument password))) - (when database (concat "-D" (shell-quote-argument database))))) " ")) + (when user (concat "-u" user)) + (when password (concat "-p" password)) + (when database (concat "-D" database)))))) (defun org-babel-sql-dbstring-postgresql (host port user database) "Make PostgreSQL command line args for database connection. Pass nil to omit that arg." - (mapconcat - #'identity + (combine-and-quote-strings (delq nil - (list (when host (concat "-h" (shell-quote-argument host))) + (list (when host (concat "-h" host)) (when port (format "-p%d" port)) - (when user (concat "-U" (shell-quote-argument user))) - (when database (concat "-d" (shell-quote-argument database))))) " ")) + (when user (concat "-U" user)) + (when database (concat "-d" database)))))) (defun org-babel-sql-dbstring-oracle (host port user password database) "Make Oracle command line arguments for database connection. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0006-ob-sql-connect-and-comint-filter.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 06/08] ob-sql: add session support lisp/ob-sql.el: preparation of session support to ob-sql * ob-sql.el: add `org-babel-sql-session-connect' and `org-sql-session-comint-output-filter' @@ -418,6 +508,79 @@ argument mechanism." -(defun org-babel-prep-session:sql (_session _params) - "Raise an error because Sql sessions aren't implemented." - (error "SQL sessions not yet implemented")) +(defun org-babel-sql-session-connect (in-engine params session) + "Start the SQL client of IN-ENGINE if it has not. +PARAMS provides the sql connection parameters for a new or +existing SESSION. Clear the intermediate buffer from previous +output, and set the process filter. Return the comint process +buffer." + (let* ((buffer-name (format "%s" (if (string= session "none") "" + (format "[%s]" session)))) + (ob-sql-buffer (format "*SQL: %s*" buffer-name))) + (org-require-package 'sql) + ;; initiate a new connection + (when (not (org-babel-comint-buffer-livep ob-sql-buffer)) + ;; store the regexp used to clear output (prompt1|indicator|prompt2) + (let ((prompt-regexp (sql-get-product-feature in-engine :prompt-regexp )) + (prompt-cont-regexp (sql-get-product-feature in-engine :prompt-cont-regexp))) + (setq-local org-sql-session-clean-output + (plist-put org-sql-session-clean-output in-engine + (concat "\\(" prompt-regexp "\\)" + "\\|\\(" org-sql-session--batch-terminate "\n\\)" + (when prompt-cont-regexp + (concat "\\|\\(" prompt-cont-regexp "\\)")))))) + + (let ((sql-server (cdr (assoc :dbhost params))) + (port (cdr (assoc :port params))) + (sql-database (cdr (assoc :database params))) + (sql-user (cdr (assoc :dbuser params))) + (sql-password (cdr (assoc :dbpassword params)))) + (when port (setq-local sql-port port)) + (save-window-excursion + ;; provides environment expressions to the comint service + (let ((process-environment (copy-sequence process-environment)) + (variables (sql-get-product-feature in-engine :sql-environment))) + (mapc (lambda (elem) ; evaluate environment expressions + (setenv (car elem) (eval (cadr elem)))) + variables) + (sql-product-interactive in-engine buffer-name t))) + + (let ((sql-term-proc (get-buffer-process ob-sql-buffer))) + (unless sql-term-proc + (user-error (format "SQL %s didn't start" in-engine))) + + (with-current-buffer (get-buffer ob-sql-buffer) + ;; preamble commands + (let ((preamble (plist-get org-sql-session-preamble in-engine))) + (when preamble + (process-send-string ob-sql-buffer preamble) + (comint-send-input)))) + ;; let the preamble execution finish and be filtered + (sleep-for 0.1)))) + + ;; set the redirection filter and return the SQL client buffer + (set-process-filter (get-buffer-process ob-sql-buffer) + #'org-sql-session-comint-output-filter) + (get-buffer ob-sql-buffer))) + +(defun org-sql-session-comint-output-filter (_proc string) + "Process output STRING of PROC gets redirected to a temporary buffer. +It is called several times consecutively as the shell outputs and flush +its message buffer" + + ;; Inserting a result in the sql process buffer (to read it as a + ;; regular prompt log) inserts it to the terminal, and as a result the + ;; ouput would get passed as input onto the next command line; See + ;; `comint-redirect-setup' to possibly fix that, + ;; (with-current-buffer (process-buffer proc) (insert output)) + + (when (or (string-match org-sql-session--batch-terminate string) + (> (time-to-seconds + (time-subtract (current-time) + org-sql-session-start-time)) + org-sql-timeout)) + (setq-local org-sql-session-command-terminated t)) + + (with-current-buffer (get-buffer-create "*ob-sql-result*") + (insert string))) + (provide 'ob-sql) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0007-ob-sql-session-exec.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 07/08] ob-sql: add session support lisp/ob-sql.el: add execution of session support to ob-sql * ob-sql.el: connect to an SQL shell and execute command block. Replaces calls to (intern engine) by variable `in-engine', Replace a unique cond by a when Close temporary buffer when org-sql-close-out-temp-buffer-p is non-nil. @@ -245,28 +293,71 @@ database connections." (cdr (assoc-string dbconnection sql-connection-alist t)))))))) (defun org-babel-execute:sql (body params) - "Execute a block of Sql code with Babel. + "Execute SQL BODY with PARAMS. This function is called by `org-babel-execute-src-block'." (let* ((result-params (cdr (assq :result-params params))) (cmdline (cdr (assq :cmdline params))) - (dbhost (org-babel-find-db-connection-param params :dbhost)) - (dbport (org-babel-find-db-connection-param params :dbport)) - (dbuser (org-babel-find-db-connection-param params :dbuser)) + (dbhost (org-babel-find-db-connection-param params :dbhost)) + (dbport (org-babel-find-db-connection-param params :dbport)) + (dbuser (org-babel-find-db-connection-param params :dbuser)) (dbpassword (org-babel-find-db-connection-param params :dbpassword)) (dbinstance (org-babel-find-db-connection-param params :dbinstance)) - (database (org-babel-find-db-connection-param params :database)) + (database (org-babel-find-db-connection-param params :database)) (engine (cdr (assq :engine params))) + (in-engine (intern (or engine (user-error "Missing :engine")))) (colnames-p (not (equal "no" (cdr (assq :colnames params))))) (in-file (org-babel-temp-file "sql-in-")) (out-file (or (cdr (assq :out-file params)) (org-babel-temp-file "sql-out-"))) (header-delim "") - (command (cl-case (intern engine) + (session (cdr (assoc :session params))) + (session-p (not (string= session "none")))) + + (if (or session-p org-sql-run-comint-p) ; run through comint + (let* ((ob-sql-buffer (org-babel-sql-session-connect in-engine params session)) + (proc (get-buffer-process ob-sql-buffer))) + (setq-local org-sql-session-start-time (current-time)) + (setq-local org-sql-session-command-terminated nil) + (with-current-buffer (get-buffer ob-sql-buffer) + (progn + (goto-char (point-max)) + (insert + (format "%s\n;\n%s" + (org-babel-expand-body:sql + (replace-regexp-in-string "[\t]" "" body) params) + (plist-get org-sql-batch-terminate in-engine))) + (comint-send-input nil t)) + (while (not org-sql-session-command-terminated) + (sleep-for 0.03)) + ;; command finished, remove filter + (set-process-filter proc nil) + + (when (not session-p) + (comint-quit-subjob) + (while (not (eq 'exit (process-status proc))) + (sleep-for 0.1)) + ;; despite this quit signal, the process may not be finished yet + (let ((kill-buffer-query-functions nil)) + (kill-this-buffer)))) + + (with-current-buffer (get-buffer-create "*ob-sql-result*") + (goto-char (point-min)) + ;; clear the output or prompt and termination + (let ((clean-output (plist-get org-sql-session-clean-output in-engine))) + (while (re-search-forward clean-output nil t) + (replace-match ""))) + (write-file out-file))) + + (let ( ; else run one command line + (command (cl-case in-engine (dbi (format "dbish --batch %s < %s | sed '%s' > %s" (or cmdline "") (org-babel-process-file-name in-file) "/^+/d;s/^|//;s/(NULL)/ /g;$d" (org-babel-process-file-name out-file))) + (sqlite (format "sqlite3 < %s > %s" + (org-babel-process-file-name in-file) + (org-babel-process-file-name out-file))) (monetdb (format "mclient -f tab %s < %s > %s" (or cmdline "") (org-babel-process-file-name in-file) @@ -332,7 +421,7 @@ footer=off -F \"\t\" %s -f %s -o %s %s" (t (user-error "No support for the %s SQL engine" engine))))) (with-temp-file in-file (insert - (pcase (intern engine) + (pcase in-engine (`dbi "/format partbox\n") (`oracle "SET PAGESIZE 50000 SET NEWPAGE 0 @@ -356,23 +445,22 @@ SET COLSEP '|' (org-babel-expand-body:sql body params) ;; "sqsh" requires "go" inserted at EOF. (if (string= engine "sqsh") "\ngo" ""))) - (org-babel-eval command "") + (org-babel-eval command ""))) (org-babel-result-cond result-params (with-temp-buffer (progn (insert-file-contents-literally out-file) (buffer-string))) (with-temp-buffer (cond - ((memq (intern engine) '(dbi mysql postgresql postgres saphana sqsh vertica)) + ((memq in-engine '(dbi mysql postgresql postgres saphana sqsh vertica)) ;; Add header row delimiter after column-names header in first line - (cond - (colnames-p - (with-temp-buffer + (when colnames-p + (with-temp-buffer (insert-file-contents out-file) (goto-char (point-min)) (forward-line 1) (insert "-\n") (setq header-delim "-") - (write-file out-file))))) + (write-file out-file)))) (t ;; Need to figure out the delimiter for the header row (with-temp-buffer @@ -388,6 +476,8 @@ SET COLSEP '|' (forward-char -1)) (write-file out-file)))) (org-table-import out-file (if (string= engine "sqsh") '(4) '(16))) + (when org-sql-close-out-temp-buffer-p + (kill-buffer (get-file-buffer out-file))) (org-babel-reassemble-table (mapcar (lambda (x) (if (string= (car x) header-delim) --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0008-ob-sql-session-commentary.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 08/08] ob-sql: add session support lisp/ob-sql.el: Commentary of session support to ob-sql @@ -36,6 +37,7 @@ ;; Header args used: ;; - engine ;; - cmdline +;; - sessions ;; - dbhost ;; - dbport ;; - dbuser @@ -58,13 +60,20 @@ ;; - mssql ;; - sqsh ;; - postgresql (postgres) +;; - sqlite ;; - oracle ;; - vertica ;; - saphana ;; +;; Limitation: +;; - sessions: +;; - engines configured: sqlite, postgres +;; - no error line number (stays as LINE 1) +;; - default port number only +;; ;; TODO: ;; -;; - support for sessions ;; - support for more engines -;; - what's a reasonable way to drop table data into SQL? -;; +;; - babel tables as input +;; - raw replace result +;; - port number configuration for sessions ;;; Code: --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 15 16:59:28 2025 Received: (at 76025) by debbugs.gnu.org; 15 Jun 2025 20:59:28 +0000 Received: from localhost ([127.0.0.1]:33697 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uQuRr-0005HD-Mq for submit@debbugs.gnu.org; Sun, 15 Jun 2025 16:59:28 -0400 Received: from mail-4322.protonmail.ch ([185.70.43.22]:49271) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uQuRo-0005Gf-Nb for 76025@debbugs.gnu.org; Sun, 15 Jun 2025 16:59:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1750021158; x=1750280358; bh=L4KM0jIz2yLLfek1zsbdp7n9nPHrB21GsfgFetaRaVM=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=NAxDSQEKevnHdXMFsjyPNESgtvIRxlGX2sdCEEwq32Drwn4Qo8xKDHs93zxfxT+Ei V6T/VuFDg+smpAVMp6pNgY0Asjev5aYn0SdnppOsnp7Dn5jt/Gg6CT+6jz6rhzpkxn kr4iXUdPPQhfy7WJa858JhFc9jMp1bwJ+mpxN9XHmmle9M/mv9XWZmzQJrrc5Hn3EC XRg3wJXuj8zmnFJTI2BOyOisnCVvi4LLCahDjUbYQwss37IOl0aQwNh5GIKsT2VVll MAmE3FqbAs+PGga7pYgcCj6DkKAqv7+GFBtk0vo/PRVUimTJQiC7h8y4ZWtX7WnVOS lwwy3Y0fHmeWQ== Date: Sun, 15 Jun 2025 20:59:13 +0000 To: Phil Estival From: Michael Mauger Subject: Re: [PATCH] ob-sql: session Message-ID: <_gsZy6NOWi-oN3cJaPi6l9UR-CcN8nIte15ukOu5KDm8QO_VAY9Laal2E6Y17ItZbInHV-dgEFR1heE4QBLvZZKr4udN1b3HZR5dxF9D30E=@protonmail.com> In-Reply-To: <87msa96nnr.fsf@7d.nz> References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> <87o6vrkt9k.fsf@localhost> <87msa96nnr.fsf@7d.nz> Feedback-ID: 119932:user:proton X-Pm-Message-ID: 3bf73d4b6458f90db02eb0f7a5d455fe7d54c392 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, Ihor Radchenko , Org Mode List X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Sunday, June 15th, 2025 at 3:16 PM, Phil Estival wrote: > I also took good note of Michael remarks.=20 > The attached series of patches will work > without any modification to sql.el. I'll introduce later a local > `sql-connection' bound to the session name. In the absence of it, > sessions will work, but will ask to confirm provided connection > parameter upon establishing connection. >=20 Wouldn't the SQLi buffer created by sql-connect be the session? At least in= sql.el, when it uses either sql-connect or sql-product-interactive, all th= e buffers are scanned to for the desired connection settings and switch to = the matching buffer rather than creating a new buffer.=20 I am trying to cleanup sql.el 2.x before I do a more significant rewrite fo= r sql.el 3.0. The update will include sql-add-connection which cleanly add= s an entry to sql-connection-alist and the ability to call sql-connect with= with the connection settings themselves rather than the connection name. = Hopefully those will simplify the integrations that you need.=20 And please let me know if you are not getting the behavior you want, or if = you are working around something that I ought to look at.... --=20 MICHAEL@MAUGER.COM // FSF and SFConservancy // GNU Emacs sql.el maintainer From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 16 08:19:33 2025 Received: (at 76025) by debbugs.gnu.org; 16 Jun 2025 12:19:33 +0000 Received: from localhost ([127.0.0.1]:43985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uR8oG-00019R-Ez for submit@debbugs.gnu.org; Mon, 16 Jun 2025 08:19:33 -0400 Received: from smtp-42ae.mail.infomaniak.ch ([84.16.66.174]:33847) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uR8oA-00018E-Ce for 76025@debbugs.gnu.org; Mon, 16 Jun 2025 08:19:29 -0400 Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4bLTZb6PzQzdV; Mon, 16 Jun 2025 14:19:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1750076359; bh=+2J8u4vJpQwbRVuo4RqSykiamJzH3z5TWQQSh/Xyl/4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=U9A31Hnjxdo2HlhlMgnyazbdERV5PDmS0jPNvC4+BzBVYV4mFPFuPqvrYA5WvNZ73 9q5nKq+sQBcb3OFgKXuf+bC+skZeIDKtWlGrSX5FlAv4KksQoXvgCMexwUVDubEwPK 3yPu9ZqHXJhlz+E+flaQVXZt5gO8rpyEjA6SD3rcjX7fCC/Zauii4UB8kyfyB7oLQp hk/nZBJe+QOjRhhWUlaSEhtWWUTSEKltFi2FuaM387nNVAZtSlVv1MUng3RbtTDbl8 t8noMthitsqigWjIOs8c8LjXCtOpEaYBk/Bz9jovHhTyF9YcJBbynxOZod/cGQEs9K l7g1jG49oKvsQ== Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4bLTZb2N5gzNbX; Mon, 16 Jun 2025 14:19:19 +0200 (CEST) From: Phil Estival To: Michael Mauger Subject: Re: [PATCH] ob-sql: session In-Reply-To: <_gsZy6NOWi-oN3cJaPi6l9UR-CcN8nIte15ukOu5KDm8QO_VAY9Laal2E6Y17ItZbInHV-dgEFR1heE4QBLvZZKr4udN1b3HZR5dxF9D30E=@protonmail.com> (Michael Mauger's message of "Sun, 15 Jun 2025 20:59:13 +0000") References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> <87o6vrkt9k.fsf@localhost> <87msa96nnr.fsf@7d.nz> <_gsZy6NOWi-oN3cJaPi6l9UR-CcN8nIte15ukOu5KDm8QO_VAY9Laal2E6Y17ItZbInHV-dgEFR1heE4QBLvZZKr4udN1b3HZR5dxF9D30E=@protonmail.com> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Mon, 16 Jun 2025 14:19:18 +0200 Message-ID: <875xgv7ubd.fsf@7d.nz> MIME-Version: 1.0 Content-Type: text/plain X-Infomaniak-Routing: alpha X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, Ihor Radchenko , Org Mode List X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) * [2025-06-15 20:59 +0000] Michael Mauger : > On Sunday, June 15th, 2025 at 3:16 PM, Phil Estival wrote: > >> I also took good note of Michael's remarks. >> The attached series of patches will work >> without any modification to sql.el. I'll introduce later a local >> `sql-connection' bound to the session name. In the absence of it, >> sessions will work, but will ask to confirm provided connection >> parameter upon establishing connection. >> > > Wouldn't the SQLi buffer created by sql-connect be the session? Yes, right. The session is an identifier name, the buffer's name is build on that name but the connection's name can be shared among sessions. > At least in sql.el, when it uses either sql-connect or > sql-product-interactive, all the buffers are scanned to for the > desired connection settings and switch to the matching buffer rather > than creating a new buffer. Aren't they opened in parallel, one connection each, with the same connection parameters ? `org-babel-sql-session-connect' uses `sql-product-interactive' with a buffer name as argument. Different sessions are run in different sql interactive buffers, yet they have the same connection settings. > I am trying to cleanup sql.el 2.x before I do a more significant > rewrite for sql.el 3.0. The update will include sql-add-connection > which cleanly adds an entry to sql-connection-alist and the ability to > call sql-connect with with the connection settings themselves rather > than the connection name. Hopefully those will simplify the > integrations that you need. Fine. > And please let me know if you are not getting the behavior you want, > or if you are working around something that I ought to look at.... * [2025-05-19 01:36 +0000] Michael Mauger : > For sqlite, I've added support for an in-memory database using the > name ":memory:" in my local repo. Obviously an empty name indicates a > temporary database which may be in-memory, or if larger, in temporary > disk space. I'll take a look at adding support for temporary databases > but I'm not a huge fan of an empty database name option. Maybe support > ":tempdb:" (or similar)? The message sqlite3 displays on the welcoming message is: "Connected to a transient in-memory database.", so perhaps the proper word is ":in-memory:" ? While the empty string as database name should IMHO be avoided, the nil parameter must still be allowed: "If no database name is supplied, the ATTACH sql command can be used to attach to existing or create new database files. ATTACH can also be used to attach to multiple databases within the same interactive session. This is useful for migrating data between databases, possibly changing the schema along the way." Cheers, -- Phil Estival From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 16 08:26:31 2025 Received: (at 76025) by debbugs.gnu.org; 16 Jun 2025 12:26:31 +0000 Received: from localhost ([127.0.0.1]:44061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uR8v0-0002KC-1b for submit@debbugs.gnu.org; Mon, 16 Jun 2025 08:26:31 -0400 Received: from smtp-42ab.mail.infomaniak.ch ([2001:1600:7:10::42ab]:53777) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uR8ut-0002I4-Mf for 76025@debbugs.gnu.org; Mon, 16 Jun 2025 08:26:27 -0400 Received: from smtp-4-0001.mail.infomaniak.ch (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4bLTkZ6w0wztWc; Mon, 16 Jun 2025 14:26:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=7d.nz; s=20240212; t=1750076774; bh=miZUXUGFVy/sSBp/EPoAjJ/LMIKQkoQvFY6rV0VTTsU=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=qUOho2GFVUElawha/zQ0GJtXSmv3cuF5WKTj7J17O7Y3Ai5WdkNM+9QDTbPsrRDIM /65aAetDl58GTCXpcHMclz2knZZA+J6Z979uAxD62x2zZhErLcky8p6o58g9iB0y77 mKZ1xR8ff9JiX/8sbLyOOgIyN6jjmivlK5VVMQghHleZXZzbbnDlF/tH5G0xMdW/Mc gSulHDj8Otl0ogVvLsvzDUItIozKwZwDNDi/vHHI2VQlp/Hhx7csbQtR+bY1esCBN/ bhd+clDlpOn6pWrYkb5Lws/DDgV6DEPKkxvOyfeUO9J5vf1yP4hfPdZwt8buq3wKu6 xfFy56LPb1IFw== Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4bLTkZ2q0Tzb9p; Mon, 16 Jun 2025 14:26:14 +0200 (CEST) From: Phil Estival To: Ihor Radchenko Subject: Re: [PATCH] ob-sql: session + sql.el w/o prompt In-Reply-To: <87o6vrkt9k.fsf@localhost> (Ihor Radchenko's message of "Sat, 17 May 2025 18:05:11 +0000") References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> <87o6vrkt9k.fsf@localhost> User-Agent: mu4e 1.12.8; emacs 30.1 Date: Mon, 16 Jun 2025 14:26:13 +0200 Message-ID: <87wm9b6ffe.fsf@7d.nz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Infomaniak-Routing: alpha X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: Michael Mauger , Org Mode List , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain This replaces the previous patch. The `sql-product-interactive' call was still using the modified signature and does no longer. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0006-ob-sql-connect-and-comint-filter.patch >From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 From: Phil Estival Date: Wed, 13 June 2025 17:00:00 +0200 Subject: [PATCH 06/08] ob-sql: add session support lisp/ob-sql.el: preparation of session support to ob-sql * ob-sql.el: add `org-babel-sql-session-connect' and `org-sql-session-comint-output-filter' @@ -418,4 +508,77 @@ argument mechanism." -(defun org-babel-prep-session:sql (_session _params) - "Raise an error because Sql sessions aren't implemented." - (error "SQL sessions not yet implemented")) +(defun org-babel-sql-session-connect (in-engine params session) + "Start the SQL client of IN-ENGINE if it has not. +PARAMS provides the sql connection parameters for a new or +existing SESSION. Clear the intermediate buffer from previous +output, and set the process filter. Return the comint process +buffer." + (let* ((buffer-name (format "%s" (if (string= session "none") "" + (format "[%s]" session)))) + (ob-sql-buffer (format "*SQL: %s*" buffer-name))) + (org-require-package 'sql) + ;; initiate a new connection + (when (not (org-babel-comint-buffer-livep ob-sql-buffer)) + ;; store the regexp used to clear output (prompt1|indicator|prompt2) + (let ((prompt-regexp (sql-get-product-feature in-engine :prompt-regexp )) + (prompt-cont-regexp (sql-get-product-feature in-engine :prompt-cont-regexp))) + (setq-local org-sql-session-clean-output + (plist-put org-sql-session-clean-output in-engine + (concat "\\(" prompt-regexp "\\)" + "\\|\\(" org-sql-session--batch-terminate "\n\\)" + (when prompt-cont-regexp + (concat "\\|\\(" prompt-cont-regexp "\\)")))))) + + (let ((sql-server (cdr (assoc :dbhost params))) + (port (cdr (assoc :port params))) + (sql-database (cdr (assoc :database params))) + (sql-user (cdr (assoc :dbuser params))) + (sql-password (cdr (assoc :dbpassword params)))) + (when port (setq-local sql-port port)) + (save-window-excursion + ;; provides environment expressions to the comint service + (let ((process-environment (copy-sequence process-environment)) + (variables (sql-get-product-feature in-engine :sql-environment))) + (mapc (lambda (elem) ; evaluate environment expressions + (setenv (car elem) (eval (cadr elem)))) + variables) + (sql-product-interactive in-engine buffer-name))) + + (let ((sql-term-proc (get-buffer-process ob-sql-buffer))) + (unless sql-term-proc + (user-error (format "SQL %s didn't start" in-engine))) + + (with-current-buffer (get-buffer ob-sql-buffer) + ;; preamble commands + (let ((preamble (plist-get org-sql-session-preamble in-engine))) + (when preamble + (process-send-string ob-sql-buffer preamble) + (comint-send-input)))) + ;; let the preamble execution finish and be filtered + (sleep-for 0.1)))) + + ;; set the redirection filter and return the SQL client buffer + (set-process-filter (get-buffer-process ob-sql-buffer) + #'org-sql-session-comint-output-filter) + (get-buffer ob-sql-buffer))) + +(defun org-sql-session-comint-output-filter (_proc string) + "Process output STRING of PROC gets redirected to a temporary buffer. +It is called several times consecutively as the shell outputs and flush +its message buffer" + + ;; Inserting a result in the sql process buffer (to read it as a + ;; regular prompt log) inserts it to the terminal, and as a result the + ;; ouput would get passed as input onto the next command line; See + ;; `comint-redirect-setup' to possibly fix that, + ;; (with-current-buffer (process-buffer proc) (insert output)) + + (when (or (string-match org-sql-session--batch-terminate string) + (> (time-to-seconds + (time-subtract (current-time) + org-sql-session-start-time)) + org-sql-timeout)) + (setq-local org-sql-session-command-terminated t)) + + (with-current-buffer (get-buffer-create "*ob-sql-result*") + (insert string))) + (provide 'ob-sql) --=-=-= Content-Type: text/plain -- Phil Estival --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 17 21:21:02 2025 Received: (at 76025) by debbugs.gnu.org; 18 Jun 2025 01:21:02 +0000 Received: from localhost ([127.0.0.1]:39517 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uRhU4-0000Sd-7V for submit@debbugs.gnu.org; Tue, 17 Jun 2025 21:21:01 -0400 Received: from mail-24417.protonmail.ch ([109.224.244.17]:32931) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uRhOa-0008Dm-UF for 76025@debbugs.gnu.org; Tue, 17 Jun 2025 21:15:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1750209314; x=1750468514; bh=LHg+N7oUWKQlizCm0/YYV+jBxzFclVIDBU8PpP8vbnw=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=mASMKDYZG+bzAzB9xUHmTmpLgOVtBA797enOjPeiiX1PQTTtaDy9A7snQWelqYVao zKkAe1/nwUjlbSaJMZ0jurJeznZtvK9f8/s98S7yhCzaauYBlmvL4u6JVKMm3cS12E yzzCxQiM1LkFQp4ish9aQj1sl7hoKQ/oCnE1RAeXNXSbiyruglBxA527VrPgvOHTs6 /bDqA0O08Xc7qcMhmhUYoqDX8bcUChMew1piz8AGYkJg5/vADVZw/iD8Gnzn6DXVzR 2/VOLDWbpXWvGFS2zSwB6wdlCfKTNvfHoh4f/3PZjtxuF8GJ4WXdTSHKL55NVGHGFW klcMGMJohaSpg== Date: Wed, 18 Jun 2025 01:15:11 +0000 To: Phil Estival From: Michael Mauger Subject: Re: [PATCH] ob-sql: session Message-ID: In-Reply-To: <875xgv7ubd.fsf@7d.nz> References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> <87o6vrkt9k.fsf@localhost> <87msa96nnr.fsf@7d.nz> <_gsZy6NOWi-oN3cJaPi6l9UR-CcN8nIte15ukOu5KDm8QO_VAY9Laal2E6Y17ItZbInHV-dgEFR1heE4QBLvZZKr4udN1b3HZR5dxF9D30E=@protonmail.com> <875xgv7ubd.fsf@7d.nz> Feedback-ID: 119932:user:proton X-Pm-Message-ID: c0a590f8e20db3aa4c706773ef9a0221aa15a352 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: 76025@debbugs.gnu.org, Ihor Radchenko , Org Mode List X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On Monday, June 16th, 2025 at 12:19 PM, Phil Estival wrote: > * [2025-06-15 20:59 +0000] Michael Mauger mmauger@protonmail.com: >=20 > > On Sunday, June 15th, 2025 at 3:16 PM, Phil Estival pe@7d.nz wrote: > >=20 > > > I also took good note of Michael's remarks. > > > The attached series of patches will work > > > without any modification to sql.el. I'll introduce later a local > > > `sql-connection' bound to the session name. In the absence of it, > > > sessions will work, but will ask to confirm provided connection > > > parameter upon establishing connection. > >=20 > > Wouldn't the SQLi buffer created by sql-connect be the session? >=20 >=20 > Yes, right. The session is an identifier name, the buffer's name is > build on that name but the connection's name can be shared among > sessions. >=20 I'd suggest remembering the buffer itself rather than the buffer name. Also= , like `sql-product-interactive', you can control a portion of the buffer n= ame in the `sql-connect' call. But again, it would be safer to use the buff= er itself to memoize the session. Your org session name would translate to = the buffer rather than the potentially changed buffer name. > > At least in sql.el, when it uses either sql-connect or > > sql-product-interactive, all the buffers are scanned to for the > > desired connection settings and switch to the matching buffer rather > > than creating a new buffer. >=20 >=20 > Aren't they opened in parallel, one connection each, with the same > connection parameters ? >=20 > `org-babel-sql-session-connect' uses` sql-product-interactive' with a > buffer name as argument. Different sessions are run in different sql > interactive buffers, yet they have the same connection settings. >=20 The name will be used as part of the match, so using different names will b= ecome different buffers. But I need to look at that logic a bit to insure i= t has consistent behavior. > > I am trying to cleanup sql.el 2.x before I do a more significant > > rewrite for sql.el 3.0. The update will include sql-add-connection > > which cleanly adds an entry to sql-connection-alist and the ability to > > call sql-connect with with the connection settings themselves rather > > than the connection name. Hopefully those will simplify the > > integrations that you need. >=20 >=20 > Fine. >=20 > > And please let me know if you are not getting the behavior you want, > > or if you are working around something that I ought to look at.... >=20 >=20 > * [2025-05-19 01:36 +0000] Michael Mauger mmauger@protonmail.com: >=20 > > For sqlite, I've added support for an in-memory database using the > > name ":memory:" in my local repo. Obviously an empty name indicates a > > temporary database which may be in-memory, or if larger, in temporary > > disk space. I'll take a look at adding support for temporary databases > > but I'm not a huge fan of an empty database name option. Maybe support > > ":tempdb:" (or similar)? >=20 >=20 > The message sqlite3 displays on the welcoming message is: > "Connected to a transient in-memory database.", so perhaps > the proper word is ":in-memory:" ? >=20 > While the empty string as database name should IMHO be avoided, the nil > parameter must still be allowed: >=20 > "If no database name is supplied, the ATTACH sql command can be used to > attach to existing or create new database files. ATTACH can also be > used to attach to multiple databases within the same interactive > session. This is useful for migrating data between databases, possibly > changing the schema along the way." >=20 The nil database should work already, but really means ":memory:" which is = sqlite's default in-memory database, in which ATTACH commands can still be = used.=20 > Cheers, > -- > Phil Estival I have been dealing with sick family for the past month and will be unavail= able for at least the next week. I expect to have some coherent changes to = sql.el by early July; I apologize for the delay but its been a chaotic 6 we= eks but appears to finally be settling down...=20 --=20 MICHAEL@MAUGER.COM // FSF and SFConservancy // GNU Emacs sql.el maintainer From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 19 09:15:13 2025 Received: (at 76025) by debbugs.gnu.org; 19 Jun 2025 13:15:14 +0000 Received: from localhost ([127.0.0.1]:33613 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uSF6l-00024s-MC for submit@debbugs.gnu.org; Thu, 19 Jun 2025 09:15:13 -0400 Received: from mout02.posteo.de ([185.67.36.66]:37847) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uSF6f-00022P-VC for 76025@debbugs.gnu.org; Thu, 19 Jun 2025 09:15:09 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id E4186240103 for <76025@debbugs.gnu.org>; Thu, 19 Jun 2025 15:14:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=1984.ea087b; t=1750338899; bh=f9kY+i1ccsGI4iNvZyb1EqbjJWrSFp2hesxJhYGzPiU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=adan2Dep/8thZX/TfBfPPbbn9fFWsxgdikzBdKrzpg/QIJrOZFoM4ZcN+g15SAcj3 v2q646lkWqDQX8ENHw33JgHz/rN0XAbcW81FE+I2qn8IyXoAfnwlVyjI2cSFind6JS Arn2fdzFH3XxFHsXQcPc7YkiM/zDyPfFOglmofH5CstAsHgMqWp4fGwHbaxLKr1qsG llyD+GLKQvB5TYbxOLkLn3JtRgWU91TAvEm42rN4Os1hA7YhD4tVrij/I2dWD/TnWb ipoQwN6TryDFOyF+nXF6hvYIQL34VUY8Q6JBL7BMY8C+wjG6fEjXCAqXGuFSMM0WnE D04y08dpO9kFwBDfemOeGeNJGZ96gfF9cIOOTKC0fzDdNmH0O09FS5OlyzgwpWovpt jurKUS/VRpKlpmlzL5CBzHTCnW5nFZ6zrn7izvNYTPsFKWrkHrNMYzQmuhspLgRnEl PFqoaNFKzhZhLbYgn4zdA2yo9ANW3MXktkOTZgC4yEGCR95QFiz Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4bNLgR1W3xz9rxK; Thu, 19 Jun 2025 15:14:58 +0200 (CEST) From: Ihor Radchenko To: Phil Estival Subject: Re: [PATCH] ob-sql: session In-Reply-To: <87msa96nnr.fsf@7d.nz> References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87seqrh3wl.fsf@localhost> <2c80ecf8-e114-45fd-8116-49ce0f975070@7d.nz> <875xmq31vr.fsf@localhost> <87a5bps4l1.fsf@localhost> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> <87o6vrkt9k.fsf@localhost> <87msa96nnr.fsf@7d.nz> Date: Thu, 19 Jun 2025 13:13:38 +0000 Message-ID: <87qzzfeuwt.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: Michael Mauger , Org Mode List , 76025@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Phil Estival writes: > I'm submitting again the patches for ob-sql.el, taking into > considerations the previous review, commented below. I also took good > note of Michael remarks. The attached series of patches will work > without any modification to sql.el. I'll introduce later a local > `sql-connection' bound to the session name. In the absence of it, > sessions will work, but will ask to confirm provided connection > parameter upon establishing connection. Thanks! > What naming convention to opt for ? org-babel-[lang]-var ? > or ob-[lang]-var ? org-babel-[lang]-var > I reintroduced `org-macs to provide `org-require-package in the following > patches. But shouldn't `org-assert-version be checked only once when > org core loads instead of subsequent modules? The purpose of org-assert-version is recording Org version information in the compiled .elc file (it is a macro expanded at compile time). That information is later compared with the dynamically determined Org version, warning about mismatch. This approach allows us catching a common problem when parts of Org libraries are loaded from built-in Org mode (inside Emacs installation) and other parts are loaded from external Org version (e.g. from ELPA). So, it should be in each Org library - to make sure that every Org library is from the same Org version. >> Why `sql--bufer'? (double slash) It is not a variable sql.el uses. >> > > Replaced by `ob-sql-buffer'. > IIUC, a double dash indicates a variable used by the prefixed package? The usual convention is 1. -... is a variable that belongs to 2. --... is an internal variable that belongs to So, your `sql--buffer' can be read as a variable that belongs to sql.el itself. We may even accidentally shadow sql.el if it ever decided to introduce such variable. >>> + (when (not session-p) >>> + (comint-quit-subjob) >>> + ;; despite this quit signal, the process may not be finished yet >>> + (let ((kill-buffer-query-functions nil)) >>> + (kill-this-buffer)))) >> >> Maybe we should wait until it is finished then? You can check >> `process-status'. > > To be fixed next time Ok. Leaving it in this message for easier review next time. > From e27f8231c2f97e6f7f84b6acb793eec7060b8396 Mon Sep 17 00:00:00 2001 > From: Phil Estival > Date: Wed, 13 June 2025 17:00:00 +0200 > Subject: [PATCH 01/08] ob-sql: add session support > > lisp/ob-sql.el: add session support to ob-sql > > * ob-sql.el: declare the maintainer of the following changes There is no notion of maintainer for specific changes. Simply say: ob-sql: Add Philippe Estival as a new maintainer Daniel is not active on the list since 2023, so we should probably remove him. Will need to ping him later to confirm that he is really AWOL. > +(defvar org-sql-batch-terminate > + (list 'sqlite (format ".print %s\n" org-sql-session--batch-terminate) > + 'postgres (format "\\echo %s\n" org-sql-session--batch-terminate)) > + "Print the command batch termination as last command.") "Print the command batch termination as last command." sounds like this is a function that prints the command ... Maybe "Alist of SQL commands used to print end marker after a command batch. Keys of the alist are symbols like `sqlite', `postgress', etc. Values of the alist are the SQL commands." > +(defvar-local org-sql-session-command-terminated nil > + "Non-nil when a command batch has completed.") Maybe "Non-nil when a command batch has completed in current SQL session buffer." > +(defvar-local org-sql-session-start-time nil > + "Starting time of a session code block execution, used to exit on timeout.") Similar here. I believe that specifying that the variable is about session buffer will make things more clear. > +(defvar-local org-sql-session-clean-output nil > + "Store the regexp used to clear output (prompt1|termination|prompt2).") This also sounds like a function "store" (action). Maybe "Regexp to filter out from SQL command output. This variable is set buffer-local in SQL session buffer to filter out prompts and termination strings." > +(defcustom org-babel-default-header-args:sql '((:engine . "unset")) I think "none" will be a bit more idiomatic for Org babel. > + "Default header args." > + :type '(alist :key-type symbol :value-type string > + :options ("dbi" "sqlite" "mysql" "postgres" > + "sqsh" "mssql" "vertica" "oracle" "saphana" )) > + :group 'org-babel-sql > + :safe t) I do not think that we should make this particular variable a defcustom. Simply because none of other babel backends do it. Also, the list of SQL engines may probably be stored in a constant, so that we can reuse it. > +(defcustom org-sql-session-preamble > + (list > + 'postgres " > +\\set ON_ERROR_STOP 1 > +\\pset footer off > +\\pset pager off > +\\pset format unaligned" > + 'sqlite " > +.header off") > + "Command preamble to run upon shell start." > + > + :type '(plist :key-type symbol :value-type string > + :options ('postgres 'sqlite 'dbi 'mysql > + 'sqsh 'mssql 'vertica 'oracle 'saphana )) > + :group 'org-babel-sql > + :safe t) I do not think that :safe t is appropriate for the code that will be injected into every SQL block. > +(defcustom org-sql-run-comint-p nil > + "Run non-session SQL commands through comint if not nil." The idiomatic way is "If non-nil, ..." > + :type 'boolean > + :group 'org-babel-sql > + :safe t) > + > +(defcustom org-sql-timeout 5.0 > + "Abort on timeout." Action is always confusing at the beginning of variable docstring. I suggest "Timeout, in seconds, before ob-sql aborts code evaluation." > (defun org-babel-sql-dbstring-mysql (host port user password database) > "Make MySQL cmd line args for database connection. Pass nil to omit that arg." > - (mapconcat > - #'identity > + (combine-and-quote-strings `combine-and-quote-string' is _not_ the same as `shell-quote-argument'. In fact, it has nothing to do with shell quoting. `combine-and-quote-string' is about Elisp string quoting. I recommend looking into the source code of these two functions. The difference will be obvious. > Subject: [PATCH 06/08] ob-sql: add session support (I used the version of the patch you posted https://list.orgmode.org/orgmode/87wm9b6ffe.fsf@7d.nz/) > + (setq-local org-sql-session-clean-output > + (plist-put org-sql-session-clean-output in-engine > + (concat "\\(" prompt-regexp "\\)" > + "\\|\\(" org-sql-session--batch-terminate "\n\\)" > + (when prompt-cont-regexp > + (concat "\\|\\(" prompt-cont-regexp "\\)")))))) Since the variable is buffer-local, do we really need to store per-engine values? Can be there multiple engines in the same SLQ comint buffer? > +(defun org-sql-session-comint-output-filter (_proc string) > + "Process output STRING of PROC gets redirected to a temporary buffer. > +It is called several times consecutively as the shell outputs and flush > +its message buffer" > ... > + > + (when (or (string-match org-sql-session--batch-terminate string) > + (> (time-to-seconds > + (time-subtract (current-time) > + org-sql-session-start-time)) > + org-sql-timeout)) > + (setq-local org-sql-session-command-terminated t)) But that won't actually terminate the command when we are over `org-sql-timeout', right? So, if something hangs, we will be unable to send any new src blocks to this SQL buffer (with :session). > + (format "%s\n;\n%s" > + (org-babel-expand-body:sql > + (replace-regexp-in-string "[\t]" "" body) params) Why do you need an additional cleanup of the BODY? Can't it be done inside `org-babel-expand-body:sql' itself? -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 19 13:01:37 2025 Received: (at 76025) by debbugs.gnu.org; 19 Jun 2025 17:01:37 +0000 Received: from localhost ([127.0.0.1]:36048 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uSIdr-0005MU-JU for submit@debbugs.gnu.org; Thu, 19 Jun 2025 13:01:36 -0400 Received: from mout01.posteo.de ([185.67.36.65]:42043) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uSIdp-0005LV-Ei for 76025@debbugs.gnu.org; Thu, 19 Jun 2025 13:01:34 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id D1722240027 for <76025@debbugs.gnu.org>; Thu, 19 Jun 2025 19:01:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=1984.ea087b; t=1750352486; bh=ZmM8Qf4JPtxPoMdwXBWLJ0hpJUuMVfXLXzdJZM2yqEk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=BkBFBjzvjKbDDIfGuPCK7dJUHNDSfktbmc6zBPyPUOmtXcWT+/zu04LKfKKDUPCXG yyJylkzwHspMM+CniRY5s0Yb3LG8TFMwbk2Sy+DemDaIdOXTd9CVdPs6SXW5AdWdPU W6GxvRgpWcHOEHXA0BHdQEy1EnbmzhZEPyyal0mA7hVNi6q2YzD1J+0oh6BHsoWnUd GpTMKHG9AMw2D8opE/L3P0WFog2jknM72tzqaKKfCwbBESzSN9dUuZVwv+hLBZjz8c gzSKyFmP7HLWIY+ZMzjGKB9QNcvYWC/qIR4EaQDDavCVZzmWdiWtXoiXGPB2i9Y3Z8 zrWjDnK3edKaZh8+AiZ9QYWHaZhzVftqpueYQRzUHSRpQAoSMrBxpcsNhrDdztDzEg XV6McldW3yRPBULpLcZsoC6JmPG1fz1GT2UA4hCXxEgv52X3Pg330+yO5I60qux2L5 DhDKI+lZhnEhqSOwZwWz6XC60aln71AXkwOqbtap7TP3vcf3R8s Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4bNRhk1J52z6v0C; Thu, 19 Jun 2025 19:01:26 +0200 (CEST) From: Ihor Radchenko To: Michael Mauger Subject: Re: [PATCH] ob-sql: session In-Reply-To: References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87ikq9qpcc.fsf@localhost> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> <87o6vrkt9k.fsf@localhost> <87msa96nnr.fsf@7d.nz> <_gsZy6NOWi-oN3cJaPi6l9UR-CcN8nIte15ukOu5KDm8QO_VAY9Laal2E6Y17ItZbInHV-dgEFR1heE4QBLvZZKr4udN1b3HZR5dxF9D30E=@protonmail.com> <875xgv7ubd.fsf@7d.nz> Date: Thu, 19 Jun 2025 17:00:05 +0000 Message-ID: <874iwbd5uy.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 76025 Cc: Phil Estival , 76025@debbugs.gnu.org, Org Mode List X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Michael Mauger writes: > I'd suggest remembering the buffer itself rather than the buffer name. Also, like `sql-product-interactive', you can control a portion of the buffer name in the `sql-connect' call. But again, it would be safer to use the buffer itself to memoize the session. Your org session name would translate to the buffer rather than the potentially changed buffer name. Org mode markup communicates "session" by naming it. So, one way or another, Org mode APIs expect some way to link session name string to actual buffer. API-wise, it is done via `org-babel-session-buffer', which can optionally use special function org-babel-session-buffer:sql (if defined) to perform backend-specific logic. -- Ihor Radchenko // yantar92, Org mode maintainer, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Thu Jun 19 15:32:17 2025 Received: (at 76025) by debbugs.gnu.org; 19 Jun 2025 19:32:18 +0000 Received: from localhost ([127.0.0.1]:38351 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1uSKzg-0004Ma-8g for submit@debbugs.gnu.org; Thu, 19 Jun 2025 15:32:17 -0400 Received: from mail-24416.protonmail.ch ([109.224.244.16]:17655) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1uSKzc-0004L2-MO for 76025@debbugs.gnu.org; Thu, 19 Jun 2025 15:32:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1750361526; x=1750620726; bh=B5oBZ/xv7HAfLMbFKmpA4/BA1DbbYd5YF1XzgjpP7PA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=y3q8u3JPyagraKx306qpiJzNIL6YU8jeh4JUY6MM63aNzEDGnGjk/gdGQIrIE6llm TpXHhoqNM6mtO5O+LqFNSB0cviS/oflriT1/pTGgVIUDAS39AeCajCP68UkiUcMnVj eUQ7fbRizIb26oclQaiu+hiVFw3/1ibYJYtXs8QJ/Cmpqi23ZmvHiJZlfxzVyirmyC 4Mwnic4iLaguYxHwa1LpAcbmKVcAu16c3YytnlIFGJJcLgEzbJ/kBrgpHyKtfs0MQe 4wAqTX1w/ZHJqAobtOzdK3NjK+Ukcgd/K0F6V3gXlxaAC1HoiEpW/fgH7z6AvpsosA gWHqnCEnVvLpg== Date: Thu, 19 Jun 2025 19:32:01 +0000 To: Ihor Radchenko From: Michael Mauger Subject: Re: [PATCH] ob-sql: session Message-ID: <0qL14TwZ-WpoVmlNAM7QKCKbz5LA1sIV7kAZ1zf1lEd8rcAiRYMJyCNIrgJVhIMWqe3FrNQ-6qPVwLjy8Ns0DNnPzsDKRbTGRROJX44b1c0=@protonmail.com> In-Reply-To: <874iwbd5uy.fsf@localhost> References: <646f7d12-a3d1-4a7c-83e2-5eecd7ca6817@7d.nz> <87r03zcgzu.fsf@localhost> <87sel7mfjl.fsf@7d.nz> <87o6vrkt9k.fsf@localhost> <87msa96nnr.fsf@7d.nz> <_gsZy6NOWi-oN3cJaPi6l9UR-CcN8nIte15ukOu5KDm8QO_VAY9Laal2E6Y17ItZbInHV-dgEFR1heE4QBLvZZKr4udN1b3HZR5dxF9D30E=@protonmail.com> <875xgv7ubd.fsf@7d.nz> <874iwbd5uy.fsf@localhost> Feedback-ID: 119932:user:proton X-Pm-Message-ID: e8d4a9bb1adc4c29c1427323f013900dcf1ddcb6 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 76025 Cc: Phil Estival , "76025@debbugs.gnu.org" <76025@debbugs.gnu.org>, Org Mode List X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) -------- Original Message -------- On 6/19/25 1:01 PM, Ihor Radchenko wrote: > Michael Mauger writes: > =20 > > I'd suggest remembering the buffer itself rather than the buffer name.= Also, like `sql-product-interactive', you can control a portion of the buf= fer name in the `sql-connect' call. But again, it would be safer to use the= buffer itself to memoize the session. Your org session name would translat= e to the buffer rather than the potentially changed buffer name. > =20 > Org mode markup communicates "session" by naming it. > So, one way or another, Org mode APIs expect some way to link session > name string to actual buffer. > =20 > API-wise, it is done via `org-babel-session-buffer', which can > optionally use special function org-babel-session-buffer:sql (if > defined) to perform backend-specific logic. > =20 My suggestion was to store the stable buffer object with the session. The A= PI can serve up the name of that's what is what is expected but recognize t= hat while the buffer is stable, the buffer name might not be depending upon= the users configuration. I also want to make sure that you are not relying= upon some naming convention of SQLi buffer names to your session names.=20 In the end, these are org decisions but I cannot guarantee stability of the= buffer naming convention generated by sql-mode going forward=E2=80=A6