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 1gLAFj-0000bf-Ji for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Nov 2018 17:07: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 1gLAFh-0000Re-Q2 for pgsql-hackers@arkaria.postgresql.org; Fri, 09 Nov 2018 17:07:25 +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 1gLAFh-0000RX-BU for pgsql-hackers@lists.postgresql.org; Fri, 09 Nov 2018 17:07:25 +0000 Received: from mail-qk1-x743.google.com ([2607:f8b0:4864:20::743]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gLAFa-0003yy-0C for pgsql-hackers@lists.postgresql.org; Fri, 09 Nov 2018 17:07:24 +0000 Received: by mail-qk1-x743.google.com with SMTP id o89so2771714qko.0 for ; Fri, 09 Nov 2018 09:07:17 -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=td3zSFX51Q8SyuPtUiyHTzJYWUdWwI153nFT0a/C16Q=; b=mGJuoBJ/ksR2Oglc6Qx0NcWQ+hsgrD8kKAPI4lI/ZBE7T9kLUmwrK6+foXerkFtH0K MDGW6dCJgsv43BToVxCpHfylv305ZTNpefwURYQ8lSpwzeXvbyUt8jOpxvqfcn6+sd+3 3daJXk2vYUNx6kRcGExdZW1H6CkqifbPgM5CLNk0LmJ4AGXbl0zw0cwykkvQvz2RzOds fpnGwi749Eb+eJIRRVCVDIXRTla8gN5hFfnbOYBvKrklkF3YsWZCg95pJK2gD9+4c1Ck g4kuuZlsI2qSiEoZXMDSUwpGu7nS+sFKQz/O70rayLzlhTT6oiRZsDTK8GPxX3Lnk/l9 EYIg== 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=td3zSFX51Q8SyuPtUiyHTzJYWUdWwI153nFT0a/C16Q=; b=OD6pRYRi4V/p44hd5DDGtrggJyLWGsif6OnXBg/BC7j7hrmZGxSV5apgWAweZTknuN jZqlgmdy153pI6TR9/fFWreHPn4ZLFmu/QbP+kOvN5EJbpIOzywFipjBUlpCTMx6ioEM uS8cLi/o6df5Q4yKJGocNLJSE3BKkpa0qMp/HkUZoPYqFKx5I4gpdti9QpM4R6zYPYyQ DHI3+DBt1gkCdvrprvTpNzfT3bv3IfQTzPlIFQHqXd4aMAsKO0hXph72oFgNKDXOZMew vveLwDu6bNdHIqSNwhv42A8jHLoMQB77JbsuwEqkBMZsLzGQjPMh94SZ4dQRY9NdL2Z+ +uIw== X-Gm-Message-State: AGRZ1gJnFY3+Yvi4OcM2zZAZRiNb6ORez0edKFlPq6Vv+IBbKuQISvFI KwfeDZdA7TvRzts3CTVfQDxuSg== X-Google-Smtp-Source: AJdET5f3lu4crb58WatDF21J6u4zPGKnqRn+sDlrzvZBssqwZbbog5r4k//+upfTpwJaLV+Cn02fXg== X-Received: by 2002:ac8:3879:: with SMTP id r54mr9020895qtb.69.1541783237032; Fri, 09 Nov 2018 09:07:17 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.121.29.3]) by smtp.gmail.com with ESMTPSA id c202sm4081656qkb.19.2018.11.09.09.07.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Nov 2018 09:07:14 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 469C1692; Fri, 9 Nov 2018 14:07:12 -0300 (-03) Date: Fri, 9 Nov 2018 14:07:12 -0300 From: Alvaro Herrera To: =?utf-8?Q?J=C3=BCrgen?= Strobel Cc: Amit Langote , Amit Langote , Ashutosh Bapat , PostgreSQL Hackers Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation Message-ID: <20181109170712.pfn55lab5j7oae4v@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <67125a48-0e0f-4f7e-6d02-e312fe13f7fe@strobel.info> User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services