Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>
Cc: jian he <jian(dot)universality(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Date: 2025-06-05 01:41:47
Message-ID: CAPpHfdugpFGUk-udjcroJLi6_5ypS9-3CxoC+MbRvpjncDy11w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Dmitry!

On Wed, Jun 4, 2025 at 10:44 PM Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru> wrote:
> Thank you very much for review.

Thank you for your work on this patch. I have some additional notes on
this patch.

Why don't you use *existing_relation_id argument of
RangeVarGetAndCheckCreationNamespace(), when it is called from
createPartitionTable() and ATExecSplitPartition()? This argument provide
an elegant way to find a duplicate table with the same name.

It also seems that 0002 patch has the following error message, which aren't
experienced in the regression tests.

+ datum = list_nth(spec->upperdatums, abs(cmpval) - 1);
+ ereport(ERROR,
+ errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("upper bound of partition \"%s\" is not
equal to upper bound of split partition",
+ relname),
+ parser_errposition(pstate, datum->location));

+ ereport(ERROR,
+ errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("new partition \"%s\" cannot have this value
because split partition does not have",
+ relname),
+ parser_errposition(pstate, overlap_location));

+ ereport(ERROR,
+ errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("new partitions do not have value %s but split
partition does",
+ searchNull ? "NULL" :
get_list_partvalue_string(notFoundVal)));

+ ereport(ERROR,
+
errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("DEFAULT partition should be
one"),
+ parser_errposition(pstate,
sps->name->location));

+ ereport(ERROR,
+ errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("one partition in the list should be DEFAULT because
split partition is DEFAULT"),
+ parser_errposition(pstate, ((SinglePartitionSpec *)
linitial(partlist))->name->location));

+ ereport(ERROR,
+ errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
+ errmsg("new partition cannot be DEFAULT because DEFAULT
partition already exists"),
+ parser_errposition(pstate, spsDef->name->location));

+ ereport(ERROR,
+ errcode(ERRCODE_CHECK_VIOLATION),
+ errmsg("can not find partition for split partition
row"),
+ errtable(splitRel));

------
Regards,
Alexander Korotkov
Supabase

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2025-06-05 01:44:12 Re: queryId constant squashing does not support prepared statements
Previous Message Michael Paquier 2025-06-05 01:20:09 Re: a couple of small cleanup patches for DSM-related code