Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZG8SA-0007cd-32 for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Jul 2015 16:25:38 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZG8S9-00087V-AT for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Jul 2015 16:25:37 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZG8RW-0007Ky-E2 for pgsql-bugs@postgresql.org; Fri, 17 Jul 2015 16:24:58 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZG8RS-0004aZ-VQ for pgsql-bugs@postgresql.org; Fri, 17 Jul 2015 16:24:57 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t6HGOp8w024450; Fri, 17 Jul 2015 12:24:51 -0400 From: Tom Lane To: "David G. Johnston" cc: "tgpfeiffer@web.de" , "pgsql-bugs@postgresql.org" Subject: Re: BUG #13504: Types in math functions table is incorrect In-reply-to: References: <20150717014156.2347.3066@wrigleys.postgresql.org> Comments: In-reply-to "David G. Johnston" message dated "Fri, 17 Jul 2015 12:00:59 -0400" Date: Fri, 17 Jul 2015 12:24:51 -0400 Message-ID: <24449.1437150291@sss.pgh.pa.us> X-Pg-Spam-Score: -3.1 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org "David G. Johnston" writes: > On Thursday, July 16, 2015, wrote: >> On http://www.postgresql.org/docs/9.4/static/functions-math.html in Table >> 9-3 there is a number of issues in the "Return Type" column. >> >> For example: >> - for ln it says "same as input", but the output is actually double >> precision (both when checked with two eyes and `pg_typeof`) >> - same for log >> - for sign it says "same as input" but the output is actually numeric >> >> I have not checked all of the functions in that table, but at least the >> ones above need to be fixed, I think. > It would be helpful if you supplied the queries you used to make these > determinations. I think the OP is misreading the table and/or failing to note the statement above it: "Many of these functions are provided in multiple forms with different argument types. Except where noted, any given form of a function returns the same data type as its argument." For example, ln() comes in exactly two forms: postgres=# \df ln List of functions Schema | Name | Result data type | Argument data types | Type ------------+------+------------------+---------------------+-------- pg_catalog | ln | double precision | double precision | normal pg_catalog | ln | numeric | numeric | normal (2 rows) which is what the table says. What the table does *not* say is "ln of any random numeric-category datatype returns that same type". This would clearly be unworkable if the input is integer, for instance. What actually will happen is that the input will be cast to one of these two types and then the function returns that type. A more reasonable complaint would be "it's not very clear which alternative gets picked when I pass a value that's not either double precision or numeric". Which is fair, because I don't think the detailed behavior of the built-in collection of casts is really documented anyplace. You can infer it if you study the contents of pg_cast, but ... regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs