Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

Поиск
Список
Период
Сортировка
От jian he
Тема Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Дата
Msg-id CACJufxGh=L6YPr37Y4t+ZfReBeWdv8aiNEk7VoyhYyP7d6L-4w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Add SPLIT PARTITION/MERGE PARTITIONS commands  (jian he <jian.universality@gmail.com>)
Ответы Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Список pgsql-hackers
On Wed, Aug 20, 2025 at 5:22 PM jian he <jian.universality@gmail.com> wrote:
>
> this time, I only checked
> v52-0001-Implement-ALTER-TABLE-.-MERGE-PARTITIONS-.-comma.patch
>
> typedef struct PartitionCmd
> {
>     NodeTag        type;
>     RangeVar   *name;            /* name of partition to attach/detach/merge */
>     PartitionBoundSpec *bound;    /* FOR VALUES, if attaching */
>     List       *partlist;        /* list of partitions, for MERGE PARTITION
>                                  * command */
>     bool        concurrent;
> } PartitionCmd;

/*
 * PartitionCmd - info for ALTER TABLE/INDEX ATTACH/DETACH PARTITION commands
 */
typedef struct PartitionCmd
the above comments also need to be updated?


+-- Use indexscan for testing indexes after merging partitions
+SET enable_seqscan = OFF;
+
+SELECT * FROM sales_all WHERE sales_state = 'Warsaw';
+SELECT * FROM sales_list WHERE sales_state = 'Warsaw';
+SELECT * FROM sales_list WHERE salesperson_name = 'Ivanov';
+
+RESET enable_seqscan;

``+SELECT * FROM sales_all WHERE sales_state = 'Warsaw';``
may ultimately fall back to using  seqscan?
so we need to use
``explain(costs off)`` to see if it use indexscan or not.


+ /*
+ * We reject whole-row variables because the whole point of LIKE is
+ * that the new table's rowtype might later diverge from the parent's.
+ * So, while translation might be possible right now, it wouldn't be
+ * possible to guarantee it would work in future.
+ */
+ if (found_whole_row)
+ ereport(ERROR,
+ errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot convert whole-row table reference"),
+ errdetail("Constraint \"%s\" contains a whole-row reference to table \"%s\".",
+  ccname,
+  RelationGetRelationName(parent_rel)));
this error is unlikely to happen, we can simply use elog(ERROR, ....),
rather than  ereport.

evaluateGeneratedExpressionsAndCheckConstraints seem not necessary?
we should make the MergePartitionsMoveRows code pattern aligned with
ATRewriteTable.
by comparing these two function, i found that before call table_scan_getnextslot
we need to switch memory context to EState->ecxt_per_tuple_memor
please check the attached changes.

Вложения

В списке pgsql-hackers по дате отправления: