Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t58Xj-004Etq-7U for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Oct 2024 19:03:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1t58Xe-000aTT-Uq for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Oct 2024 19:03:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t58Xe-000aTL-LM for pgsql-hackers@lists.postgresql.org; Sun, 27 Oct 2024 19:03:11 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1t58Xc-0039Ps-Az for pgsql-hackers@lists.postgresql.org; Sun, 27 Oct 2024 19:03:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 49RJ36LR3803370; Sun, 27 Oct 2024 15:03:07 -0400 From: Tom Lane To: Tomas Vondra cc: pgsql-hackers@lists.postgresql.org Subject: Re: libedit history seems to be misbehaving / broken In-reply-to: <665e2b50-8969-42e1-b691-aabb9ea5ada5@vondra.me> References: <665e2b50-8969-42e1-b691-aabb9ea5ada5@vondra.me> Comments: In-reply-to Tomas Vondra message dated "Sun, 27 Oct 2024 18:47:10 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3803368.1730055786.1@sss.pgh.pa.us> Date: Sun, 27 Oct 2024 15:03:06 -0400 Message-ID: <3803369.1730055786@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tomas Vondra writes: > I'm not terribly familiar with libedit, so can't say if it's a bug in > libedit, or if we're just using it wrong in some way. I investigated > that while on a flight from pgconf.eu, but can't look into this further. > So let me at least share the behavior I observed, and what I found. > Note: All of this is with libedit-3.1-53.20240808cvs.fc40.x86_64, which > is what I currently get in Fedora 40. libedit has been a hot mess for a long time. psql's input.c has workarounds for assorted bugs that it has or had in prior versions, and what I suspect is that latest libedit has a different set of bugs. FWIW, I don't observe any particular misbehavior with the very ancient libedit that macOS ships. On Fedora 39, I notice something related to what you say: it seems like the "\q" ending a session gets repeated into .psql_history by the next session. I'm surprised that it's not exactly the same as your results though, because it seems to be the same source version: $ rpm -q libedit libedit-3.1-53.20240808cvs.fc39.x86_64 Didn't try the too-many-lines behavior, but it looks like that is implemented totally by history_truncate_file(), so if that's busted it's surely their fault. regards, tom lane