Re: partitioning and identity column

Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>

From: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: Peter Eisentraut <peter@eisentraut.org>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-04-26T12:57:58Z
Lists: pgsql-hackers
Thanks Alexander for the report.

On Fri, Apr 26, 2024 at 5:30 PM Alexander Lakhin <exclusion@gmail.com>
wrote:

> Hello Ashutosh and Peter,
>
> 16.01.2024 21:59, Peter Eisentraut wrote:
> > On 09.01.24 15:10, Ashutosh Bapat wrote:
> >> Here's complete patch-set.
> >
> > Looks good!  Committed.
> >
>
> Please take a look at a new error case introduced by 699586315:
> CREATE TABLE tbl1 (a int PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY)
>    PARTITION BY LIST (a);
> CREATE TABLE tbl2 PARTITION OF tbl1 DEFAULT;
>
> CREATE TABLE tbl3 (LIKE tbl2 INCLUDING IDENTITY);
> ERROR:  no owned sequence found
>

I don't think creating a table like a partition is common or even useful.
Usually it would create it from partitithe oned table. But if we consider
that to be a use case, I think the error is expected since a partition
doesn't have its own identity; it shares it with the partitioned table.
Maybe we could give a better message. But I will look into this and fix it
if the solution makes sense.

Do you want to track this in open items?

-- 
Best Wishes,
Ashutosh Bapat

Commits

  1. Fix assorted bugs related to identity column in partitioned tables

  2. Remove extra check_stack_depth() from dropconstraint_internal()

  3. Support identity columns in partitioned tables

  4. doc: Add Identity Column section under Data Definition chapter

  5. Assert that partition inherits from only one parent in MergeAttributes()

  6. doc: Decorate PostgreSQL with productname tag

  7. Fix prologue of get_partition_ancestors()