Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSRum-0002x6-Ov for pgsql-sql@arkaria.postgresql.org; Sun, 19 May 2019 19:56:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hSRul-0004zv-32 for pgsql-sql@arkaria.postgresql.org; Sun, 19 May 2019 19:56:11 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSRuk-0004uT-Np for pgsql-sql@lists.postgresql.org; Sun, 19 May 2019 19:56:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hSRui-0004HT-93 for pgsql-sql@postgresql.org; Sun, 19 May 2019 19:56:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x4JJtsOu007512; Sun, 19 May 2019 15:55:54 -0400 From: Tom Lane To: Larry Rosenman cc: pgsql-sql@postgresql.org Subject: Re: create index on a jsonb timestamp field? In-reply-to: <8b5563be3bf7f0ae9826b223b61fa22d@lerctr.org> References: <78a5d1232bb5ef5797a8ae6e1f23543f@lerctr.org> <29956.1558228655@sss.pgh.pa.us> <8b5563be3bf7f0ae9826b223b61fa22d@lerctr.org> Comments: In-reply-to Larry Rosenman message dated "Sun, 19 May 2019 14:37:55 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7510.1558295754.1@sss.pgh.pa.us> Date: Sun, 19 May 2019 15:55:54 -0400 Message-ID: <7511.1558295754@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Larry Rosenman writes: > On 05/18/2019 8:17 pm, Tom Lane wrote: >> BTW, I'd had the idea that the GENERATED option in PG v13 would allow >> setting up this sort of case without bothering with a handwritten >> trigger, but it seems not: >> >> regression=# create table foo(data jsonb, ts timestamptz GENERATED >> ALWAYS AS ((data->>'ts')::timestamptz) stored); >> psql: ERROR: generation expression is not immutable >> >> I wonder if that's really necessary to insist on? > Good question. Is that something the project is going to look into? Well, I was just asking the question, not opining on whether it was right or wrong. GENERATED is a SQL-spec feature, and it might be that the semantics the spec calls for wouldn't work without the restriction. I've not looked... regards, tom lane