Re: Proposal to improve uniq function documentation in intarray extension

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: martin(dot)kalcher(at)aboutsource(dot)net
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Proposal to improve uniq function documentation in intarray extension
Date: 2022-06-03 15:34:21
Message-ID: 219445.1654270461@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

PG Doc comments form <noreply(at)postgresql(dot)org> writes:
> The **uniq** function in the **intarray** extension removes **adjacent**
> duplicates from an integer array. The documentation[0] about this behavior
> is correct, but the example is a bit misleading, because it sorts the array
> before applying uniq. The sort can be overlooked **easily** and leads to the
> impression that **uniq** removes all duplicates from the array.

> I propse to change the example to somthing like that:

> uniq('{1,2,2,3,1,1}'::integer[]) → {1,2,3,1}

You have a point, but the example of use with sort() is pretty useful in
its own right, particularly for people for whom "blah blah | sort | uniq"
is not second nature. Fortunately, there's no longer any reason we have
to limit ourselves to one example. I propose this:

diff --git a/doc/src/sgml/intarray.sgml b/doc/src/sgml/intarray.sgml
index f930c08eeb..18c6f8c3ba 100644
--- a/doc/src/sgml/intarray.sgml
+++ b/doc/src/sgml/intarray.sgml
@@ -131,6 +131,11 @@
</para>
<para>
Removes adjacent duplicates.
+ Often used with <function>sort</function> to remove all duplicates.
+ </para>
+ <para>
+ <literal>uniq('{1,2,2,3,1,1}'::integer[])</literal>
+ <returnvalue>{1,2,3,1}</returnvalue>
</para>
<para>
<literal>uniq(sort('{1,2,3,2,1}'::integer[]))</literal>

regards, tom lane

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Daniel Gustafsson 2022-06-03 17:05:57 Re: Proposal to improve uniq function documentation in intarray extension
Previous Message jian he 2022-06-03 07:31:18 Re: pg_stat_database view column xact_commit description should be more descriptive?