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 1gMcEC-0006Ln-NI for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Nov 2018 17:11:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gMcEA-0006lL-LA for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Nov 2018 17:11:50 +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 1gMcEA-0006lE-9J for pgsql-hackers@lists.postgresql.org; Tue, 13 Nov 2018 17:11:50 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gMcE7-0001nE-G3 for pgsql-hackers@lists.postgresql.org; Tue, 13 Nov 2018 17:11:49 +0000 Received: by mail-wm1-x341.google.com with SMTP id f2-v6so12139420wme.3 for ; Tue, 13 Nov 2018 09:11:47 -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=WsKT3BorXBlKE4DAJV7UD+sJZa3UmhEdtjdl1GxX2c4=; b=b/kLm5b1SODUAlBdppxqFNpYx/WCxb7B4BSGww6p/ebdHTUY0J2o+bPOs5Ii8EQcP5 4otzf8wzajw5jZNirKkakhmO0SYLdM8yPC/LZ+G/uIm/q3L9m4yynuVHpbP6Li+jbHEX l6FnUoeD3aY9Eu6WUYuxwH/odGmzWKu0EPMnkJeK24g1LrwlyqYX7gG/3AxA61K7Rz6H NFQpFRbrk3dR+vPtEuil1tmMTJgbHg0ckRSqxbps72rY/ZL/aA0f0TBcun4dGHrbTKjt Qg9ZwszWJPyVAmE8DCAWSmsYohPjGSqFBhUlZZr7uhOkISHPxnjkeDhmSw+4RiQVoaGZ GqNA== 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=WsKT3BorXBlKE4DAJV7UD+sJZa3UmhEdtjdl1GxX2c4=; b=GQLLy5ilk7uNWhY8zWfXR05JR7O/suXdxDysBxaCUsBxg3btpi5RzkUVVI9V6nu7WP 5NAsF4xg9cXXI8j55dHh0Y9R3xGSv7+Lld2gy28FyyUVHVFChlPWfpfJWkL1pzjd6kgW xeGDcv8N38zQDs6piD2gGGiWZdE3aDkoeodrfh4zHrQV4+kMv/ZLSaplIRup3Y+OKdYR nN/oMu1ZD40NvNzA49wKjTYzTIuOa8YT121CH3RMYySYO/eNmpWQn7X3y81iOo8giOpN jp/fCcSA9Gdo0UYP6T9Ibr5cMB7TXZUA/th+LcfMKilXCNOUNDAcyGW3u4Pv03oWqQyW LjYQ== X-Gm-Message-State: AGRZ1gIKEnwDxFfbTboH3gCSLn1Qz1Pb62/Q4RfcHA5mGyp2Q3eKV0T5 z0qNFj8p3ICsxFxmeDgzxDsz9g== X-Google-Smtp-Source: AJdET5cC78ww3CFYKR+J87L5cEzkfTlpTN3EQBrQdMjhtHgDfNXH1VNKK1TryCmw7oPMJtHBiBEYfw== X-Received: by 2002:a1c:568b:: with SMTP id k133-v6mr4183950wmb.4.1542129106346; Tue, 13 Nov 2018 09:11:46 -0800 (PST) Received: from development (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id q7-v6sm13047177wmg.27.2018.11.13.09.11.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Nov 2018 09:11:45 -0800 (PST) Message-ID: Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation From: Tomas Vondra To: =?ISO-8859-1?Q?J=FCrgen?= Strobel , Tom Lane Cc: Alvaro Herrera , Amit Langote , PostgreSQL Hackers Date: Tue, 13 Nov 2018 18:11:42 +0100 In-Reply-To: References: <20181112140051.yv5m77esq5jz6rkg@alvherre.pgsql> <5662.1542040384@sss.pgh.pa.us> <10299.1542067039@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: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 2018-11-13 at 13:44 +0100, Jürgen Strobel wrote: > 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: > I think the question is what part of the current behavior is intentional (albeit with corner-cases not handled or rejected properly), and what part is just not thought through. Not sure. > 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). > Yeah, allowing defaults mismatching the partition seems like a can of worms. We certainly should not allow such rows to be inserted in the partition. Routing them somewhere else seems tricky, so perhaps it'd be better to just error-out in this case. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services