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 1gLDw6-0002ky-UI for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Nov 2018 21:03:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gLDw4-0006O6-Ju for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Nov 2018 21:03:24 +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 1gLDw4-0006Ny-7y for pgsql-hackers@lists.postgresql.org; Fri, 09 Nov 2018 21:03:24 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gLDvx-0000kE-3s for pgsql-hackers@lists.postgresql.org; Fri, 09 Nov 2018 21:03:22 +0000 Received: by mail-wr1-x436.google.com with SMTP id y3-v6so3241155wrh.10 for ; Fri, 09 Nov 2018 13:03:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=strobel.info; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kKARGpzSiwXE3vPDRweZhDfdjql6oqraspRM9kZwfeA=; b=bB/CZDKbtWPs+JIzQmCKfE5eha0dKBlUjDMl1qGboVR2qVhqKCm+10aH6Vr8J5rmZQ NxZt4H6S0NP2zvylrgoKwYZCgp2zj38kCa86WopF9cxxV6I3rWAqMquGfdvHgHntjL6u RwJnR6BkWIENXpd10epqBRiSEiR0IOMXRc2ek= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kKARGpzSiwXE3vPDRweZhDfdjql6oqraspRM9kZwfeA=; b=aOUjBk+D2IkunaYKSpf15pJd7k3sJxj/s9eECb9Gu2a53sQFyu+w/vq6ILk4YYIYQf mFUmQpo2wIr9d9HjXc3YxlBW2bYjkGtdCGmceiLyALzQ+SEzNzsOy3pQUK7v60uvrauY +++qasl7Pq3b28uNuLSTUl8shBTfa+Nct/1aPudy4Jor9XHrcYS+7n09gaE7x9PoGF/g Hi2POWXjtjxz1dw09VoXinXQ9nR5Hh9oalciqKf169yj5cu71vxMg/mrMoGpq0YK2Hpb YHETZNXSqdhqLE5KJ3d3NJq23z9zhEXMSHtji/OT5SRB6aaS1IOVXNHJDwDgEHP9vOKc BwuQ== X-Gm-Message-State: AGRZ1gLFzxvw5CHq/1aKTxTyc2z5U+obI4tGx3lCx8yQhuaZZyZGz8+f 8x9HVMLo/lLSAsnlNJT32Ip4mLzyDi/hVA== X-Google-Smtp-Source: AJdET5dfiGzGv95277/XZKchXVoz1x7BTwNirCQcujhN3bv23B8d7l3BxbPzht+gl66FyPyJfgxNIA== X-Received: by 2002:a5d:48cc:: with SMTP id p12-v6mr4139864wrs.122.1541797395023; Fri, 09 Nov 2018 13:03:15 -0800 (PST) Received: from Juergens-MacBook.local (77.119.129.96.wireless.dyn.drei.com. [77.119.129.96]) by smtp.gmail.com with ESMTPSA id t77-v6sm3748124wme.18.2018.11.09.13.03.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 13:03:14 -0800 (PST) Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation To: Alvaro Herrera Cc: Amit Langote , Amit Langote , Ashutosh Bapat , PostgreSQL Hackers References: <20181109170712.pfn55lab5j7oae4v@alvherre.pgsql> From: =?UTF-8?Q?J=c3=bcrgen_Strobel?= Message-ID: <00ca74fd-4f88-877a-823b-2891f3f212ce@strobel.info> Date: Fri, 9 Nov 2018 22:03:12 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181109170712.pfn55lab5j7oae4v@alvherre.pgsql> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2018-11-09 18:07, Alvaro Herrera wrote: > On 2018-Nov-09, Jürgen Strobel wrote: > >> Regarding your example, what I expected is that *both* inserts would >> consistently result in a tuple of (1, 42) since p should route the >> insert to p1 and use p1's defaults. The current inconsistent behavior is >> the heart of the bug. > > I think that would be sensible behavior, as long as the partition > doesn't override values for the partitioning column -- i.e. if the > default values don't re-route the tuple to another partition, I think we > should use the partition's default rather than the parent. This says we > should expand defaults after routing. However, can we really route if > we haven't expanded defaults? In general, we may be lacking values for > some columns of the partition key. Another point: if we've already > expanded defaults when processing at the parent level, when we reach the > partition we don't know which values are still missing default > expansion, or which defaults coming from the parent ought to be > re-expanded. > > So this looks to be a bit of a landmine. > > In any case it seems really hard to see this is as a bug that we would > fix in back-branches. > I am slightly confused now, I thought this landmine was already fixed in master and what remains is only whether to backport it or not? Which I guess depends on whether this is classified as a bug or not. Since the fix has the potential to break current applications and the documentation is vague about wanted behavior I think it would be sensible to add a warning only, even if we agree to call it a bug. Best regards, Jürgen