X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3C40814B2824 for ; Wed, 11 Aug 2004 17:19:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 49645-09 for ; Wed, 11 Aug 2004 20:19:30 +0000 (GMT) Received: from mproxy.gmail.com (rproxy.gmail.com [64.233.170.192]) by svr1.postgresql.org (Postfix) with ESMTP id D4CCC14B27FF for ; Wed, 11 Aug 2004 17:19:29 -0300 (ADT) Received: by mproxy.gmail.com with SMTP id 76so203672rnl for ; Wed, 11 Aug 2004 13:19:30 -0700 (PDT) Received: by 10.38.78.1 with SMTP id a1mr2166859rnb; Wed, 11 Aug 2004 13:19:30 -0700 (PDT) Message-ID: <7eeb33a0408111319791e88a5@mail.gmail.com> Date: Wed, 11 Aug 2004 22:19:30 +0200 From: Lars Erik Thorsplass To: pgsql-sql@postgresql.org Subject: Fwd: Inserts with incomplete rows... NOT NULL constraints In-Reply-To: <7eeb33a04081113184f268cf@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <7eeb33a040811053563894d7b@mail.gmail.com> <200408111502.08030.peter_e@gmx.net> <7eeb33a04081113184f268cf@mail.gmail.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/94 X-Sequence-Number: 18591 Sorry about that, forgot to send to the list. ---------- Forwarded message ---------- From: Lars Erik Thorsplass Date: Wed, 11 Aug 2004 22:18:24 +0200 Subject: Re: [SQL] Inserts with incomplete rows... NOT NULL constraints To: Peter Eisentraut > Am Mittwoch, 11. August 2004 14:35 schrieb Lars Erik Thorsplass: > > I would expect NULL fields not specified in the insert to get NULL > > inserted automatically. But that fields which are NOT NULL in the > > table structure gets inserted a NULL value too seems odd. > > More accurately, the default value is inserted, which in turn is null if you > didn't specify one. You might find it odd that default values that are > inconsistent with constraints are allowed, but I don't see any reasonable > alternative. Thanks for clearing that up. Guess I'll work around my migration problems with placeholder default values. I tried another approach at the same time. I tried to alter the tables that had changed between versions of the sql structure. The problem with this is that postgres is unable to add a field to a table with a NOT NULL constraint. You can add a NOT NULL constraint to the field afterwards but now all records in the table have a NULL value in the field. So you wont be able to do that until you change all the values. No default value was specified for the new field. As with the other approach this might also work if I enter some default values. Best regards, L.E.Thorsplass -- L.E.Thorsplass