Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4D847B5DBFB for ; Thu, 7 Jul 2011 22:01:13 -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 26316-07 for ; Fri, 8 Jul 2011 01:01:06 +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 1B743B5DBF4 for ; Thu, 7 Jul 2011 22:01:05 -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 p6810uwx009085; Thu, 7 Jul 2011 21:00:56 -0400 (EDT) To: "Gavin Flower" cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6095: Misleading error message: INSERT has more expressions than target columns In-reply-to: <201107080029.p680T8dO058681@wwwmaster.postgresql.org> References: <201107080029.p680T8dO058681@wwwmaster.postgresql.org> Comments: In-reply-to "Gavin Flower" message dated "Fri, 08 Jul 2011 00:29:08 +0000" Date: Thu, 07 Jul 2011 21:00:56 -0400 Message-ID: <9084.1310086856@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: 201107/62 X-Sequence-Number: 30674 "Gavin Flower" writes: > In the 'INSERT INTO' construct: I think that psql should first check that > the fields listed after the table name are valid, before checking that the > number of columns specified is sufficient for the number of expressions. Hmm ... I think this would just move the set of unpleasant cases around. Usually I find it's better if we check the count first. For example, if you accidentally stick an extra value into the VALUES list, and we weren't checking the count first, you'd likely get weird invalid-input-value complaints that stem from matching subsequent input items to the wrong column. In such cases it saves a lot of time if we first point out the wrong number of values. > Due to my poor eyesight: it took me a few minutes before I realized that I > had used a fullstop '.' rather than a comma ',' in the list of columns. > There is neither a schema, nor a database, called 'id' - so I would have > thought that pg should have been able to detect the error. Actually, what you get if you change the number of VALUES columns is: ERROR: cannot assign to field "pay" of column "id" because its type integer is not a composite type LINE 1: INSERT INTO wage (id. pay) ^ This *is* valid syntax, if id is a composite-type column. regards, tom lane