pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: vidushi2504@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18407: ALTER TABLE SET SCHEMA on foreign table with SERIAL column does not move sequence to new schema
Date: Mon, 25 Mar 2024 12:17:25 -0400
Message-ID: <2497748.1711383445@sss.pgh.pa.us> (raw)
In-Reply-To: <18407-4fd07373d252c6a0@postgresql.org>
References: <18407-4fd07373d252c6a0@postgresql.org>

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?

			regards, tom lane





view thread (4+ messages)  latest in thread

Message-ID: <2497748.1711383445@sss.pgh.pa.us>
Permalink:  ../2497748.1711383445@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2497748.1711383445@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, vidushi2504@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18407: ALTER TABLE SET SCHEMA on foreign table with SERIAL column does not move sequence to new schema
  In-Reply-To: <2497748.1711383445@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox