Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 1D0B9B5DBE9 for ; Thu, 7 Jul 2011 21:29:10 -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 00484-08 for ; Fri, 8 Jul 2011 00:29:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id 7F5EFB5D803 for ; Thu, 7 Jul 2011 21:29:09 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p680T8oF058682 for ; Fri, 8 Jul 2011 00:29:08 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p680T8dO058681; Fri, 8 Jul 2011 00:29:08 GMT (envelope-from www) Date: Fri, 8 Jul 2011 00:29:08 GMT Message-Id: <201107080029.p680T8dO058681@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6095: Misleading error message: INSERT has more expressions than target columns From: "Gavin Flower" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201107/61 X-Sequence-Number: 30673 The following bug has been logged online: Bug reference: 6095 Logged by: Gavin Flower Email address: gavin.flower@archidevsys.co.nz PostgreSQL version: 9.1beta2 Operating system: x86_64 Linux Description: Misleading error message: INSERT has more expressions than target columns Details: Using pg 9.1beta2 compiled using gcc (GCC) 4.5.1 20100924 (Red Hat 4.5.1-4), on a 64 bit Linux system. 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. 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. DROP TABLE wage; CREATE TABLE wage ( id int PRIMARY KEY, pay numeric(5,2) ); INSERT INTO wage (id. pay) VALUES (1, 4.2); TABLE wage; //// output $ psql < bug.sql DROP TABLE NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "wage_pkey" for table "wage" CREATE TABLE ERROR: INSERT has more expressions than target columns LINE 2: VALUES (1, 4.2); ^ id | pay ----+----- (0 rows) $