date_trunc not immutable

Поиск
Список
Период
Сортировка
От Ravi Krishna
Тема date_trunc not immutable
Дата
Msg-id 1544916384.3079614.1610261080.7F8C1B97@webmail.messagingengine.com
обсуждение исходный текст
Ответы Re: date_trunc not immutable
Re: date_trunc not immutable
Список pgsql-general
Version: PG 10.6 on AWS Linux.

I am trying to create an index on function date_trunc('month',timestamp)

PG is complaining that the function must be marked as IMMUTABLE.  So I assume that date_trunc is not marked as immutable.

Definition of immutable from PG documentation
====================================

All functions and operators used in an index definition must be "immutable", that is, their results must depend only on their arguments and never on any outside influence (such as the contents of another table or the current time). This restriction ensures that the behavior of the index is well-defined. To use a user-defined function in an index expression or WHERE clause, remember to mark the function immutable when you create it.
===================================
What am I missing?  date_trunc will always return the same value for a given value. Not sure how I can mark a PG function as immutable.  

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

Предыдущее
От: Ron
Дата:
Сообщение: Re: simple query on why a merge join plan got selected
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: date_trunc not immutable