Re: BUG #18407: ALTER TABLE SET SCHEMA on foreign table with SERIAL column does not move sequence to new schema - Mailing list pgsql-bugs

From Peter Eisentraut
Subject Re: BUG #18407: ALTER TABLE SET SCHEMA on foreign table with SERIAL column does not move sequence to new schema
Date
Msg-id b3176e79-19a6-496c-9416-e95f5c1675f4@eisentraut.org
Whole thread Raw
In response to Re: BUG #18407: ALTER TABLE SET SCHEMA on foreign table with SERIAL column does not move sequence to new schema  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #18407: ALTER TABLE SET SCHEMA on foreign table with SERIAL column does not move sequence to new schema  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
On 25.03.24 17:17, Tom Lane wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
>> I created a foreign table with a serial column and then moved the table to a
>> different schema. The sequence bound to the table column wasn't moved to the
>> new schema. I expected the sequence to be moved as well just like it works
>> for regular tables.
> 
> Hmm ... that does seem fairly inconsistent.  It looks like the cause
> is in AlterTableNamespaceInternal:
> 
>      /* Fix other dependent stuff */
>      if (rel->rd_rel->relkind == RELKIND_RELATION ||
>          rel->rd_rel->relkind == RELKIND_MATVIEW ||
>          rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
>      {
>          AlterIndexNamespaces(classRel, rel, oldNspOid, nspOid, objsMoved);
>          AlterSeqNamespaces(classRel, rel, oldNspOid, nspOid,
>                             objsMoved, AccessExclusiveLock);
>          AlterConstraintNamespaces(RelationGetRelid(rel), oldNspOid, nspOid,
>                                    false, objsMoved);
>      }
> 
> It's probably reasonable to have this relkind gating for
> AlterIndexNamespaces, although I'm not sure it saves much to
> skip that, either.  But we can have sequences attached to
> foreign tables, and I think maybe constraints as well.
> Maybe it'd be best to just drop this relkind check altogether?

Yes, seems better to remove the relkind check.




pgsql-bugs by date:

Previous
From: Subhrajit Mutsuddi
Date:
Subject: Walsender getting klilled, ERROR: out of memory in server logs
Next
From: Peter Eisentraut
Date:
Subject: Re: Regression tests fail with musl libc because libpq.so can't be loaded