Exclusion constraint issue

Поиск
Список
Период
Сортировка
От Eric McKeeth
Тема Exclusion constraint issue
Дата
Msg-id AANLkTim7nhtRi_muWrVwxMwHey2E4uZpLXm_WEM9HQxD@mail.gmail.com
обсуждение исходный текст
Ответы Re: Exclusion constraint issue  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
I'm getting an error message that doesn't make sense to me. Using PostgreSQL 9.0.0 on CentOS 5.5.


Given the following table and function definitions

CREATE TABLE test3
(
  test3_id serial NOT NULL,
  fk_id integer,
  data_3 text,
  effect_date date NOT NULL,
  expire_date date NOT NULL,
  CONSTRAINT test3_pkey PRIMARY KEY (test3_id)
)

CREATE OR REPLACE FUNCTION period(timestamp with time zone, timestamp with time zone)
  RETURNS period AS
$BODY$
    SELECT CASE WHEN $1 <= $2
    THEN ($1, $2)::period
    ELSE ($2, $1)::period END;
$BODY$
  LANGUAGE sql IMMUTABLE STRICT


and the period datatype with it's associated functions and operators installed from http://pgfoundry.org/projects/timespan/

why would I get the following error, since the period() function is in fact declared as immutable?

test=# ALTER TABLE test3 ADD exclude using gist(period(effect_date::timestamptz, expire_date::timestamptz) with && );
ERROR:  functions in index expression must be marked IMMUTABLE

Thanks in advance for any assistance.
-Eric

В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Trade Study on Oracle vs. PostgreSQL
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Exclusion constraint issue