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 1n6wLr-0004XG-SQ for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Jan 2022 15:12:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n6wLq-0004PW-KZ for pgsql-bugs@arkaria.postgresql.org; Mon, 10 Jan 2022 15:12:50 +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 1n6wBQ-0007QB-Pc for pgsql-bugs@lists.postgresql.org; Mon, 10 Jan 2022 15:02:04 +0000 Received: from marvin.harmless.hu ([195.56.55.204]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n6wBN-0005QZ-Pd for pgsql-bugs@lists.postgresql.org; Mon, 10 Jan 2022 15:02:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=harmless.hu ; s=marvin; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=eeKGH6SguDjfRyGpOC7qsOeLdcnzdvrOlPGfsdzr+tg=; b=V3g0boQj/GzwjRe4Esh2niulFy cSsNd2rkDMEYN9+KUG83Nhotu/ctR50/2axI7yoUiRsuMW/xHAFw6IY8tZYHJjGz9rgd5dbyCRL9s 9UsDBTZt0MZM0uHX5BZhvAoOAz0lkoKQEXNRK2SqnOOtHlTBBaHVSqu2epT2M2t8rnE4=; Received: from 94-21-27-221.pool.digikabel.hu ([94.21.27.221] helo=[10.219.18.1]) by marvin.harmless.hu with esmtpsa (TLS1.3) tls TLS_AES_128_GCM_SHA256 (envelope-from ) id 1n6wBJ-000NMH-Mi; Mon, 10 Jan 2022 15:01:58 +0000 Message-ID: <8e04a7ec-4e55-aed2-de88-ac6fe6a74d8b@harmless.hu> Date: Mon, 10 Jan 2022 16:01:56 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Subject: Re: BUG #17360: array_to_string should be immutable instead of stable Content-Language: en-US To: Tom Lane Cc: pgsql-bugs@lists.postgresql.org References: <17360-a50d754b72a97cad@postgresql.org> <2187793.1641826463@sss.pgh.pa.us> From: Gergely Czuczy In-Reply-To: <2187793.1641826463@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-HD-Spam-Score: -0.1 X-HD-Spam-Report: Action: no action Symbol: ARC_NA(0.00) Symbol: RCVD_VIA_SMTP_AUTH(0.00) Symbol: FROM_HAS_DN(0.00) Symbol: TO_DN_SOME(0.00) Symbol: TO_MATCH_ENVRCPT_ALL(0.00) Symbol: MIME_GOOD(-0.10) Symbol: RCPT_COUNT_TWO(0.00) Symbol: NEURAL_HAM(-0.00) Symbol: RCVD_COUNT_ONE(0.00) Symbol: FROM_EQ_ENVFROM(0.00) Symbol: MIME_TRACE(0.00) Symbol: ASN(0.00) Symbol: RCVD_TLS_ALL(0.00) Symbol: MID_RHS_MATCH_FROM(0.00) Message-ID: 8e04a7ec-4e55-aed2-de88-ac6fe6a74d8b@harmless.hu List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello, Thanks for explaining Tom, I wasn't aware these things on the internals. Wouldn't it possible to add polymorphs for immutable types, like func(text[]), func(int[]), etc, mark those immutable, and keep the generic for all the other not-explicitly-dealt-with types as stable? Again, I don't really know the implementation details here, so it's just my tuppence. Thanks again for explaining it. Regards, Gergely On 2022. 01. 10. 15:54, Tom Lane wrote: > 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