Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id CF738632A39 for ; Mon, 8 Mar 2010 02:45:58 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 46089-09 for ; Mon, 8 Mar 2010 06:45:46 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from calpacs.org (calpacs.org [69.174.246.238]) by mail.postgresql.org (Postfix) with ESMTP id 37F4E6322F9 for ; Mon, 8 Mar 2010 02:45:47 -0400 (AST) Received: from new.calpacs.org (localhost.localdomain [127.0.0.1]) by calpacs.org (8.13.8/8.13.8) with ESMTP id o286jOZU023881; Mon, 8 Mar 2010 00:45:25 -0600 Received: from [192.168.1.4] (pool-173-55-140-58.lsanca.fios.verizon.net [173.55.140.58]) by calpacs.org (Scalix SMTP Relay 11.4.6.13676) via ESMTP; Mon, 08 Mar 2010 00:45:24 -0600 (CST) Date: Sun, 7 Mar 2010 22:45:22 -0800 From: Noel Proffitt To: Josh Berkus cc: pgsql-testers@postgresql.org Message-ID: <1268030722.6076.131.camel@keg> In-Reply-To: <4B94320B.9000804@agliodbs.com> References: <1267589227.25740.25.camel@keg> References: <4B92FD12.9070307@agliodbs.com> References: <4B94320B.9000804@agliodbs.com> Subject: Re: Numerics of diffrent scales Raises Type Mismatch Error in a Set Returning Function x-scalix-Hops: 1 X-Mailer: Evolution 2.28.2 (2.28.2-1.fc12) Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.855 tagged_above=-10 required=5 tests=AWL=0.745, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/4 X-Sequence-Number: 53 On Sun, 2010-03-07 at 15:08 -0800, Josh Berkus wrote: > Per pgsql-bugs, it's an expected compatibility issue due to unifying the > SQL and PLPGSQL parsers. That is, the fact that plpgsql used to let you > do this was regarded as a bug, and was not consistent with the SQL > command line. > > Worth noting in the release notes as part of a general class of > backwards-compatibility issues. > > --Josh Berkus > Note that this behavior change affects seems to affect other types who's size is different such as character varying. I'm probably not understanding, but I'm not sure I follow what the consistency issue is. It seems like in most other parts of PG, types are cast sensibly without complaint. In 9.0 and 8.4 we can do things like: CREATE TABLE foo (n NUMERIC(10,2)); INSERT INTO foo values (42.777777::NUMERIC(12,2)); INSERT INTO foo values (42.777777::NUMERIC(8,2)); INSERT INTO foo values (42.777777::NUMERIC(14,8)); SELECT * FROM foo JOIN (VALUES (42.78::NUMERIC)) AS bar(m) ON foo.n = bar.m; The values are rounded and cast; Same with varchar of various sizes. But when returning a setof things are now strictly checked. However, when selecting into a record PL doesn't complain if the sizes don't match the substructure. Also curious is that single value return types are not too particular. For example: CREATE OR REPLACE FUNCTION check_me() RETURNS VARCHAR(2) AS $$ BEGIN RETURN 42.7777::NUMERIC(7,4); END; $$ LANGUAGE 'plpgsql'; SELECT *,pg_typeof(check_me) FROM check_me(); check_me | pg_typeof ----------+------------------- 42.7777 | character varying (1 row) -Noel Proffitt