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 1vBrul-006CJi-MP for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Oct 2025 09:47:23 +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 1vBruk-007jwk-DK for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Oct 2025 09:47:21 +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 1vBruj-007jt6-Pc for pgsql-hackers@lists.postgresql.org; Thu, 23 Oct 2025 09:47:21 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1vBruf-003KL4-1w for pgsql-hackers@postgresql.org; Thu, 23 Oct 2025 09:47:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1761212833; bh=reNMbtDnBT5qtrAWAESUGOvgASnKIKTN8DqFpA5ZYko=; h=Date:From:To:Subject:Message-ID:From; b=eGZxRSguyNwIsGGKv9YenYOsNX11kfK2Zpxj/nAQnJgqSgDLLPL+VNHL6Xn6D1Qx3 6XkYhsqRTa474GY5Aab3vYngQ+pnBMA6O3pfVWs1D26FPytS1kaTcmhOkJETbS8qUS FiGBnrVY/Mg8J53tUoHS39leeaD1HzJGb98g5dhoDb6aIwTyO9QcsgvEUvbq0FzpJH i5vRumh5CbkpuXGWcoP+mQrLJhndx4WnFi9Lab28VbyF/7GZXGLJxV6ziSp3rk+LgW UWzmqty5nknuKF64ubdKIrL/tsCown75JEM6q5YJvwbZkJ25A0NQTO7IW3PvVaUUrK vU3tZ0wMfiyxw== Received: from mail.postgrespro.ru (webmail-master-mstn.l.postgrespro.ru [192.168.2.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: o.tselebrovskiy@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id 7F74060A9C for ; Thu, 23 Oct 2025 12:47:13 +0300 (MSK) MIME-Version: 1.0 Date: Thu, 23 Oct 2025 12:47:13 +0300 From: Oleg Tselebrovskiy To: pgsql-hackers@postgresql.org Subject: 001_password.pl fails with --without-readline Message-ID: X-Sender: o.tselebrovskiy@postgrespro.ru Organization: Postgres Pro Content-Type: multipart/mixed; boundary="=_9316ce4344f9b53aa1642a23c5656194" X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/10/23 07:51:00 #27791923 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=_9316ce4344f9b53aa1642a23c5656194 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Greetings! If you configure PostgreSQL with --without-readline, test authentication/t/001_password.pl fails due to timeout This can be reproduced on any branch that contains commit 8b886a4 (so, on PostgreSQL 13-19) I've looked through debug info using IPCRUNDEBUG = "data" or "details" Here's some output: This is with readline: [18:31:45.030](0.027s) ok 22 - scram_iterations in server side ROLE IPC::Run 0001 [#15(253566)]: ** pumping IPC::Run 0001 [#15(253566)]: write( 10, '\echo background_psql: ready IPC::Run 0001 [#15(253566)]: \warn background_psql: ready IPC::Run 0001 [#15(253566)]: ' ) = 58 IPC::Run 0001 [#15(253566)]: ** pumping IPC::Run 0001 [#15(253566)]: read( 10 ) = 60 chars '\echo background_psql: ready IPC::Run 0001 [#15(253566)]: \warn background_psql: ready IPC::Run 0001 [#15(253566)]: ' IPC::Run 0001 [#15(253566)]: ** pumping IPC::Run 0001 [#15(253566)]: read( 10 ) = 41 chars 'psql (19devel) IPC::Run 0001 [#15(253566)]: Type "help" for help. IPC::Run 0001 [#15(253566)]: IPC::Run 0001 [#15(253566)]: ' IPC::Run 0001 [#15(253566)]: ** pumping IPC::Run 0001 [#15(253566)]: read( 10 ) = 11 chars 'postgres=# ' IPC::Run 0001 [#15(253566)]: ** pumping IPC::Run 0001 [#15(253566)]: read( 10 ) = 65 chars '\echo background_psql: ready IPC::Run 0001 [#15(253566)]: background_psql: ready IPC::Run 0001 [#15(253566)]: postgres=# ' IPC::Run 0001 [#15(253566)]: ** pumping IPC::Run 0001 [#15(253566)]: read( 10 ) = 41 chars '\warn background_psql: ready IPC::Run 0001 [#15(253566)]: postgres=# ' IPC::Run 0001 [#15(253566)]: read( 12 ) = 23 chars 'background_psql: ready IPC::Run 0001 [#15(253566)]: ' [18:31:45.042](0.013s) # connect output: And this is without readline: [18:34:32.050](0.029s) ok 22 - scram_iterations in server side ROLE IPC::Run 0001 [#15(263802)]: ** pumping IPC::Run 0001 [#15(263802)]: write( 10, '\echo background_psql: ready IPC::Run 0001 [#15(263802)]: \warn background_psql: ready IPC::Run 0001 [#15(263802)]: ' ) = 58 IPC::Run 0001 [#15(263802)]: ** pumping IPC::Run 0001 [#15(263802)]: read( 10 ) = 60 chars '\echo background_psql: ready IPC::Run 0001 [#15(263802)]: \warn background_psql: ready IPC::Run 0001 [#15(263802)]: ' IPC::Run 0001 [#15(263802)]: ** pumping IPC::Run 0001 [#15(263802)]: read( 10 ) = 98 chars 'psql (19devel) IPC::Run 0001 [#15(263802)]: Type "help" for help. IPC::Run 0001 [#15(263802)]: IPC::Run 0001 [#15(263802)]: postgres=# background_psql: ready IPC::Run 0001 [#15(263802)]: postgres=# postgres=# ' IPC::Run 0001 [#15(263802)]: ** pumping IPC::Run 0001 [#15(263802)]: read( 12 ) = 23 chars 'background_psql: ready IPC::Run 0001 [#15(263802)]: ' IPC::Run 0001 [#15(263802)]: ** pumping As you can see, those outputs are different 1) In readline output commands \echo and \warn are re-read (that's why banner_match in BackgroundPsql.pm has checks for \n or start of line), but in no-readline output both \echo and \warn are read only once, when they are first send to psql 2) In readline ouput stdout is re-read multiple times, and banner (background_psql: ready) is placed neatly on it's own line, while in no-readline output banner in stdout is mixed with "postgres=#" prompts, and they are read as one batch Those differences are probably an effect of inner workings of readline, turning input echoing off. Also, without readline, stdout during query exectution can look like this # \\echo background_psql: QUERY_SEPARATOR 1: # \\warn background_psql: QUERY_SEPARATOR 1: # SET # postgres=# postgres=# background_psql: QUERY_SEPARATOR 1: # postgres=# ' So, there are some ways to handle this situation 1) Skip this test if Postgres is configured without readline support. I don't think this is a good way, since this test doesn't really test anything that needs readline to work 2) Modify variable banner_match depending on having readline or not. Something like the attached I'm interested to hear your thoughts on this Oleg Tselebrovskiy, PostgresPro --=_9316ce4344f9b53aa1642a23c5656194 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=v1-0001-background-psql-without-readline.patch Content-Disposition: attachment; filename=v1-0001-background-psql-without-readline.patch; size=2193 ZGlmZiAtLWdpdCBhL3NyYy90ZXN0L3BlcmwvUG9zdGdyZVNRTC9UZXN0L0JhY2tncm91bmRQc3Fs LnBtIGIvc3JjL3Rlc3QvcGVybC9Qb3N0Z3JlU1FML1Rlc3QvQmFja2dyb3VuZFBzcWwucG0KaW5k ZXggNjBiYmQ1ZGQ0NDUuLmRjZTdjY2Q2NGQwIDEwMDY0NAotLS0gYS9zcmMvdGVzdC9wZXJsL1Bv c3RncmVTUUwvVGVzdC9CYWNrZ3JvdW5kUHNxbC5wbQorKysgYi9zcmMvdGVzdC9wZXJsL1Bvc3Rn cmVTUUwvVGVzdC9CYWNrZ3JvdW5kUHNxbC5wbQpAQCAtM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