Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uPFth-003TfZ-GN for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jun 2025 07:29:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uPFtf-0000AV-2P for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Jun 2025 07:29:19 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uPFte-0000AN-Ou for pgsql-hackers@lists.postgresql.org; Wed, 11 Jun 2025 07:29:19 +0000 Received: from mail-ua1-x92b.google.com ([2607:f8b0:4864:20::92b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uPFtd-001OGj-1U for pgsql-hackers@lists.postgresql.org; Wed, 11 Jun 2025 07:29:19 +0000 Received: by mail-ua1-x92b.google.com with SMTP id a1e0cc1a2514c-87ecca2dc48so1026644241.1 for ; Wed, 11 Jun 2025 00:29:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749626953; x=1750231753; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5sRv4zkb954ux1o0e5l/lZaONefKp7bNwQJn9dhfB78=; b=es9c+XA5249HccvoQ+0gcJUk4IoXq1Fip81Hbe3w2+SG3hBiuXP6cEfI0KHfRu5LJn Q0itzBcvFpcnlYNwPOuc8EoLqP2oTk3uXfgYFRavpqLke5FE8KnLmHBrG8NgGUie04aQ qGuwz3yPr/yqwt0+pLHs4Fpvzv13eeEIplt38XALdo5tx4HPhKq+QzH6yB4sDxcQA2ay 7bYcNeeTJKS8Y9eQvvKc0MQvYRdjMU4igPxMGQbiNwxigECEyB/u+5GpmgjY6UmbEbpv u2+LdfXah2AJmXc9Xlf3f2Mt6bdQAs6DlRTSnC1WO3oSj0n5zjOw/5IbW7Kzx5suNDku oemw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749626953; x=1750231753; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5sRv4zkb954ux1o0e5l/lZaONefKp7bNwQJn9dhfB78=; b=wonuBQjUdYfOALKY8yR/tDW4BJWFURCWIt4VqVbUQ3T0wKHb+F+20AF0R6W7a/c/AF W/DprJZn3u0R9j8o0sjG9L49PTh1Mkzs/O+H+7e1FzA+XVJgbY7mlaHouMmC38KfA5bW SBhuQNEsX1AdMPoF/lX+CcpOYa5fEv2NvqMxtLLFn0RcrkD7hjAs45oSY70bK//IhWVe 4uFvb6k0M7raP359Jq1dWZuGWcvDoaok5Jv39IqI5+RrsfhAZete8P9t6+ZgEpqxThSa sWf0mnfOkIOZPsCe3wx85KRxW4C/W6FYptE6m3s9L6IBcn8rWXoIOxzKOAv0jW9Vy1Ky Xxug== X-Gm-Message-State: AOJu0YxtP3BXbMPr9/TaxlabCG1PmEkV/4x0rvMx+u+50AElq4SqO2xl HS9LstZUL+/okNKjR/kYlYVLhabmuM7bzuBbeWZfpBSDSHXcur4U7iuwfBoBrFMzKZAHNXpb8Qi Xu/X2jon7TI6mlbXg6NaAFzppZRs049JA+euxGdkH6A== X-Gm-Gg: ASbGnctfXO56bmrYsOhDbygyM5lapn2e1crPOWshB7M46n+cJJXA9Yc3vjqKKCl6dV+ ald7ool2WO5uuRQqVmC98YpFarHlNT51285PbBlgso/jhiapm11PM+6xSQqLflHlMTWvCAK/tmt VKy91TXBOimi0/KowswruHl3u8W2VIjulSaYCA1IOLNp7y7ZfVNtmj X-Google-Smtp-Source: AGHT+IG3IeK7axnhqz72XXFrpdHnaO6f+882v3jicgrWIr/GdioKbW+qULibTztM2uA3igCWmAXXRYPgXIUn5kI2o2E= X-Received: by 2002:a05:6102:f95:b0:4e7:3efd:ac76 with SMTP id ada2fe7eead31-4e7bba13384mr1624109137.8.1749626953110; Wed, 11 Jun 2025 00:29:13 -0700 (PDT) MIME-Version: 1.0 References: <171085360143.2046436.7217841141682511557.pgcf@coridan.postgresql.org> <4e2764f7-f6be-478f-8d7f-f921dbd10f5f@postgrespro.ru> <7fdaf3e8-4c05-4739-bee6-98acc068d1c7@postgrespro.ru> <4433b492-9e97-4334-96d9-ddaaa5083099@postgrespro.ru> <67ecf5fb-e63d-4284-be75-d0479eef81aa@postgrespro.ru> <884bcf9e-d6e3-4b0c-8dcb-7f2110070ac9@postgrespro.ru> <1e74c9fd-830e-4544-b0de-e49ea4b04029@postgrespro.ru> In-Reply-To: <1e74c9fd-830e-4544-b0de-e49ea4b04029@postgrespro.ru> From: jian he Date: Wed, 11 Jun 2025 15:28:36 +0800 X-Gm-Features: AX0GCFuGav5c1E0M-3UzLd3VX362hhE6LDm89ukfX-YemhOAP4RT4MCZ-D-TSAg Message-ID: Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands To: Dmitry Koval Cc: pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 11, 2025 at 8:06=E2=80=AFAM Dmitry Koval wrote: > > >Do getAttributesList need to care about pg_attribute.attidentity? > >currently MERGE PARTITION seems to work fine with identity columns, > >this issue i didn't dig deeper. > > Probably after commit [3] partition's identity columns shares the > identity space (i.e. underlying sequence) as the corresponding > columns of the partitioned table. So call BuildDescForRelation in > createPartitionTable function should copy pg_attribute.attidentity > for new partition. > but BuildDescForRelation is based on getAttributesList, in getAttributesList, assign pg_attribute.attidentity to def->identity should be safe, IMHO. + + If merged partitions have different owners, an error will be generat= ed. + The owner of the merged partitions will be the owner of the new partition. + + + It is the user's responsibility to setup ACL on t= he + new partition. + since they are related, these two can be one ? + + If merged partitions have individual constraints, those constraints = will + be dropped because command uses partitioned table as a model to crea= te + the constraints. + I feel like it's not fully accurate, the following is what I can come up wi= th: + + When partitions are merged, any individual objects belonging to those + partitions, such as constraints or statistics will be dropped. This occur= s + because ALTER TABLE MERGE PARTITIONS uses the partitioned table itself as= the + template to define these objects. + > > >I am wondering right after createPartitionTable, > >do we need a CommandCounterIncrement? > >because later moveMergedTablesRows will use the output of > >createPartitionTable. > > We call CommandCounterIncrement in createPartitionTable function right > after heap_create_with_catalog (same code in create_toast_table, > make_new_heap, DefineRelation functions). We need an additional > CommandCounterIncrement call in case we use objects created after this > point. But we probably don't use these objects (in function > moveMergedTablesRows too). > As mentioned in the previous thread [1], moveMergedTablesRows need latest relcache entry for newPartRel. so I guess, put one CommandCounterIncrement at the end of createPartitionTable should be fine, which I already did in [1]. [1]: https://postgr.es/m/CACJufxH3mfNYfHy9+dCUZPhOsmVRtJUJbWU1vH248Lg0eZjhz= Q@mail.gmail.com > 3. > >I only want to allow HEAP_TABLE_AM_OID to be used > >in the merge partition, > >I guess that would avoid unintended consequences. > > Thanks for the clarification. Isn't this limitation too strong? > It is very likely that the user will create an AM based on > HEAP_TABLE_AM_OID, in which case the code should work. > ok. if you looking at ATExecDetachPartition, we have: /* * Detaching the partition might involve TOAST table access, so ensure = we * have a valid snapshot. */ PushActiveSnapshot(GetTransactionSnapshot()); /* Do the final part of detaching */ DetachPartitionFinalize(rel, partRel, concurrent, defaultPartOid); PopActiveSnapshot(); do we need do the same to the following DetachPartitionFinalize: foreach_ptr(RelationData, mergingPartition, mergingPartitionsList) { /* Remove the pg_inherits row first. */ RemoveInheritance(mergingPartition, rel, false); /* Do the final part of detaching. */ DetachPartitionFinalize(rel, mergingPartition, false, defaultPartOi= d); }