Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 92DA2131F6D2 for ; Fri, 16 Mar 2012 12:03:17 -0300 (ADT) Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S8YgV-0008L8-T5 for pgsql-bugs@postgresql.org; Fri, 16 Mar 2012 15:03:17 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S8YgH-00052f-6V for pgsql-bugs@postgresql.org; Fri, 16 Mar 2012 15:03:03 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1S8YgG-0002hJ-SR for pgsql-bugs@postgresql.org; Fri, 16 Mar 2012 15:03:00 +0000 Date: Fri, 16 Mar 2012 15:03:00 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6535: LEFT JOIN on large table is altering data To: pgsql-bugs@postgresql.org From: aren@arencambre.com X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/120 X-Sequence-Number: 32681 The following bug has been logged on the website: Bug reference: 6535 Logged by: Aren Cambre Email address: aren@arencambre.com PostgreSQL version: 9.1.3 Operating system: Windows 7 x64 Description: = (Note that this issue is described fully at http://stackoverflow.com/questions/9713537/postgres-left-join-is-creating-n= ew-data. A few knowledgeable people have weighed in, and there is no solution identified.) In a nutshell, I have a query LEFT JOINing table A with table B and inserting the data into table A'. A' is a functional equivalent of table A. Table B is actually built from a using a WITH at the top. I'm using it to help add a rank() to the table. Table A has just over 2 million rows. There is a column named citation_id that has no null values. Not only does citation_id have a NOT NULL constraint, I have verified with a query that it has no null values. The LEFT JOIN is pulling table A's citation_id. However, when the joined table is inserted into table A', Postgres throws "null value in column "citation_id" violates not-null constraint" errors. Note that I am running Postgres 32 bit for PostGIS compatibility.