Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gL9CN-00059c-7h for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Nov 2018 15:59:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gL9CL-0000RN-6v for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Nov 2018 15:59:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gL9CK-0000QY-PZ for pgsql-hackers@lists.postgresql.org; Fri, 09 Nov 2018 15:59:53 +0000 Received: from mail-qk1-x744.google.com ([2607:f8b0:4864:20::744]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gL9CH-0002S2-3J for pgsql-hackers@lists.postgresql.org; Fri, 09 Nov 2018 15:59:51 +0000 Received: by mail-qk1-x744.google.com with SMTP id y16so2343421qki.7 for ; Fri, 09 Nov 2018 07:59:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=edPsZsUXqLHlJtVt+0i9v7iOsHEUsLexmmY7Dp9gzr0=; b=TThtMrO8/ArBsqJIjMsVpiFQGMYbOWsd6PH+Vd2m8uV1EsFoAYRUd7knmhSzyis4ms b/UrMR+svpgtZosBPfBsFyyPcOShonEUXac44E/QnVsOEiH4VJRpDR1JbT7BFpA+32Rd 7uq2r+OUCvV+dJG4VE/wCbYFIBMmRNJDZcWIqioG+Pze6KiXKKVfhg2lBSHTn1BGQb/i VNpcYjzPeWqQCtSUVxpG//+/qjaLDIRDVafLfssi/pLTankK8EUK25yQEa7C+bPQ7oc2 YOsCQu2wGHjxeq/J71LMijazM4d58c6IJcQwHdrFkllEOmk5X4wrxQ0Kl2tlO3GDVnXE 0mDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=edPsZsUXqLHlJtVt+0i9v7iOsHEUsLexmmY7Dp9gzr0=; b=FCXF16DIqqi0e3g7QeDiG3Rg9IHHiZrkft1Er4/O6UnaNqkvJ15C6ELN03/PoKLQ8c WUd1FK/KLPHv/9QJWkfAP2mxaEh7hEMIS8PCu/IGEwin7UCEG+XIWcjZcnHqumTG0uue KyRNeGSKP41nOBJ8tNUk1HKacmQ6XhFU8cRr/kQebJLkwKQMdvn7PxMMPBJLJPjFCzPZ voQkGbRHAAaTWQEvbzxgoiCJhoVw1+UuhQ0VWh1gssYZGV+iqewnmHH6nkkuv3xc9ZQQ OBXoZgt8E95fe+/sWm3WJ3mdxtVzYJ3sZekcbg42uGfM5AO0qx5lMGykykuy38BLjrAV zXyA== X-Gm-Message-State: AGRZ1gKeOzOWMZNnX7FVWktoZAJd7PeDMIVJ/o/mHTLRTZ6er3QAkojQ KeT5KMbRZFHXQN0kjiR63p3Xpg== X-Google-Smtp-Source: AJdET5eWcoCOi76NXbq/3awz5sPe/22majt2Skf62u8W6oS+2P0nK8nNg1b+l+qdLm/gcsk1hkjGlg== X-Received: by 2002:a37:c891:: with SMTP id t17mr8532386qkl.31.1541779188013; Fri, 09 Nov 2018 07:59:48 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id k19-v6sm3395285qtj.57.2018.11.09.07.59.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Nov 2018 07:59:47 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 7D68F692; Fri, 9 Nov 2018 12:59:43 -0300 (-03) Date: Fri, 9 Nov 2018 12:59:43 -0300 From: Alvaro Herrera To: Amit Langote Cc: Amit Langote , Ashutosh Bapat , PostgreSQL Hackers , =?utf-8?Q?J=C3=BCrgen?= Strobel Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation Message-ID: <20181109155943.xnlbcyzp7crnyjmo@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7d42123a-2d60-2829-8d6b-0c28e3e32376@lab.ntt.co.jp> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-Nov-09, Amit Langote wrote: > Or is it a *bug* of tuple-routing that it doesn't substitute default > values that may be defined for partitions? It kind of looks like one if > you see an example like this. > > create table p (a int, b int) partition by list (a); > create table p1 partition of p (b not null default 1) for values in (1); > insert into p1 values (1); > table p; > a │ b > ───┼─── > 1 │ 1 > (1 row) > > insert into p values (1); > ERROR: null value in column "b" violates not-null constraint > DETAIL: Failing row contains (1, null). I don't know. I wonder if the bug isn't that we allow the default to be specified for the partition at all -- why shouldn't we just reject that with an error? See this example, where the inserts give values that could be said to be inconsistent: create table p (a int , b int default 3) partition by list (a); create table p1 partition of p (b default 42) for values in (1); insert into p (a) values (1); insert into p1 (a) values (1); select * from p; a │ b ───┼──── 1 │ 3 1 │ 42 (2 filas) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services