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 1ufPHV-006rFO-VH for pgsql-general@arkaria.postgresql.org; Fri, 25 Jul 2025 20:44:42 +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 1ufPHV-004eLY-0T for pgsql-general@arkaria.postgresql.org; Fri, 25 Jul 2025 20:44:41 +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 1ufPHU-004eLO-Lg for pgsql-general@lists.postgresql.org; Fri, 25 Jul 2025 20:44:40 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ufPHT-000mA7-0y for pgsql-general@lists.postgresql.org; Fri, 25 Jul 2025 20:44:40 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3b77683cc5bso749936f8f.1 for ; Fri, 25 Jul 2025 13:44:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1753476276; x=1754081076; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=39nPKW/UZ3rmRIDML4ZhmAp2kP4/ATwO4Hw1KVMW64Y=; b=Lj13t/C+UkjZEsi5J/NwpN04lkcUHs5G2GutTkDzi2YK9wlelr182ihR3xwbEmSulN 24z7xlPg5WOXBoGZnMTKzgadRcjRW41fogUii974yxYKi+6ztvB3CViuIamTX9L62CF9 MvWY5kGKKKVTQDqptUx4MdxtzJFVll0sk07oUcDfet5LW2far6hCQsug2ToSROGaNNZ8 +Kp/oInunaqK1EQnH6dXKh7FiJcehDi8JDbgWuMqUjftsfXP6CYjG/QK+AOLHbQ9R89F v/5nrPLQ8lyzLuaWifjfAfaP4tGuq3oAqRNDjtFgXohupU3ojE5pQEJqASrhcjH5bVY8 OI3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753476276; x=1754081076; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=39nPKW/UZ3rmRIDML4ZhmAp2kP4/ATwO4Hw1KVMW64Y=; b=I5J5sdtmiU9Vjvs12AnVU9QKvd6bTPwNdmix49Y8LskD++jPvdgpF2uL6GyGmKZcCE 44h/vRjnyf3PDbVNqSGJHDar+g9CoSpbeHLCcLv4pGYec28cD+iBQU+xVgIK4jvYRwKl AJWZ0456z/Wq2Sx3mIfVS6wuKfjmqN/pPhDYjBSFss8RxYax8kZ72CnTUjcIFXJaV47m IEW6NgGDDhi2ttp7HIAJnTA0cGZk0MyoskmwoJbBCMT/dzf/dmKcx2+cxGG53UuQqfda eNwLPhO7r/AETr9XL82gpMc84VoqPtIefCO2Pc5FtjcDHYljeTpK/WQQeGzEMtcYpXX5 Q+zQ== X-Gm-Message-State: AOJu0YyhtXkjgBHxrO7uXEZFkPxjzVCDKpHaMIpbvloexiDQkjh6MukQ y6OQM1i0gAtvpxn6VL65AJc7sLm8DEBkdNTIjNvnf1Wez8dzEwYst5qHgg2CGqg3j1AF7raK6JI N3Lzk X-Gm-Gg: ASbGncvEjjcHmPyTNDJLvcC24HIUPysZBhviZl2qxxq33SAit2Jz8sE8oBmdBHuzo58 nQKi52TjNULYXoXpFtP7XAp//OClnA120cD+rHsaPP9NIANDi3/9b/mg6Tl2Hqk6y2Yq5kfl2sI hlBUlCPqpXTjlaECxo94JBVdHNbzc/lrzCiZRDtLKFJG93buLGotrEyoFWUVuSFES3X6xMYXGqb ZTY3rx7S9LoJBAtlL++qb03O/6efTUvOOHuXz+8sLzc3gmlCSWVPIMam0dGnEDODrFcfOKWM036 zoUFhKJ/QdLZcvtXt4mVgWAGqCBSkr1LccX6DpfBMtPupokLNNKugitRYoreLd6g7cnFepVnQhK DGbKqlSSk2LyhOb2wOY6T9mHuO7V4D8Hw0DQI6k2MYwX9HB9IaXWZuNHQXOKI0g== X-Google-Smtp-Source: AGHT+IGWIPjYu0891b+VjYF2XHKzkgo7/lv+du2O5E6XqJVCTAO+G8tis1jMK8JE4dT+e77E0CiJ0g== X-Received: by 2002:a05:6000:22c4:b0:3a4:dd16:a26d with SMTP id ffacd0b85a97d-3b776646911mr2544319f8f.38.1753476276100; Fri, 25 Jul 2025 13:44:36 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:255:ce84:8917:ad95:e45:f3d]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b778eba85asm782290f8f.29.2025.07.25.13.44.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jul 2025 13:44:35 -0700 (PDT) Message-ID: Subject: Re: PostgreSQL Bug with simple function unexpectedly treating varchar parameter as an array From: Laurenz Albe To: Tom Lane , Rumpi Gravenstein Cc: PostgreSQL Date: Fri, 25 Jul 2025 22:44:35 +0200 In-Reply-To: <1943137.1753467040@sss.pgh.pa.us> 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> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-1.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2025-07-25 at 14:10 -0400, Tom Lane wrote: > After looking at the code I remembered that the parser might be taking > this as a type coercion request.=C2=A0 With that idea, I can duplicate th= e > observed behavior like so: >=20 > regression=3D# select _sa_setup_role('af_repo_app'); > INFO:=C2=A0 af_repo_app > =C2=A0_sa_setup_role=20 > ---------------- > =C2=A0Done > (1 row) >=20 > regression=3D# create domain _sa_setup_role as varchar[]; > CREATE DOMAIN > regression=3D# select _sa_setup_role('af_repo_app'); > ERROR:=C2=A0 malformed array literal: "af_repo_app" > LINE 1: select _sa_setup_role('af_repo_app'); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 ^ > DETAIL:=C2=A0 Array value must start with "{" or dimension information. >=20 > So ... any chance you have a data type named _sa_setup_role? ... it could also be a type "sa_setup_role", and "_sa_setup_role" is interpreted as the corresponding array type: CREATE DOMAIN sa_setup_role AS varchar; 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. Yours, Laurenz Albe