Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fT5zf-0001jQ-Ul for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Jun 2018 13:39:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fT5ze-0004I4-JR for pgsql-bugs@arkaria.postgresql.org; Wed, 13 Jun 2018 13:39:22 +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_SHA384:256) (Exim 4.89) (envelope-from ) id 1fT5ze-0004Hv-8G for pgsql-bugs@lists.postgresql.org; Wed, 13 Jun 2018 13:39:22 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fT5zQ-0007Cd-Ri for pgsql-bugs@lists.postgresql.org; Wed, 13 Jun 2018 13:39:21 +0000 Received: by mail-wm0-x242.google.com with SMTP id v16-v6so4772161wmh.5 for ; Wed, 13 Jun 2018 06:39:07 -0700 (PDT) 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; bh=qrsxaBZYx49B8HbIr0ZHtgNUiO/vDop9DN7nlKdtUXc=; b=plXbMclRwDXL3C2YIl1xujSteq/fOTCi1awL58zbb7O0enNUT9Txnw4m0csOQY8avh cHknE1fmKUyMYgCnptkDgVht9FREzX4/g0spyVGv0ERkRDZ2xuhaXM0trN5uH2STzytu lW9GLNufzmqHn2I70dnI1VBpVhtiFpaeUoAus= 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; bh=qrsxaBZYx49B8HbIr0ZHtgNUiO/vDop9DN7nlKdtUXc=; b=a/Z6xyBi3/4pMWS52Yu6+lmORysvAXOYXuCGmLF816tNHJSrDhbrTVd8XOcPgC/6QX pU+eZ2pITJqk/7tsOqtnDl0OJlDy9Xg47Ko0ho0M3Mh5uLB5y8ECPv7vPjredZtg6rBn rdZ5/QMgNJZMfF802JwGK49egDFkQxzXc/oozeXzwQkDlqE2XR96bWtJDkL9krPkafVg qQ6xnv0GPiiuA+3fjzRxd37bKGhup2bXW3qpXRKs4DB2AV9Kmx4IWaJdI8sZkPDU87Pd LsF0evfy0v+iBGQUCWHgXvJK6DmZdRj+wrEyN1fYrv/9SS3XdYxdpD/pEvYaKDWTmcHm v5ZA== X-Gm-Message-State: APt69E3cx/4qxv2IA+uWNf2mgy8viYJIt3KuVdIx/h4RqJpUsy3HkjWU Zq977oXA7XFSiAyHGNJwS9vr5Q== X-Google-Smtp-Source: ADUXVKLBv4nLaP7LhXknNmvOHTXtAxUBKI8XedrNX51yzYETG+1dfT4QtE0QkuWIn5Fv7YqZ44FMlA== X-Received: by 2002:a1c:d884:: with SMTP id p126-v6mr3317589wmg.110.1528897147285; Wed, 13 Jun 2018 06:39:07 -0700 (PDT) Received: from [192.168.5.19] (IOO-I3.static.anw.at. [195.234.100.13]) by smtp.gmail.com with ESMTPSA id o138-v6sm4732853wmg.10.2018.06.13.06.39.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Jun 2018 06:39:05 -0700 (PDT) Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation To: Amit Langote , Dmitry Dolgov <9erthalion6@gmail.com> Cc: juergen+postgresql@strobel.info, pgsql-bugs@lists.postgresql.org, PG Bug reporting form References: <152746742177.1291.9847032632907407358@wrigleys.postgresql.org> <23628f29-6cb7-7cea-4329-84774374e335@lab.ntt.co.jp> From: =?UTF-8?Q?J=c3=bcrgen_Strobel?= Message-ID: <2fd8e258-af80-aab8-8028-30fb1320443a@strobel.info> Date: Wed, 13 Jun 2018 15:39:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="AKeDD0WqdaacAnftxKAiqHENz1o2yOXIO" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --AKeDD0WqdaacAnftxKAiqHENz1o2yOXIO Content-Type: multipart/mixed; boundary="Q4IXrjE7y5XyJ2rgpSvWGBCYIpl0ARlKR"; protected-headers="v1" From: =?UTF-8?Q?J=c3=bcrgen_Strobel?= To: Amit Langote , Dmitry Dolgov <9erthalion6@gmail.com> Cc: juergen+postgresql@strobel.info, pgsql-bugs@lists.postgresql.org, PG Bug reporting form Message-ID: <2fd8e258-af80-aab8-8028-30fb1320443a@strobel.info> Subject: Re: BUG #15212: Default values in partition tables don't work as expected and allow NOT NULL violation References: <152746742177.1291.9847032632907407358@wrigleys.postgresql.org> <23628f29-6cb7-7cea-4329-84774374e335@lab.ntt.co.jp> In-Reply-To: --Q4IXrjE7y5XyJ2rgpSvWGBCYIpl0ARlKR Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 06/13/2018 11:42 AM, Amit Langote wrote: > Hi. >=20 > On 2018/06/07 23:08, Dmitry Dolgov wrote: >>> On 7 June 2018 at 15:53, Dmitry Dolgov <9erthalion6@gmail.com> wrote:= >>>> On 6 June 2018 at 10:00, Amit Langote wrote: >>>> On 2018/05/28 9:30, PG Bug reporting form wrote: >>>>> The following bug has been logged on the website: >>>>> >>>>> Bug reference: 15212 >>>>> Logged by: J=C3=BCrgen Strobel >>>>> Email address: juergen+postgresql@strobel.info >>>>> PostgreSQL version: 10.4 >>>>> Operating system: Debian >>>>> Description: >>>>> >>>>> I found unexpected behavior when playing around with declarative >>>>> partitioning. >>>>> First, any way to define defaults on (child) partition tables is si= lently >>>>> ignored when inserting into the master table, but not when insertin= g into >>>>> the child table. =2E.. >>> >>> Well, since documentation says that partitioning build on top of inhe= ritance, >>> and for inheritance: >>> >>> If the new table explicitly specifies a default value for the col= umn, this >>> default overrides any defaults from inherited declarations of the= column. >>> >>> So one may think it should be the same for partitioning as well. >> >> "The same for partitioning" - I mean the same approach when in all the= >> situations (whether it's an insert into a parent table or a partition)= a >> partition default value will take precedence. >=20 > I think you have a point. Before partitioning, one would either insert= > directly into the child table or use a trigger to redirect an insert on= > parent into one of the child tables. In both cases, child table's defa= ult > value would be used, because the insert query would mention the child > table name. >=20 > With partitioning, inserts into parent are internally handled in a way > that bypasses the processing which would otherwise fill a partition's o= wn > default values for columns whose value is missing in the input row. >=20 > That said, I'd like to make sure before writing a patch if the feature = of > being able to set defaults on partition level is something that users w= ill > want in the long run. >=20 > Thanks, > Amit >=20 I agree, and I imagine especially being able to use per-partition sequences would be a common use case. That was my motivation when I discovered it, and it was very counter intuitive to me. Thanks for the NULL violation patch btw. Best regards, J=C3=BCrgen --Q4IXrjE7y5XyJ2rgpSvWGBCYIpl0ARlKR-- --AKeDD0WqdaacAnftxKAiqHENz1o2yOXIO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEzEUBhshzZ4ebf+dVfUXCogVOOZ0FAlshHngACgkQfUXCogVO OZ1Jrw//WEVx3jzLladcMc45yAjUkZOZXi/XFGBBlw53zBejWkq3Mrqr8/4u9oZV pA5mWAkmGxgnhZHHea8tBXfGSphEwozTZwg6xdACCihCZLPCtLqTNRgLHgK3M0f/ T6IId2kjM+o3cB3aVkuHYeQS4L6MJkla/ZkFXFBxq/xjxxsy99mLisaGc/DzxybV wBQ+YhZGnjZFEepGl15AF5g60BzC0ieZm3Hrssylrdj6IE+zLbu0oKJv+rBYJpyP JHei84AvrLP+j4tkmIydl34QjXlYJEJHQsOSg6s0dO9A9zgeY7DteT8kbHT/0W2q alwrvNY7T+NCcEWeiBSqXpwKH1vy3hDBXQmYRe7eNGPL2bQWRUg0a/DZbtc/xPCw P8+gJLhPVnU1La6DoFHcq60uuRV2Z3bK1/3TWImjG5cFkvA4KwWagFyb1qm5chmv AWrl3epO8Uy9+iEkGl1bijWgZPYtOKytLLvQQzFe5CYMdWyFaTyXQPptKMELrq5E bpHOAvI5y2kb2YDigOpo7mPspBn6SSJvswOiHMHo0ecdrn8YIR/mtwM+iS1UYFN6 2Do1otaPMF4hGjiI6nYIumDZQbTZuzguIGrqGgK5UKsKb5t/3j70ZNGkjPuo7JwN bBPlhhb62d0Pvo00WgIZ7BqMtNllg42ZGrxOVbgkBVznIQd8aH0= =1zjY -----END PGP SIGNATURE----- --AKeDD0WqdaacAnftxKAiqHENz1o2yOXIO--