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.96) (envelope-from ) id 1whiol-000Npu-2w for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 07:05:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1whioi-00BLei-05 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Jul 2026 07:05:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1whioh-00BLea-0o for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 07:05:04 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1whiod-00000000QLF-36v1 for pgsql-hackers@lists.postgresql.org; Thu, 09 Jul 2026 07:05:03 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id 3A7277A012A; Thu, 9 Jul 2026 03:04:57 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Thu, 09 Jul 2026 03:04:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eisentraut.org; h=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=fm1; t=1783580697; x=1783667097; bh=m4/INgxVx2XesqZT0UGp0ZOqKa7b/tboxbyxxBdG5/k=; b= s+rNGCULFSMFrXS+s6uhvpUPedxaHA1/IU6qY+yLhTLA4MdCZJGkctlBIhP2hrYM lzROQsEsXzUF5drZdx+8eUZWLRHQvCoGxKqChqOEvRUd89+sKjkhoiRn3IUm9EUT RSiCSpQN3s1aqkLsy6o0Puv260FvBJd/SXp391iXU4JfExyS8lDmBZWneOWM3Nd3 nx5+o4bOh5HtRpXAQ2shtoRrzc70qsbX28dkYYA4wDad4IpELwZUUjb1DV3g7hul 1B+eZ1C70nqY0/dYlIidhNNR18km8W5zJkGBmrO5SnsnHdh2nddWwQ1glk8cvpFR 3X9HOo8Qjf5bHDwoXrouOQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=fm2; t=1783580697; x=1783667097; bh=m 4/INgxVx2XesqZT0UGp0ZOqKa7b/tboxbyxxBdG5/k=; b=cZ2zPWWHwFkB1lPgO 6AhAKOwjqW1ZLVFWEqDmnPLV4qCldqFQKYU5qb6FFBzUvbib/2jn0zb6v913ZXi4 t9xwkK+SNxeDuPMFKdjPeQ5hK4gFs0q1ccX2RSA21ayqkc4zGvxV9ThvKfqMMi+F Zq53xTQvz9So2hM+0PDZhWqYobw82sHRMj904kPCRG+X/cCmTnBgSv7HNzQQ1m4m 1TmIKtcXx1SEEwGdlGD4xhD3buN6R4mchwH9UncuUVewaX/Mp7TvrL8pukA+Xt+m zuWMfUmCn7N0jGPyNXIQ46ta/WRHSt/UTfugtXwTTojjRi5hRaAPXGC2mu1TivXz 8Y7yg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFeCCqU2Wvg5313vXlTIsdcPuJClcl75Y7IU8soFyqCLm5rYtia7T4aYuKx0nxZ/O kByAj1XTxyapUIASrkZfCRouXGXu8KFrnYLQq4ySdJB6vQWqsQH6vQU1e10HugIORuXBPM cLIDqqZSxWLEa5Q+gspofVnxAlQBP12PyJEMMWW49gMhdTobXKy/zVlx6Uomu8rAadsLo6 SBwrKvNIl5aWgz7+SH2Ic3jTbPkQouen6Gt6DY0VzVyC1rUCIadCJo2DYWu7+Bs9F3Bf6u g/ffcAb87MjotHpEK3yt+yyPJbwWD1caT3OZh7x1zjb5CeYk68kg4OC+2DM7gHl6cG1vta IJ+48nDdcZPiQSM24MgJ1QIkB+rRHW4OR2Cf5ua3ljsgErsIzHbsiclxRBUvPgdGFnVBBJ LV8Q558vPC5elc+LgitnZ0qdhNhqdYqlQO0SCUOwnutq3tT1oZiXpgKpbKo4ZrBWSZ/n2g fIimgshTRwkKNPhAZYHZgGtR3tgdPyaTO6NZVYf2SZ6EMwNHImpYv7QTLeRRno0GWGR3OZ Wc2Yot5CJaddsenHZj1Biw7L3KLKKhgGFLCXu9UWW+zC9fEf5dBPZBexBwFbJGPFtMnr6g NafpwORsVFFRU8Sv5+FidhJTvlF/lHWWpsUmgP2r0jaK5DTR4m4d6vnEOEtg X-ME-Proxy: Feedback-ID: ie0a040ee:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 9 Jul 2026 03:04:56 -0400 (EDT) Message-ID: Date: Thu, 9 Jul 2026 09:04:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] ecpg: use memcpy in a few length-based copies To: Haibo Yan , PostgreSQL Hackers References: From: Peter Eisentraut Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 08.07.26 21:24, Haibo Yan wrote: > I noticed a few places in ecpg that use strncpy() even though the code already > knows how many bytes to copy. > > For example, some paths copy N bytes into a temporary buffer and then add the > terminating NUL explicitly. There is also one small substring copy in > pgtypeslib/datetime.c. memcpy() seems a better fit for those cases. Why is it better? At least strncpy() enforces that the target is a char array, which memcpy() doesn't. At a quick glance, strlcpy() might be more suitable in some of the cases you found.