Re: Array behavior oddities

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: Array behavior oddities
Дата
Msg-id 200803261443.m2QEhnM21931@momjian.us
обсуждение исходный текст
Ответ на Re: Array behavior oddities  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:
> Bruce Momjian <bruce@momjian.us> writes:
> >   If any dimension is written as a slice, i.e. contains a colon, then all
> >   dimensions are treated as slices.
>
> > Is the the behavior of assuming an entry with no colon is a slice what
> > we want, or are we just stuck with it?
>
> Why do you find that surprising?  It's either a slice or it isn't,
> there's no halfway point.  Are you proposing to throw an error if only
> some of the subscripts have colons?  What would be the point?
>
> > Is there a reason out-of-bounds array accesses behave differently for
> > slices and non-slices?
>
> History (although "sloppy original implementation" would do too).  I'm
> not sure if we should try to clean it up --- there've not been that many
> complaints, but I'm sure we'd get complaints from people whose code
> stopped working, if we change it.

I have updated the documention (patch attached) to be clearer on the odd
array slice behavior.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://postgres.enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: doc/src/sgml/array.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/array.sgml,v
retrieving revision 1.62
diff -c -c -r1.62 array.sgml
*** doc/src/sgml/array.sgml    7 Jun 2007 14:49:56 -0000    1.62
--- doc/src/sgml/array.sgml    26 Mar 2008 14:42:14 -0000
***************
*** 258,263 ****
--- 258,266 ----
   {{meeting,lunch},{training,presentation}}
  (1 row)
  </programlisting>
+
+   To avoid confusion with slices, use slice syntax for all dimmension
+   references, e.g.  <literal>[1:2][1:1]</>, not <literal>[2][1:1]</>.
   </para>

   <para>
***************
*** 275,281 ****
    any of the subscript expressions are null.  However, in other corner
    cases such as selecting an array slice that
    is completely outside the current array bounds, a slice expression
!   yields an empty (zero-dimensional) array instead of null.
    If the requested slice partially overlaps the array bounds, then it
    is silently reduced to just the overlapping region.
   </para>
--- 278,285 ----
    any of the subscript expressions are null.  However, in other corner
    cases such as selecting an array slice that
    is completely outside the current array bounds, a slice expression
!   yields an empty (zero-dimensional) array instead of null.  (This
!   does not match non-slice behavior and is done for historical reasons.)
    If the requested slice partially overlaps the array bounds, then it
    is silently reduced to just the overlapping region.
   </para>

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Surfacing qualifiers
Следующее
От: "Zubkovsky, Sergey"
Дата:
Сообщение: Re: [DOCS] pg_total_relation_size() and CHECKPOINT