Re: split tablecmds.c

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, pgsql-hackers(at)postgresql(dot)org, euler(at)eulerto(dot)com, andres(at)anarazel(dot)de
Subject: Re: split tablecmds.c
Date: 2025-12-02 00:03:53
Message-ID: aS4s6d2m5tH9yddy@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Dec 01, 2025 at 04:43:37PM -0600, Nathan Bossart wrote:
> I tried to move the partitioning-related code to a new file, and it wasn't
> too bad. Note that there are a couple of internal-to-tablecmds.c things
> that need to be exported. Besides that, the attached patch is still pretty
> rough, and I'm not sure I correctly placed the line in the sand when
> determining what stays and what goes, but this at least shows the general
> shape of what's needed. (BTW git was generating an atrocious diff for
> tablecmds.c. You might need to set the diff algorithm to "minimal" if you
> are similarly affected.)

Moving all the partition-specific code into a different file makes
sense here. Is partcmds.c as name the best fit though? Perhaps a
tablecmds_partition.c, with other files named tablecmds_popo.c to
indicate the sub-systems formerly in tablecmds.c?

> src/backend/commands/Makefile | 1 +
> src/backend/commands/meson.build | 1 +
> src/backend/commands/partcmds.c | 3377 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> src/backend/commands/tablecmds.c | 3456 +--------------------------------------------------------------------------------------------
> src/backend/partitioning/partbounds.c | 1 +
> src/include/commands/partcmds.h | 53 ++
> src/include/commands/tablecmds.h | 134 +++-
> 7 files changed, 3575 insertions(+), 3448 deletions(-)

The new contents of tablecmds.h don't have any strong dependency with
tablecmds.h, so perhaps having the "internal" structures like the ones
you are moving here into a new tablecmds_internal.h would be cleaner?

Another sub-area of tablecmds.c that could be split is I think the
rewrite logic. It has a lot of its own perks that become harder to
figure out the more tablecmds.c gets bloated.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2025-12-02 00:16:31 Re: new commitfest transition guidance
Previous Message Peter Geoghegan 2025-12-02 00:00:45 Re: index prefetching