Re: pg_sequence_last_value() for unlogged sequences on standbys

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: pg_sequence_last_value() for unlogged sequences on standbys
Дата
Msg-id 4179588.1715103856@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: pg_sequence_last_value() for unlogged sequences on standbys  (Nathan Bossart <nathandbossart@gmail.com>)
Ответы Re: pg_sequence_last_value() for unlogged sequences on standbys
Список 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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Nathan Bossart
Дата:
Сообщение: Re: pg_sequence_last_value() for unlogged sequences on standbys
Следующее
От: "Tristan Partin"
Дата:
Сообщение: Re: Use pgstat_kind_infos to read fixed shared stats structs