Re: Add SPLIT PARTITION/MERGE PARTITIONS commands

From: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Date: 2024-04-07 22:15:06
Message-ID: CAPpHfdsTh90nLg0New96Mf9xuo92rPLoqKEsMgQx7_Ws0oxOAA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Alexander!

On Sun, Apr 7, 2024 at 10:00 PM Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
> 07.04.2024 01:22, Alexander Korotkov wrote:
> > I've pushed 0001 and 0002. I didn't push 0003 for the following reasons.
>
> Please try the following (erroneous) query:
> CREATE TABLE t1(i int, t text) PARTITION BY LIST (t);
> CREATE TABLE t1pa PARTITION OF t1 FOR VALUES IN ('A');
>
> CREATE TABLE t2 (i int, t text) PARTITION BY RANGE (t);
> ALTER TABLE t2 SPLIT PARTITION t1pa INTO
> (PARTITION t2a FOR VALUES FROM ('A') TO ('B'),
> PARTITION t2b FOR VALUES FROM ('B') TO ('C'));
>
> that triggers an assertion failure:
> TRAP: failed Assert("datums != NIL"), File: "partbounds.c", Line: 3434, PID: 1841459
>
> or a segfault (in a non-assert build):
> Program terminated with signal SIGSEGV, Segmentation fault.
>
> #0 pg_detoast_datum_packed (datum=0x0) at fmgr.c:1866
> 1866 if (VARATT_IS_COMPRESSED(datum) || VARATT_IS_EXTERNAL(datum))
> (gdb) bt
> #0 pg_detoast_datum_packed (datum=0x0) at fmgr.c:1866
> #1 0x000055f38c5d5e3f in bttextcmp (...) at varlena.c:1834
> #2 0x000055f38c6030dd in FunctionCall2Coll (...) at fmgr.c:1161
> #3 0x000055f38c417c83 in partition_rbound_cmp (...) at partbounds.c:3525
> #4 check_partition_bounds_for_split_range (...) at partbounds.c:5221
> #5 check_partitions_for_split (...) at partbounds.c:5688
> #6 0x000055f38c256c49 in transformPartitionCmdForSplit (...) at parse_utilcmd.c:3451
> #7 transformAlterTableStmt (...) at parse_utilcmd.c:3810
> #8 0x000055f38c2bdf9c in ATParseTransformCmd (...) at tablecmds.c:5650

Thank you for spotting this. This seems like a missing check. I'm
going to get a closer look at this tomorrow.

------
Regards,
Alexander Korotkov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2024-04-07 22:26:31 Re: Use streaming read API in ANALYZE
Previous Message Andres Freund 2024-04-07 22:12:29 Re: Streaming read-ready sequential scan code