Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNix9-00080x-BD for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Mar 2014 13:12:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WNix7-0002fh-Oc for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Mar 2014 13:12:09 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNewx-0002nc-F5 for pgsql-hackers@postgresql.org; Wed, 12 Mar 2014 08:55:43 +0000 Received: from mimolette.dalibo.net ([212.85.154.222]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WNewq-0003rq-Ad for pgsql-hackers@postgresql.org; Wed, 12 Mar 2014 08:55:42 +0000 Received: from [192.168.1.18] (alo33-3-78-225-150-42.fbx.proxad.net [78.225.150.42]) by mimolette.dalibo.net (Postfix) with ESMTPSA id C6D546820010 for ; Wed, 12 Mar 2014 09:55:32 +0100 (CET) Message-ID: <53202106.3070207@dalibo.com> Date: Wed, 12 Mar 2014 09:55:34 +0100 From: Julien Tachoires User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: pgsql-hackers@postgresql.org Subject: Rowtype column and domain subfield with DEFAULT and NOT NULL constraint Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi, A customer has reported us a strange behaviour regarding a rowtype column with a domain subfield: test=# CREATE DOMAIN my_int_not_null_1 AS INTEGER DEFAULT 1 NOT NULL; CREATE DOMAIN test=# CREATE TYPE my_int_rowtype AS ( test(# f1 INTEGER, test(# f2 my_int_not_null_1 test(# ); CREATE TYPE test=# CREATE TABLE test (id SERIAL, col1 my_int_rowtype); CREATE TABLE test=# INSERT INTO test (col1.f1) VALUES (1); INSERT 0 1 test=# INSERT INTO test (id, col1.f1) VALUES (2, 1); INSERT 0 1 test=# INSERT INTO test (col1) VALUES ((1,NULL)); ERROR: domain my_int_not_null_1 does not allow null values test=# SELECT * FROM test; id | col1 ----+------ 1 | (1,) 2 | (1,) (2 rows) It seems: - the DEFAULT value (from the domain) is not inserted - the NOT NULL constraint is no applied excepting if we set explicitly the value to NULL, looks like it is the same issue than before, when there is no DEFAULT the parser/rewriter should set the column/subfield to NULL. Is build_column_default() the right place to handle that case ? -- Julien Tachoires http://dalibo.com - http://dalibo.org -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers