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 1ufLgj-0062Q7-TT for pgsql-general@arkaria.postgresql.org; Fri, 25 Jul 2025 16:54:30 +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 1ufLgi-002n6Q-QX for pgsql-general@arkaria.postgresql.org; Fri, 25 Jul 2025 16:54:29 +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 1ufLgh-002n6I-PV for pgsql-general@lists.postgresql.org; Fri, 25 Jul 2025 16:54:28 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1ufLge-000kZq-0s for pgsql-general@lists.postgresql.org; Fri, 25 Jul 2025 16:54:25 +0000 Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfhigh.stl.internal (Postfix) with ESMTP id 0E2637A0AE8; Fri, 25 Jul 2025 12:54:23 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Fri, 25 Jul 2025 12:54:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; 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=1753462462; x=1753548862; bh=Qhg7TID/qHxu24e06OCRDCH5Zr1JeFf7baVWBBnY5Ck=; b= ZV8yUKEd0wCZ9mboQR8oT/l27KFVPo9Zu5l/X7snPTMj+zrE5OKNMXMSh6uK1u1G eumdKBe+quhjHM1qKv03P1PJKb3IqCMqrXPVblULX3jOuCEZihG/dCufXhMXyv3s fcJhYxShhpMGXyuKmDzCy2lo1erLKBPvEfdVSOlfsXlhh4dulBCtRp1TYsgvu41C IhfgqPfPdxfQATEa4ZlbEs/CD90cyByUbTRmJqWEZn1jUDatQtWRvATO9KjIpt+F ZtI7d3z8xnes41Ra3RgbJx05hYMFhLA3rU4pBiUYOyM7F3PYu39rxkR/dHUm0EqC iSgaqeLIC2zDjRskYsMtqA== 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=1753462462; x=1753548862; bh=Q hg7TID/qHxu24e06OCRDCH5Zr1JeFf7baVWBBnY5Ck=; b=Izz5OFDUc14++X02e lrY5YdsUnq441wjoLrtO3dwDTOOyaxyOBFhcqXkkZujN3O+2Bn0lZSTk3tSLuODK nODgjv95lB29wLVx/wZZOjHs8SCvXmtdmP2ooKKezc/qfBPpE9k0YfyhHCWfx98D RryYEuSeGAO5e0XFEDszWOuyp5m//qklWYTKbs3/cbBophNucdBtvKvAz1EcDLIv tJhlUojCnl90IIw0P/BGscY8Y9ugxrt/G7t0522RtTg1JN7apRSjWlD8pred9WNn 9n0QufUSlSOMiMBYpHA7wH4NxuP3oqig4q2B4JS2aGSyaTCyjQhpu7X4+K8ZxagA bJzGw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgdekgedtiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughrihgrnhcu mfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomheqne cuggftrfgrthhtvghrnhepffelgeeifefgveduhedthfekuedtffejveegffegjeevtdeh gfduieetfeehjeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnhgspghr tghpthhtohepvddpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtoheprhhgrhgrvhgvnh hssehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhi shhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 25 Jul 2025 12:54:22 -0400 (EDT) Message-ID: <7da90478-4ea9-47e6-ac22-40689b8d9ff4@aklaver.com> Date: Fri, 25 Jul 2025 09:54:21 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array To: Rumpi Gravenstein , PostgreSQL References: Content-Language: en-US From: Adrian Klaver In-Reply-To: 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 7/25/25 09:36, Rumpi Gravenstein wrote: > PostgreSQL Experts, > > I've been confound by the following behavior that I see in one of our > PostgreSQL 16 instances.  In this case I am running this script from psql. > > --------------------------------------------------------------------------------------------------------- > xxxx_pub_dev_2_db=# SELECT version(); >                                                  version > --------------------------------------------------------------------------------------------------------- >  PostgreSQL 16.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 > 20210514 (Red Hat 8.5.0-26), 64-bit > (1 row) > > xxxx_pub_dev_2_db=# SHOW server_version; >  server_version > ---------------- >  16.9 > (1 row) > > xxxx _pub_dev_2_db=# DROP FUNCTION if exists _sa_setup_role; > DROP FUNCTION > xxxx _pub_dev_2_db=# CREATE OR REPLACE FUNCTION > _sa_setup_role( p_role_to_be_granted varchar) > xxxx _pub_dev_2_db-# RETURNS varchar > xxxx _pub_dev_2_db-#     LANGUAGE plpgsql > xxxx _pub_dev_2_db-# AS > xxxx _pub_dev_2_db-# $function$ > xxxx _pub_dev_2_db $# declare > xxxx _pub_dev_2_db$# begin > xxxx _pub_dev_2_db$# raise info '%',p_role_to_be_granted::varchar; > xxxx _pub_dev_2_db$#   return('Done'); > xxxx _pub_dev_2_db$# end; > xxxx _pub_dev_2_db$# $function$; > CREATE FUNCTION > xxxx _pub_dev_2_db=# select _sa_setup_role('af_repo_app'); > ERROR:  malformed array literal: "af_repo_app" > LINE 1: select _sa_setup_role('af_repo_app'); >                               ^ > DETAIL:  Array value must start with "{" or dimension information. > xxxx _pub_dev_2_db=#select _sa_setup_role('af_repo_app'::varchar); > INFO:  af_repo_app >  _sa_setup_role > ---------------- >  Done > (1 row) > > I've been able to run the same script with no issues in other PostgreSQL > databases, just not this one. > > Thoughts? You have more then on version of _sa_setup_role in this database, one of which is looking for an array argument. In psql do \df *._sa_setup_role and see what it returns. > > Best Regards > -- > Rumpi Gravenstein -- Adrian Klaver adrian.klaver@aklaver.com