Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6w4B-0003wx-Ag for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Jan 2022 14:54:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n6w49-0004lh-WD for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Jan 2022 14:54:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6w49-0004lY-Jf for pgsql-bugs@lists.postgresql.org; Mon, 10 Jan 2022 14:54:33 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6w47-0005M9-Df for pgsql-bugs@lists.postgresql.org; Mon, 10 Jan 2022 14:54:32 +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 20AEsNq32187794; Mon, 10 Jan 2022 09:54:24 -0500 From: Tom Lane To: gergely.czuczy@harmless.hu cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17360: array_to_string should be immutable instead of stable In-reply-to: <17360-a50d754b72a97cad@postgresql.org> References: <17360-a50d754b72a97cad@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Mon, 10 Jan 2022 10:47:26 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2187792.1641826463.1@sss.pgh.pa.us> Date: Mon, 10 Jan 2022 09:54:23 -0500 Message-ID: <2187793.1641826463@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > The array_to_string function should have a volatility of immutable, Nope. It invokes an arbitrary datatype I/O function, which might only be stable. As an example: regression=# begin; BEGIN regression=*# select array_to_string(array[now()], ','); array_to_string ------------------------------- 2022-01-10 09:47:06.605304-05 (1 row) regression=*# set timezone to UTC; SET regression=*# select array_to_string(array[now()], ','); array_to_string ------------------------------- 2022-01-10 14:47:06.605304+00 (1 row) Actually, in principle somebody could make a datatype whose output function is volatile. It's not clear what the use-case is, though, so we've established a project policy that code that invokes some arbitrary I/O function may assume that function is at least stable. Thus, array_to_string() is marked stable, and likewise for some other polymorphic functions such as format(). Ideally, perhaps, we'd determine the volatility level of polymorphic functions like array_to_string() based on the actual input data types --- but it's hard to see how to do that. regards, tom lane