Re: Global temporary tables

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: Kirk Wolak <wolakk(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Global temporary tables
Date: 2026-07-13 09:12:50
Message-ID: CAEZATCVeGPE-NdWMtOX99GiiR+o2ocyT0kEZB2CPprG-a5ivrg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 7 Jul 2026 at 02:09, Japin Li <japinli(at)hotmail(dot)com> wrote:
>
> On Mon, 06 Jul 2026 at 11:12, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
>
> > Regarding pg_class.reloncommit, 'p' (preserve) seems correct for a
> > sequence attached to a GTT with ON COMMIT DELETE ROWS, because the
> > sequence data is preserved. For indexes, not so much, because the
> > index data is deleted on commit. I guess it could be NULL for anything
> > that's not a table.
> >
>
> +1 for setting it to NULL for non‑table objects, since CREATE INDEX and
> CREATE SEQUENCE do not support the ON COMMIT clause.
>

After thinking about that some more, I decided that it was neater to
go with reloncommit = 'n' (for "none") rather than NULL for relations
that aren't temporary tables (and for temporary tables without an ON
COMMIT action). That's simpler for the code that reads it, so it
doesn't need to worry about NULLs. Also, since nearly every other
column of pg_class is marked NOT NULL, it seems neater to do the same
here too.

Attached is a rebased patchset doing that, plus a number of other
fixes in response to other review comments. This now includes some
additional pg_dump tests and tab-completion support.

Regards,
Dean

Attachment Content-Type Size
v9-0001-Save-temporary-table-ON-COMMIT-actions-to-pg_clas.patch text/x-patch 14.0 KB
v9-0002-Basic-support-for-global-temporary-tables.patch text/x-patch 157.8 KB
v9-0003-Support-indexes-on-global-temporary-tables.patch text/x-patch 36.2 KB
v9-0004-Support-global-temporary-sequences.patch text/x-patch 19.6 KB
v9-0005-Support-global-temporary-catalog-tables-and-add-p.patch text/x-patch 91.1 KB
v9-0006-Add-relation-statistics-columns-to-pg_temp_class.patch text/x-patch 53.2 KB
v9-0007-Add-relfrozenxid-and-relminmxid-columns-to-pg_tem.patch text/x-patch 56.7 KB
v9-0008-Add-pg_temp_statistic-global-temporary-catalog-ta.patch text/x-patch 32.7 KB
v9-0009-Add-pg_temp_statistic_ext_data-global-temporary-c.patch text/x-patch 36.7 KB
v9-0010-Add-pg_temp_index-global-temporary-catalog-table.patch text/x-patch 69.0 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2026-07-13 09:15:15 Re: Global temporary tables
Previous Message Rui Zhao 2026-07-13 09:08:30 Re: allow spread checkpoints when changing checksums online