X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 848FE9FB263 for ; Thu, 17 Aug 2006 15:11:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 56145-05 for ; Thu, 17 Aug 2006 15:11:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mtaout03-winn.ispmail.ntl.com (mtaout03-winn.ispmail.ntl.com [81.103.221.49]) by postgresql.org (Postfix) with ESMTP id 1B5099FB25D for ; Thu, 17 Aug 2006 15:11:24 -0300 (ADT) Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com with ESMTP id <20060817181123.VBOJ1865.mtaout03-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Thu, 17 Aug 2006 19:11:23 +0100 Received: from Wilbur ([86.14.228.87]) by aamtaout02-winn.ispmail.ntl.com with SMTP id <20060817181122.XZIC23938.aamtaout02-winn.ispmail.ntl.com@Wilbur> for ; Thu, 17 Aug 2006 19:11:22 +0100 Message-ID: <029c01c6c228$8e8e5210$0600a8c0@Wilbur> From: "Julian Scarfe" To: Subject: NULL becomes default Date: Thu, 17 Aug 2006 19:11:21 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.372 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200608/134 X-Sequence-Number: 26092 A surrogate key has been introduced on a table with modifiers: Column | Type | Modifiers -------------+-----------------------------+------------------------------------------------------------ new_id | integer | not null default nextval(('some_id_seq'::text)::regclass) However, some legacy software inserts into the table by first getting column names and then composing an INSERT for all the columns, filling in any undefined values with NULLs. Thus when it attempts to insert a row I get a: ERROR: null value in column "new_id" violates not-null constraint Thus I would like NULLs in such INSERTs to be treated as DEFAULT rather than violating the constraint. Is there an easy way to do that at the database level? Thanks Julian