Thread

Commits

  1. Doc: clarify handling of duplicate elements in array containment tests.

  1. @> (contains)

    The Post Office <noreply@postgresql.org> — 2019-08-18T15:13:24Z

    The following documentation comment has been logged on the website:
    
    Page: https://www.postgresql.org/docs/9.6/functions-array.html
    Description:
    
    Hi.
    Noticed strange thin with @>
    Query "select '{1,2}'::int[] @> '{1,2,2,2,2,2,2,2}'::int[]" returns true,
    but first array contains even less elements then second.
    I think it's a bug in "contains" logic, but don't know where to submit it.
    
  2. Re: @> (contains)

    David G. Johnston <david.g.johnston@gmail.com> — 2019-08-18T16:19:58Z

    On Sun, Aug 18, 2019 at 8:53 AM PG Doc comments form <noreply@postgresql.org>
    wrote:
    
    > The following documentation comment has been logged on the website:
    >
    > Page: https://www.postgresql.org/docs/9.6/functions-array.html
    > Description:
    >
    > Hi.
    > Noticed strange thin with @>
    > Query "select '{1,2}'::int[] @> '{1,2,2,2,2,2,2,2}'::int[]" returns true,
    > but first array contains even less elements then second.
    > I think it's a bug in "contains" logic, but don't know where to submit it.
    >
    
    Its a valid interpretation of "contains", for this purpose each array is
    treated like a set (ignoring the cardinality of elements, and overall
    dimensionality), but it needs to be documented as behaving that way on that
    page.  I don't see that its documented anywhere for that matter.  The
    source code documents that dimensions are ignored but is silent on
    duplication of elements:
    
    array_contain_compare:
    /*-----------------------------------------------------------------------------
     * array overlap/containment comparisons
     * These use the same methods of comparing array elements as array_eq.
     * We consider only the elements of the arrays, ignoring dimensionality.
     *----------------------------------------------------------------------------
     */
    
    David J.
    
  3. Re: @> (contains)

    Tom Lane <tgl@sss.pgh.pa.us> — 2019-09-23T16:56:36Z

    "David G. Johnston" <david.g.johnston@gmail.com> writes:
    > On Sun, Aug 18, 2019 at 8:53 AM PG Doc comments form <noreply@postgresql.org>
    >> Noticed strange thin with @>
    >> Query "select '{1,2}'::int[] @> '{1,2,2,2,2,2,2,2}'::int[]" returns true,
    >> but first array contains even less elements then second.
    >> I think it's a bug in "contains" logic, but don't know where to submit it.
    
    > Its a valid interpretation of "contains", for this purpose each array is
    > treated like a set (ignoring the cardinality of elements, and overall
    > dimensionality), but it needs to be documented as behaving that way on that
    > page.
    
    Done now.
    
    			regards, tom lane