Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSiYC-0004Pj-LI for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 18:00:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pSiYB-0003Os-IP for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 18:00:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSiYB-0003Oh-5W for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 18:00:07 +0000 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pSiY8-0003fa-4A for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 18:00:06 +0000 Received: by mail-lf1-x132.google.com with SMTP id x40so3742070lfu.12 for ; Thu, 16 Feb 2023 10:00:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=8OlTAzdzOEoAk4rIF0zRRsHdGA97o7EBvJVMRm1aaMY=; b=l0vwY5UwKK5SlTJr7Nqkh2fv4ZwWgiB7tY+nAoFc8rs6JH/n71Pg8uF41nOJX0rAKJ XXbiJoYEkwNY2W9r+Z/lOvIBz+Nwav7z/UNplqGdpwOxw3YZ87FQpttCueT16bw+7ssC ccoJv8aqhMtrIX5xo/MY1lQdqRZ/l6/wj7iL1jhQfTdNR1OHENs2DTPyFOAnw34dOrpM 9nm5Mz0KjSnRmOHL+zIVUFdZK4mfAlX9wJ66P65678DLXoafxLu846hNcTO4tirUTbK2 e2VHDqCQR4tA5ZdGGvByiv0WIbwIlbsLKFXbhOJxa3bkDyay0EHDsbMkAifhWfLlC4mW 4z8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=8OlTAzdzOEoAk4rIF0zRRsHdGA97o7EBvJVMRm1aaMY=; b=ogNxS/llMs55nack1N9XZ+2mk+11mqaOfkgRYoz14ASHCb+/siZHEvsztJtT7s1Db7 BPnujkSiRgkbGYV+7wLneK3jrKrl7LRxdT5f6zf8ZocLqC+0Ux1RXLLDXYV8MY67FCuu E2k4/LPWEUsz8rTZ4CYWvmB8qZ+i1raDLUiD3KNCh5AFVY8NPU1tDr7M6vRroxniYpxw CTtD7CJ2ZWbcN2/eSv/6gTmTltPwU17HaT0XczOF0MTC7mIGB75xsYt2eOl6AHux4Fzb XVmQ/WC45GNXbU060s8k+VFdwkb1DYV2NmLal0uGBm/fGo/TJZjqMEZgfDbVhe8keKiI hOlQ== X-Gm-Message-State: AO0yUKXgIRwpn6GrB9nrHE0Lqc54IdZchXzrij4TLF+E4gpOsM9qcoQn CEB2BTRo9Z8Llb12jlzUklA= X-Google-Smtp-Source: AK7set88VKO2ZfxhWeDsdbpk06T2vZJQbw2cPsMQhzTmQz31EdE93XxUvRRWMAdb4nfUti8SqDlnCA== X-Received: by 2002:a19:c215:0:b0:4a9:39f4:579a with SMTP id l21-20020a19c215000000b004a939f4579amr1918274lfc.66.1676570402948; Thu, 16 Feb 2023 10:00:02 -0800 (PST) Received: from [1.0.0.7] ([178.155.5.245]) by smtp.gmail.com with ESMTPSA id t1-20020ac25481000000b004d16263b36bsm370557lfk.111.2023.02.16.10.00.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 16 Feb 2023 10:00:01 -0800 (PST) Content-Type: multipart/alternative; boundary="------------S5tSn7rnMiargV6j0WFzh0D4" Message-ID: <4a8200ca-8378-653e-38ed-b2e1f1611aa6@gmail.com> Date: Thu, 16 Feb 2023 21:00:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: ATTACH PARTITION seems to ignore column generation status To: Tom Lane , Amit Langote Cc: pgsql-hackers@lists.postgresql.org, Peter Eisentraut References: <2793383.1672944799@sss.pgh.pa.us> <3016779.1673026372@sss.pgh.pa.us> <44978.1673300465@sss.pgh.pa.us> <191819.1673318283@sss.pgh.pa.us> <378312.1673388786@sss.pgh.pa.us> <667767.1673470691@sss.pgh.pa.us> Content-Language: en-US From: Alexander Lakhin In-Reply-To: <667767.1673470691@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------S5tSn7rnMiargV6j0WFzh0D4 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hello, 11.01.2023 23:58, Tom Lane wrote: > Amit Langote writes: >> I've updated your disallow-generated-child-columns-2.patch to do this, >> and have also merged the delta post that I had attached with my last >> email, whose contents you sound to agree with. > Pushed with some further work to improve the handling of multiple- > inheritance cases. We still need to insist that all or none of the > parent columns are generated, but we don't have to require their > generation expressions to be alike: that can be resolved by letting > the child table override the expression, much as we've long done for > plain default expressions. (This did need some work in pg_dump > after all.) I'm pretty happy with where this turned out. I've encountered a query that triggers an assert added in that commit: CREATE TABLE t(a int, b int GENERATED ALWAYS AS (a) STORED) PARTITION BY RANGE (a); CREATE TABLE tp PARTITION OF t(b DEFAULT 1) FOR VALUES FROM (0) to (1); Core was generated by `postgres: law regression [local] CREATE TABLE                                 '. Program terminated with signal SIGABRT, Aborted. warning: Section `.reg-xstate/3152655' in core file too small. #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140460372887360) at ./nptl/pthread_kill.c:44 44      ./nptl/pthread_kill.c: No such file or directory. (gdb) bt #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140460372887360) at ./nptl/pthread_kill.c:44 #1  __pthread_kill_internal (signo=6, threadid=140460372887360) at ./nptl/pthread_kill.c:78 #2  __GI___pthread_kill (threadid=140460372887360, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3  0x00007fbf79f0e476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4  0x00007fbf79ef47f3 in __GI_abort () at ./stdlib/abort.c:79 #5  0x000055e76b35b322 in ExceptionalCondition (     conditionName=conditionName@entry=0x55e76b4a2240 "!(coldef->generated && !restdef->generated)",     fileName=fileName@entry=0x55e76b49ec71 "tablecmds.c", lineNumber=lineNumber@entry=3028) at assert.c:66 #6  0x000055e76afef8c3 in MergeAttributes (schema=0x55e76d480318, supers=supers@entry=0x55e76d474c18,     relpersistence=112 'p', is_partition=true, supconstr=supconstr@entry=0x7ffe945a3768) at tablecmds.c:3028 #7  0x000055e76aff0ef2 in DefineRelation (stmt=stmt@entry=0x55e76d44b2d8, relkind=relkind@entry=114 'r', ownerId=10,     ownerId@entry=0, typaddress=typaddress@entry=0x0,     queryString=queryString@entry=0x55e76d44a408 "CREATE TABLE tp PARTITION OF t(b DEFAULT 1) FOR VALUES FROM (0) to (1);") at tablecmds.c:861 ... Without asserts enables, the partition created successfully, and INSERT INTO t VALUES(0); SELECT * FROM t; yields: a | b ---+--- 0 | 1 (1 row) Is this behavior expected? Best regards, Alexander --------------S5tSn7rnMiargV6j0WFzh0D4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hello,

11.01.2023 23:58, Tom Lane wrote:
Amit Langote <amitlangote09@gmail.com> writes:
I've updated your disallow-generated-child-columns-2.patch to do this,
and have also merged the delta post that I had attached with my last
email, whose contents you sound to agree with.
Pushed with some further work to improve the handling of multiple-
inheritance cases.  We still need to insist that all or none of the
parent columns are generated, but we don't have to require their
generation expressions to be alike: that can be resolved by letting
the child table override the expression, much as we've long done for
plain default expressions.  (This did need some work in pg_dump
after all.)  I'm pretty happy with where this turned out.
I've encountered a query that triggers an assert added in that commit:
CREATE TABLE t(a int, b int GENERATED ALWAYS AS (a) STORED) PARTITION BY RANGE (a);
CREATE TABLE tp PARTITION OF t(b DEFAULT 1) FOR VALUES FROM (0) to (1);

Core was generated by `postgres: law regression [local] CREATE TABLE                                 '.
Program terminated with signal SIGABRT, Aborted.

warning: Section `.reg-xstate/3152655' in core file too small.
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140460372887360) at ./nptl/pthread_kill.c:44
44      ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=140460372887360) at ./nptl/pthread_kill.c:44
#1  __pthread_kill_internal (signo=6, threadid=140460372887360) at ./nptl/pthread_kill.c:78
#2  __GI___pthread_kill (threadid=140460372887360, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3  0x00007fbf79f0e476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4  0x00007fbf79ef47f3 in __GI_abort () at ./stdlib/abort.c:79
#5  0x000055e76b35b322 in ExceptionalCondition (
    conditionName=conditionName@entry=0x55e76b4a2240 "!(coldef->generated && !restdef->generated)",
    fileName=fileName@entry=0x55e76b49ec71 "tablecmds.c", lineNumber=lineNumber@entry=3028) at assert.c:66
#6  0x000055e76afef8c3 in MergeAttributes (schema=0x55e76d480318, supers=supers@entry=0x55e76d474c18,
    relpersistence=112 'p', is_partition=true, supconstr=supconstr@entry=0x7ffe945a3768) at tablecmds.c:3028
#7  0x000055e76aff0ef2 in DefineRelation (stmt=stmt@entry=0x55e76d44b2d8, relkind=relkind@entry=114 'r', ownerId=10,
    ownerId@entry=0, typaddress=typaddress@entry=0x0,
    queryString=queryString@entry=0x55e76d44a408 "CREATE TABLE tp PARTITION OF t(b DEFAULT 1) FOR VALUES FROM (0) to (1);") at tablecmds.c:861
...

Without asserts enables, the partition created successfully, and
INSERT INTO t VALUES(0);
SELECT * FROM t;
yields:
a | b  
---+---
0 | 1
(1 row)

Is this behavior expected?

Best regards,
Alexander
--------------S5tSn7rnMiargV6j0WFzh0D4--