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 1uuGNg-005rWj-2J for pgsql-general@arkaria.postgresql.org; Thu, 04 Sep 2025 20:16:29 +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 1uuGNe-0022kb-Bz for pgsql-general@arkaria.postgresql.org; Thu, 04 Sep 2025 20:16:26 +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 1uuGNd-0022kR-CP for pgsql-general@lists.postgresql.org; Thu, 04 Sep 2025 20:16:26 +0000 Received: from fout-b1-smtp.messagingengine.com ([202.12.124.144]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1uuGNb-000YrP-1f for pgsql-general@lists.postgresql.org; Thu, 04 Sep 2025 20:16:24 +0000 Received: from phl-compute-12.internal (phl-compute-12.internal [10.202.2.52]) by mailfout.stl.internal (Postfix) with ESMTP id 347501D0048B; Thu, 4 Sep 2025 16:16:22 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-12.internal (MEProxy); Thu, 04 Sep 2025 16:16:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1757016982; x=1757103382; bh=+RZ/w4w4zWAIwj/cGP+yR+2OFSGY0IleSe2CYCzqWJg=; b= TDX/orFX2WXs0I6BfrP21AGpHIBz6mcfRa2AxSShWjYaTF66oXCEeMFrkpfhmvRG TRStch/u2QQu9wKf4bzugGebKBaZHhEsfWdkxR9Ix/1oT/HiOXTEd5jwVWBrEmi2 dYt7Gsuwd0w7tL8s+cQbgnYw/zuAEjKwWOM9mUYh/KxZGhkg7J4nfCdTNq4EL/+K a9fPQC8dEGCZrs75h4+ZV2GgK7NQ7AOwEAmdQ2d80HsFAASYQASPyq4sAHPxthkw Ry/yu2bYxf7m8ekdhZFG7O89t5+pXYvqD++pmJ4JAGEb/aM8ICoIUe5oGvDVKAlp izd0k4YNt9QG0GOdUnIkrA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1757016982; x= 1757103382; bh=+RZ/w4w4zWAIwj/cGP+yR+2OFSGY0IleSe2CYCzqWJg=; b=R ZXgS32gUTSu4HRZg95x0IvwJWjSs0+EN/YIaawFaOqPIU+oVxZH/qopLIqkUw84Y MycSWCMu7wfQwQUDYUNY5S9pgvj428nVZZY66bM97BiFpMZNUQcxvp0zzWdJIcVz 9RKokS6LfJ9KPb1aFGG006FGcsKSsM6bc0InmHp+jYDyL+AvHex6ERuRby2RodDq zqMLtj0oPrCSgFMNDdloleTKu4AzxwDIz7UJm30vIUl8glFIL0YOykVpuzdtGDzE 9UbIGp3YioCjiYS7NMFN5SW7nxnO+w7b2gDxwD8SAxHRuESM3PC1bW2uHRYYoEpM wppGa9Cn1i0fiz6zHGXgw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdeileehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttd dvjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghv vghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeekffduvdetkeejje evfedukeegfeffuedvhfetudduteevhfehteejffehgfeifeenucffohhmrghinhepphhs higtohhpghdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhmpdhnsggp rhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegrlhgsrhgvtg hhthdrughrvghsshesphhoshhtvghordguvgdprhgtphhtthhopehtghhlsehsshhsrdhp ghhhrdhprgdruhhspdhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhishhtsh drphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 4 Sep 2025 16:16:21 -0400 (EDT) Message-ID: <452c4e48-5ea8-46cf-9826-7afaddb323e1@aklaver.com> Date: Thu, 4 Sep 2025 13:16:20 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Q: limit the length of log file entries? To: =?UTF-8?Q?Albrecht_Dre=C3=9F?= Cc: Tom Lane , pgsql-general@lists.postgresql.org References: <574OKSN4.CDETQIBQ.ZESIWSCX@VP6CMSVU.ANT6WK46.P2K35XKE> Content-Language: en-US From: Adrian Klaver In-Reply-To: <574OKSN4.CDETQIBQ.ZESIWSCX@VP6CMSVU.ANT6WK46.P2K35XKE> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/4/25 12:43, Albrecht Dreß wrote: > Am 04.09.25 20:21 schrieb(en) Adrian Klaver: >>> "Psycopg 3 sends the query and the parameters to the server separately, >>> instead of merging them on the client side. Server-side binding works >>> for normal SELECT and data manipulation statements (INSERT, UPDATE, >>> DELETE), but it doesn’t work with many other statements. For instance, >>> it doesn’t work with SET or with NOTIFY:" >> >> As example: >> >> import psycopg2 >> import psycopg >> >> conpsyc2 = psycopg2.connect("dbname=test user=postgres") >> conpsyc3 = psycopg.connect("dbname=test user=postgres") >> >> cur2 = conpsyc2.cursor() >> cur3 = conpsyc3.cursor() >> >> cur2.execute("select * from csv_test where id = %s", [1]) >> cur3.execute("select * from csv_test where id = %s", [1]) >> >> yields: >> >> --cur2 >> 2025-09-04 11:17:30.246 PDT [29695] postgres@test LOG: statement: BEGIN >> 2025-09-04 11:17:30.246 PDT [29695] postgres@test LOG: statement: >> select * from csv_test where id = 1 >> >> --cur3 >> 2025-09-04 11:18:07.158 PDT [29703] postgres@test LOG: statement: BEGIN >> 2025-09-04 11:18:07.159 PDT [29703] postgres@test LOG: execute >> : select * from csv_test where id = $1 >> 2025-09-04 11:18:07.159 PDT [29703] postgres@test DETAIL: Parameters: >> $1 = '1' > > Very nice example! Looks as if the (anyway broken) script should be migrated to the the newer Python module – which, looking into the docs, shouldn't be too complex… Just be sure to read: https://www.psycopg.org/psycopg3/docs/basic/from_pg2.html Things that I had to deal with: 1) These: https://www.psycopg.org/docs/extras.html#fast-execution-helpers don't exist in psycopg(3). Made up for, in my cases, because executemany() is faster in psycopg as it uses pipeline mode when libpq 14+ is available. 2) COPY is not file based, so it's usage has changed. The examples here: https://www.psycopg.org/psycopg3/docs/basic/copy.html#copy are clear and it was not that difficult to change over. 3) with connection has changed. It now closes the connection as well as the transaction. FYI, you can use: https://www.psycopg.org/psycopg3/docs/advanced/cursors.html#client-side-binding-cursors to keep the old client side binding style of parameters to help migrate code over in stages. > > Thanks a lot for all your helpful insight, > Albrecht. -- Adrian Klaver adrian.klaver@aklaver.com