X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 6EF88D1B20E for ; Wed, 16 Jun 2004 12:49:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 93563-04 for ; Wed, 16 Jun 2004 15:49:08 +0000 (GMT) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by svr1.postgresql.org (Postfix) with ESMTP id 769EAD1B170 for ; Wed, 16 Jun 2004 12:49:06 -0300 (ADT) Received: (from mail@localhost) by martin.sysdetect.com (8.11.4/8.11.3) id i5GBpW711066 for ; Wed, 16 Jun 2004 11:51:32 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdXa9574; Wed Jun 16 11:51:29 2004 Received: from sysd.com (thriller.sysdetect.com [172.16.1.33]) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id i5GFn2b07642 for ; Wed, 16 Jun 2004 11:49:02 -0400 Message-ID: <40D06BEC.3060102@sysd.com> Date: Wed, 16 Jun 2004 11:49:00 -0400 From: Rich Cullingford User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: Problems creating indexes with IMMUTABLE functions Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200406/44 X-Sequence-Number: 4972 All, It appears that the use of certain kinds of functions on columns to create indexes is disabled in PG 7.4.1 (on RH 8.0 3.2-7). An attempt to create an index on the concatenation of a date and an int gives: sysd=> create index bnoz_idx on evidence (bnoz(alert_date, period)); ERROR: functions in index expression must be marked IMMUTABLE although: sysd=> select provolatile, prosrc from pg_proc where proname='bnoz'; provolatile | prosrc -------------+------------------------------------------------------------------------------------------------------------------------------------------------ i | declare hr alias for $2; pad text := '0'; begin if hr<10 then return $1 || ' ' || pad || hr; end if; return $1 || ' ' || hr; end; That is, the function is IMMUTABLE according to the catalog. The problem appears to be with the date field: sysd=> create index bnoz_idx on evidence ((alert_date || ' ' || period)); ERROR: functions in index expression must be marked IMMUTABLE though: sysd=> create index bnoz_idx on evidence ((service || ' ' || period)); CREATE INDEX works, where 'service' is a text column. I've searched the lists for indciations of this problem, and have failed to find anything. Does this ring a bell with anyone? Sincerely, Rich Cullingford rculling@sysd.com