Cannot create index on Jsonb timestamp field

From: "Raschkowski, Michael" <michael(dot)raschkowski(at)auconet-it(dot)com>
To: <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Cannot create index on Jsonb timestamp field
Date: 2020-01-13 14:41:33
Message-ID: 002401d5ca1f$8d4d2da0$a7e788e0$@auconet-it.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi,

I am checking the possibilities of using jsonb fields and can’t create index
on jsonb element if I cast it to timestamp with time zone:

drop table if exists test_json;

create table test_json (j jsonb);

insert into test_json select jsonb_build_object('id',1,'time',
now()::timestamptz);

--OK

create index test_json_idx1 on test_json(((j->>'id')::integer));

--ERROR

create index test_json_idx2 on test_json(((j->>'time')::timestamptz));

The message is :

ERROR: FEHLER: Funktionen im Indexausdruck müssen als IMMUTABLE markiert
sein

SQL state: 42P17

Viele Grüße / Kind regards,

Dr. Michael Raschkowski
Software Architect

Auconet GmbH - ein Unternehmen der Beta Systems Gruppe
An den Treptowers 1, 12435 Berlin
Phone: +49 30 254 690-0
Fax: +49 30 254 690-199
Email: <mailto:michael(dot)raschkowski(at)auconet-it(dot)com>
michael(dot)raschkowski(at)auconet-it(dot)com
<http://www.auconet-it.com/> www.auconet-it.com

Mandatory Information for business emails according to German trade laws /
Pflichtangaben für geschäftliche E-mails gemäß Handelsgesetzbuch:

Auconet GmbH - ein Unternehmen der Beta Systems Gruppe
An den Treptowers 1
12435 Berlin
Germany
Phone: +49-(0)30-254 690-0
Fax: +49-(0))30-254 690-199
<mailto:info(at)auconet-it(dot)com> info(at)auconet-it(dot)com
<http://www.auconet-it.com/> www.auconet-it.com

Management / Geschäftsführer: Hartmut Bolten, Sebastian Zang
Legal form / Rechtsform: GmbH | Registered office / Sitz: Berlin
Commercial register / Handelsregister: Amtsgericht Charlottenburg HRB 141
887 B
VAT-ID / Ust-ID-Nr.: DE316422231 | Tax No. / St.-Nr.: 30/036/75431
Bank / Bankverbindung: Commerzbank AG, BIC: COBADEFF, IBAN: DE25 1004 0000
0230 9391 00

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2020-01-13 15:56:47 Re: Cannot create index on Jsonb timestamp field
Previous Message Jobin Augustine 2020-01-13 14:37:06 Re: libpq parameter parsing problem