Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A03011337B71 for ; Fri, 5 Nov 2010 16:17:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 83364-02 for ; Fri, 5 Nov 2010 19:17:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 116611337B8D for ; Fri, 5 Nov 2010 16:17:27 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id oA5JHOS0029498; Fri, 5 Nov 2010 15:17:24 -0400 (EDT) To: Merlin Moncure , Kevin Grittner , Robert Haas , Jon Nelson , pgsql-bugs@postgresql.org Subject: Re: [PERFORM] typoed column name, but postgres didn't grump In-reply-to: <11057.1288889780@sss.pgh.pa.us> References: <4480.1288374498@sss.pgh.pa.us> <4CCACE6E0200002500036F95@gw.wicourts.gov> <6240.1288379246@sss.pgh.pa.us> <4CCADE440200002500036FB2@gw.wicourts.gov> <8216.1288383162@sss.pgh.pa.us> <4CD28C5C020000250003727B@gw.wicourts.gov> <9974.1288887285@sss.pgh.pa.us> <11057.1288889780@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Thu, 04 Nov 2010 12:56:20 -0400" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <29481.1288984609.0@sss.pgh.pa.us> Date: Fri, 05 Nov 2010 15:17:24 -0400 Message-ID: <29497.1288984644@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/41 X-Sequence-Number: 28621 ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <29481.1288984609.1@sss.pgh.pa.us> I wrote: > Ah. No, that would still work after the change. The case that I'm > proposing to break is using function-ish notation to invoke a cast > from a composite type to some other type whose name you use as if it > were a function. Even there, if you've created such a cast following > the usual convention of naming the cast function after the target type, > it'll still act the same. It's just the built-in I/O-based casts that > will stop working this way (for lack of a matching underlying function). Here's a proposed patch, sans documentation as yet. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-patch; charset="us-ascii" Content-ID: <29481.1288984609.2@sss.pgh.pa.us> Content-Description: disable-composite-casts.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_fu= nc.c index b50bce448728280f63c695a688c004bd15bf84cf..9bb100e0c1e83c63b554f65300= c03afed563373a 100644 *** a/src/backend/parser/parse_func.c --- b/src/backend/parser/parse_func.c *************** func_get_detail(List *funcname, *** 985,992 **** * can't write "foo[] (something)" as a function call. In theory * someone might want to invoke it as "_foo (something)" but we have * never supported that historically, so we can insist that people ! * write it as a normal cast instead. Lack of historical support is ! * also the reason for not considering composite-type casts here. * * NB: it's important that this code does not exceed what coerce_type * can do, because the caller will try to apply coerce_type if we --- 985,997 ---- * can't write "foo[] (something)" as a function call. In theory * someone might want to invoke it as "_foo (something)" but we have * never supported that historically, so we can insist that people ! * write it as a normal cast instead. ! * ! * We also reject the specific case of COERCEVIAIO for a composite ! * source type and a string-category target type. This is a case that ! * find_coercion_pathway() allows by default, but experience has shown ! * that it's too commonly invoked by mistake. So, again, insist that ! * people use cast syntax if they want to do that. * * NB: it's important that this code does not exceed what coerce_type * can do, because the caller will try to apply coerce_type if we *************** func_get_detail(List *funcname, *** 1017,1024 **** cpathtype =3D find_coercion_pathway(targetType, sourceType, COERCION_EXPLICIT, &cfuncid); ! iscoercion =3D (cpathtype =3D=3D COERCION_PATH_RELABELTYPE || ! cpathtype =3D=3D COERCION_PATH_COERCEVIAIO); } = if (iscoercion) --- 1022,1044 ---- cpathtype =3D find_coercion_pathway(targetType, sourceType, COERCION_EXPLICIT, &cfuncid); ! switch (cpathtype) ! { ! case COERCION_PATH_RELABELTYPE: ! iscoercion =3D true; ! break; ! case COERCION_PATH_COERCEVIAIO: ! if ((sourceType =3D=3D RECORDOID || ! ISCOMPLEX(sourceType)) && ! TypeCategory(targetType) =3D=3D TYPCATEGORY_STRING) ! iscoercion =3D false; ! else ! iscoercion =3D true; ! break; ! default: ! iscoercion =3D false; ! break; ! } } = if (iscoercion) ------- =_aaaaaaaaaa0--