Re: Help with error date_trunc() function.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Help with error date_trunc() function.
Дата
Msg-id 1344783.1712335067@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [MASSMAIL]Help with error date_trunc() function.  (Miguel Angel Prada <mprada@hoplasoftware.com>)
Список pgsql-sql
Miguel Angel Prada <mprada@hoplasoftware.com> writes:
> I would need help to know what could be happening to cause the error 
> when using the /date_trunc/ function.

EXPLAIN would be informative, but I bet what is happening is that the
date_trunc condition is being pushed down to the scan of pg_class,
since it mentions no variables that aren't available there.  Then it
can get evaluated on tables whose names don't match the pattern you
expect.  I doubt it's more than luck that PG 15 isn't doing the
same thing.

The usual recommendation for fixing this kind of thing is to insert an
optimization fence to keep the WHERE clause from being pushed down.
You could add "OFFSET 0" in the sub-select, or convert it into a
materialized CTE.

            regards, tom lane



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

Предыдущее
От: Miguel Angel Prada
Дата:
Сообщение: [MASSMAIL]Help with error date_trunc() function.
Следующее
От: intmail01
Дата:
Сообщение: [MASSMAIL] Function can not use the 'NEW' variable as a direct parameter inside trigger function?