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 1ujlz2-00Bpqf-QA for pgsql-general@arkaria.postgresql.org; Wed, 06 Aug 2025 21:47:41 +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 1ujly3-001Qs2-Fs for pgsql-general@arkaria.postgresql.org; Wed, 06 Aug 2025 21:46:39 +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 1ujly3-001Qrq-4v for pgsql-general@lists.postgresql.org; Wed, 06 Aug 2025 21:46:39 +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.96) (envelope-from ) id 1ujly0-00170x-1v for pgsql-general@lists.postgresql.org; Wed, 06 Aug 2025 21:46:38 +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 576LkW3o1457433; Wed, 6 Aug 2025 17:46:32 -0400 From: Tom Lane To: "David G. Johnston" cc: Rumpi Gravenstein , Laurenz Albe , PostgreSQL Subject: Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array In-reply-to: References: <1934172.1753462470@sss.pgh.pa.us> <1936547.1753463422@sss.pgh.pa.us> <1940680.1753465819@sss.pgh.pa.us> <1943137.1753467040@sss.pgh.pa.us> <2223785.1753476729@sss.pgh.pa.us> Comments: In-reply-to "David G. Johnston" message dated "Wed, 06 Aug 2025 14:35:24 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <1457431.1754516792.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 06 Aug 2025 17:46:32 -0400 Message-ID: <1457432.1754516792@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Wednesday, August 6, 2025, Rumpi Gravenstein wrote: >> Here's a reproducible test case that causes the problem in different >> schemas. The issue appears to be related to creating a table and a >> function that has the same name as the table with a prepended underscore. > Don’t do that. Naming a function (action) and table (noun) the same seems > unwise anyway, underscores or no. Yeah. The chain of events here is: * A table has a matching composite type with the same name as the table. * The composite type also has an associated array type, which will normally be named as the composite type's name with a prepended underscore. * For any type name, the syntax "type_name(argument)" is understood as a possible request to cast to that type, the same as "argument::type_name". There are restrictions on whether that interpretation will be applied, but none of them keep you out of trouble in this example. This is all covered in our documentation, though not all in one place. Perhaps we'd think twice about some of these choices if we were redesigning in a green field; but these are things that Postgres has done for decades and we'd surely break applications if we changed them now. regards, tom lane