Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMY3D-0008Bh-D6 for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Nov 2018 12:44:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMY3B-0007Cd-TD for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Nov 2018 12:44:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMY3B-0007CW-D4 for pgsql-hackers@lists.postgresql.org; Tue, 13 Nov 2018 12:44:13 +0000 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMY38-0003uz-4s for pgsql-hackers@lists.postgresql.org; Tue, 13 Nov 2018 12:44:12 +0000 Received: by mail-wm1-x342.google.com with SMTP id 124-v6so11847484wmw.0 for ; Tue, 13 Nov 2018 04:44:08 -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=b/kybY4kDUGKUbkvz18dVVrUlJYD/IR3+t3KO9xDgEw=; b=Rpoj8nNWNuAbacwMJzicbdUpVelNncYNgfo6plZ6iwyBQsQQ4apUgoS8bYJ5/suLV9 PpXgoMkziVbr7OOT/ebhQcYvEm1IZ5PVarrJGiHABcjOKGP3eELSTG6KbguY1O3AvRSU XfgShr3tbjK85Rj3bFvDJiKveOeyIlET6lrC8= 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=b/kybY4kDUGKUbkvz18dVVrUlJYD/IR3+t3KO9xDgEw=; b=nXLJUyRvIL0CVOGaVW+oNTeeJRgdlctJnaG1sJvin7cqvOAEQePLrBM1wnClBNO5WV NVnmMkaopEIOT3iutAxueqR4mjXY1qsDsO3H0JkiISoSuyaNN3rm1xft1nTTBMdZA2Op 8ExdXA66hV7w6+HiLl3KNR8JsKrELOC9tLGI7RDzmXaO2iuEHBNddDbus972inq2byDU iwY0npmWc4DYx9jTnIdAG19ZCFc9t+VF/hyGXd5rsv4zpFYw+iV9sYc7Cd/tUi42ojeI bn9/5WE2qdLl4iwz5Go6TC+q9cC+ynEPeritDFQU3P4jURbNG3gWehSUzVu4hEfp+0fd K+yQ== X-Gm-Message-State: AGRZ1gLOGEhrTSD2R6vixWc+bqc9I5E9s4nA1k9GPH5s7uwfw736pfoP sFb7Y27A7rAE0KNUZHz8ZQcWNKWmLsTgZg== X-Google-Smtp-Source: AJdET5ezk28H7zCYUG7Qe7YAFPlcHqIvsxgt0CC7KIhDNw2XJ02tt23ADcZ0SRJA0j/ywBkIWXyvIg== X-Received: by 2002:a1c:7f86:: with SMTP id a128-v6mr3229375wmd.17.1542113047732; Tue, 13 Nov 2018 04:44:07 -0800 (PST) Received: from Juergens-MacBook.local (178.115.129.242.wireless.dyn.drei.com. [178.115.129.242]) by smtp.gmail.com with ESMTPSA id w11-v6sm23391953wrr.96.2018.11.13.04.44.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 04:44:06 -0800 (PST) Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation To: Tom Lane Cc: Alvaro Herrera , Amit Langote , PostgreSQL Hackers References: <20181112140051.yv5m77esq5jz6rkg@alvherre.pgsql> <5662.1542040384@sss.pgh.pa.us> <10299.1542067039@sss.pgh.pa.us> From: =?UTF-8?Q?J=c3=bcrgen_Strobel?= Message-ID: Date: Tue, 13 Nov 2018 13:44:03 +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: <10299.1542067039@sss.pgh.pa.us> 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-13 00:57, Tom Lane wrote: > =?UTF-8?Q?J=c3=bcrgen_Strobel?= writes: >> On 2018-11-12 17:33, Tom Lane wrote: >>> I'm not entirely convinced that I buy that argument, especially not in >>> a case like this where it introduces logical inconsistencies where there >>> otherwise wouldn't be any. > >> I think I missed something, what are the *introduced* logical problems? > > What to do if a partition introduces a default value that would force > re-routing to some other partition. I would claim this is a problem which already exists with the current behavior: a) If a tuple is inserted through the parent it's ignored and useless. b) If a tuple is inserted through the partition it can lead to inconsistency and a constraint violation (possibly rectifiable by a re-route which I think we all agree is out of the question). >> Apart from implementation issues the only logical problems I see are if >> you allow to change defaults of the partition key columns, and these are >> problematic (nonsensical really) in either case. > > Just claiming that it's nonsensical doesn't fix the problem. Also, it > is neither problematic nor nonsensical for the root to provide defaults > for partition key columns. So if we go this route, we are giving up > useful behavior (key-column defaults on the root) for useless behavior > (key-column defaults on the partitions). Yes, I strongly believe defaults on the key columns in partitions should be disallowed, that's why I called them nonsensical in both cases, see above a) and b) for why this applies even to current behavior. Of course disallowing all DEFAULT clauses on partitions is the easiest way out, and I'd rather see this than inserts through partitions being more than a pure optimization. Best regards, Jürgen