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 1gMces-0007lt-1M for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Nov 2018 17:39:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMcep-0005oy-Tv for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Nov 2018 17:39:23 +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 1gMcep-0005or-MY for pgsql-hackers@lists.postgresql.org; Tue, 13 Nov 2018 17:39:23 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMcei-0002Pm-Mn for pgsql-hackers@lists.postgresql.org; Tue, 13 Nov 2018 17:39:23 +0000 Received: by mail-wm1-x32e.google.com with SMTP id f2-v6so12222212wme.3 for ; Tue, 13 Nov 2018 09:39:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=LUq/Yiua8PoCAuP1DtRicwUvQaCFVaRJS0jEMs3zPzw=; b=1j1VbgL+kIttQzsbSepX1/fqNHzlRr4bQwoRCxQv0n7XYdVfrDfNRf4cMf4J2Ti4M/ U8OKT7L2d08mDIvQM0gpFaUzTKyDSL/z4KYxUZFQKQVuPCrPf21mPpsO5miPMw7MyMDr ujiIJu2aDJakL70TJ/0MtyaaBLxFDYHAP1Z1icJkow6JeFKq/SSf3gre7lYU7vZ5ChaA Gzxmvn4izIYmVzHySPJryh/nmu2qhIX+OqwRaAkfpyENHA6VEVz0yLAZ+vAFgMlIwv/H j2LbWidpQwzNvMEGpEWKw9dqRx5SFvTvGmY9mO6SXPGSlpAqg1og0VXeuGbBDjMNZ0Pi 8EBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=LUq/Yiua8PoCAuP1DtRicwUvQaCFVaRJS0jEMs3zPzw=; b=Hl4A8w9E7cIRIbmbilo4NVqB8DaRj3w6dZyXDiJdwuNGo2Cqww19z5w8ikBlAM9BU0 T+QQKEnZsWKYXDLFHprmR2S3U97mXdlAhc8I4PSOoeNeCVpAePe84RO50K5oVjAJQ3hr rEkfEM3XHCmmVkAroehNvXFMradLqcvUygeuD08GfR5nYAwK308d/giHNbsqMwvVtPFG ck0ivwft679oK2koAHtHXLd/pigoHvGxqAZvflz770a1Nsn1ZVfvMTcA0S/kxxwqyCdP w4nfGnkUnUyqwMCYtEGzH9WIjme23ipvVQf13Nh9CD60ywQH0imYHzXc7vrXd/GquD3X Qkvg== X-Gm-Message-State: AGRZ1gKBK4wKsbCF0JgRrNpaTGYq8woCMhvppJz24xlKWM++ifu+024I OKt8IgxW3hEJ0XPWEl9t8q4piw== X-Google-Smtp-Source: AJdET5dI+Va6eAray/7TPNyvLgk79vZWN5KjdxBcTLm1ABwGK5fv5G9HVWYuwACqY99p4LM7HTGRbw== X-Received: by 2002:a1c:1383:: with SMTP id 125-v6mr4204910wmt.71.1542130755057; Tue, 13 Nov 2018 09:39:15 -0800 (PST) Received: from development (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id g13-v6sm16584629wru.1.2018.11.13.09.39.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 09:39:14 -0800 (PST) Message-ID: <578398af46350effe7111895a4856b87b02e000e.camel@2ndquadrant.com> Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation From: Tomas Vondra To: Tom Lane , Alvaro Herrera Cc: =?ISO-8859-1?Q?J=FCrgen?= Strobel , Amit Langote , PostgreSQL Hackers Date: Tue, 13 Nov 2018 18:39:11 +0100 In-Reply-To: <5662.1542040384@sss.pgh.pa.us> References: <20181112140051.yv5m77esq5jz6rkg@alvherre.pgsql> <5662.1542040384@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-2.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 2018-11-12 at 11:33 -0500, Tom Lane wrote: > Alvaro Herrera writes: > > One of the guiding principles that I think we should hold for > > partitioning is that operating directly into the partition should > > be > > seen as only an optimization compared to inserting into the parent > > table > > -- thus it should not behave differently. Applying different > > default > > values depending on where you're inserting into goes counter to > > that > > principle. > > 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. > Not sure what new logical inconsistencies you have in mind, but the principle proposed by Alvaro seems sensible to me. I too see insertions into the partition primarily as an optimization, and would not expect it to use other defaults than when inserting through the parent. Particularly not defaults contradicting the partition definition and forcing rerouting the tuple somewhere else automatically. (IME when inserting directly into partitions people expect that data to end in that partition, and if not it's an error - bogus data, ...). I'm not claiming there are no use cases for defaults on partitions. For example I can imagine multi-level partitioning, where each layer can specify defaults for the lower levels. But it seems rather surprising to only apply the partition defaults for direct insertions. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services