Re: pg_sequence_last_value() for unlogged sequences on standbys
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, pgsql-hackers@postgresql.org
Date: 2024-05-07T17:44:16Z
Lists: pgsql-hackers
Nathan Bossart <nathandbossart@gmail.com> writes:
> Okay, so are we okay to back-patch something like v1? Or should we also
> return NULL for other sessions' temporary schemas on primaries? That would
> change the condition to something like
> char relpersist = seqrel->rd_rel->relpersistence;
> if (relpersist == RELPERSISTENCE_PERMANENT ||
> (relpersist == RELPERSISTENCE_UNLOGGED && !RecoveryInProgress()) ||
> !RELATION_IS_OTHER_TEMP(seqrel))
> {
> ...
> }
Should be AND'ing not OR'ing the !TEMP condition, no? Also I liked
your other formulation of the persistence check better.
> I personally think that would be fine to back-patch since pg_sequences
> already filters it out anyway.
+1 to include that, as it offers a defense if someone invokes this
function directly. In HEAD we could then rip out the test in the
view.
BTW, I think you also need something like
- int64 result;
+ int64 result = 0;
Your compiler may not complain about result being possibly
uninitialized, but IME others will.
regards, tom lane
Commits
-
Remove redundant privilege check from pg_sequences system view.
- 7967d10c5b49 18.0 landed
-
Fix pg_sequence_last_value() for unlogged sequences on standbys.
- 2812059d3eea 12.20 landed
- 09ec5d45548a 13.16 landed
- c8714230ad35 14.13 landed
- 857d280c6528 15.8 landed
- c1664c8eefad 16.4 landed
- 3cb2f13ac500 17.0 landed