Re: Wrong type for the left argument of the operator "|/" and "||/" in chapter 9.3 - Mailing list pgsql-docs

From Tom Lane
Subject Re: Wrong type for the left argument of the operator "|/" and "||/" in chapter 9.3
Date
Msg-id 2938565.1619639893@sss.pgh.pa.us
Whole thread Raw
In response to Wrong type for the left argument of the operator "|/" and "||/" in chapter 9.3  (PG Doc comments form <noreply@postgresql.org>)
List pgsql-docs
PG Doc comments form <noreply@postgresql.org> writes:
> The left argument of the operator square root |/ and cube root ||/ in the
> current documentation is double precision. But to my experience that should
> also work on any numeric types including smallint, integer, bigint, real and
> numeric. I have tested it on both PostgreSQL server 12 and 13.

The docs are correct.  There is only one instance of these operators, and
it takes double precision, as you can easily verify in psql:

postgres=# \do |/
                                   List of operators
   Schema   | Name | Left arg type |  Right arg type  |   Result type    | Description
------------+------+---------------+------------------+------------------+-------------
 pg_catalog | |/   |               | double precision | double precision | square root
(1 row)

postgres=# \do ||/
                                   List of operators
   Schema   | Name | Left arg type |  Right arg type  |   Result type    | Description
------------+------+---------------+------------------+------------------+-------------
 pg_catalog | ||/  |               | double precision | double precision | cube root
(1 row)

The reason those other types are accepted is implicit casting, not
that the operator takes something else than what's documented.
But we're not going to clutter the function/operator tables with
annotations about what other inputs can be accepted via casts ---
it'd be bulky, repetitive, and probably more confusing than
helpful.

            regards, tom lane



pgsql-docs by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: Clarify how triggers relate to transactions
Next
From: PG Doc comments form
Date:
Subject: pl/pgsql errors when multi-dimensional arrays are used