Re: analyze-error: "cannot compare arrays of different element types" revisited

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: analyze-error: "cannot compare arrays of different element types" revisited
Дата
Msg-id 23983.1103317585@sss.pgh.pa.us
обсуждение исходный текст
Ответ на analyze-error: "cannot compare arrays of different element types" revisited  ("Florian G. Pflug" <fgp@phlo.org>)
Список pgsql-general
"Florian G. Pflug" <fgp@phlo.org> writes:
> A few weeks ago, I reported that ANALYZE gives the error
> "cannot compare arrays of different element types"
> in one of my databases.

> I now constructed a small testcase that is able to reproduce the problem:

Thanks for the example.  It turns out array_map() thought it could just
return an empty input array unmodified, so the implicit coercion from
int4[] to int8[] didn't do what it was supposed to, and then things go
downhill :-(.  array_map() was correct when it was written, but it
didn't get updated properly when we added type OIDs to array headers.
Here's the patch against 7.4, if you need it.

            regards, tom lane

Index: arrayfuncs.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v
retrieving revision 1.100.2.1
diff -c -r1.100.2.1 arrayfuncs.c
*** arrayfuncs.c    8 Jun 2004 20:28:29 -0000    1.100.2.1
--- arrayfuncs.c    17 Dec 2004 20:48:49 -0000
***************
*** 2063,2069 ****

      /* Check for empty array */
      if (nitems <= 0)
!         PG_RETURN_ARRAYTYPE_P(v);

      /*
       * We arrange to look up info about input and return element types
--- 2063,2075 ----

      /* Check for empty array */
      if (nitems <= 0)
!     {
!         /* Return empty array */
!         result = (ArrayType *) palloc0(sizeof(ArrayType));
!         result->size = sizeof(ArrayType);
!         result->elemtype = retType;
!         PG_RETURN_ARRAYTYPE_P(result);
!     }

      /*
       * We arrange to look up info about input and return element types

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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: sorting problem
Следующее
От: Bruno Wolff III
Дата:
Сообщение: Re: sorting problem