Re: Logical Replication of sequences

From: vignesh C <vignesh21(at)gmail(dot)com>
To: Ajin Cherian <itsajin(at)gmail(dot)com>
Cc: shveta malik <shveta(dot)malik(at)gmail(dot)com>, Peter Smith <smithpb2250(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, Shlok Kyal <shlok(dot)kyal(dot)oss(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Euler Taveira <euler(at)eulerto(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz>, "Zhijie Hou (Fujitsu)" <houzj(dot)fnst(at)fujitsu(dot)com>, "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org>
Subject: Re: Logical Replication of sequences
Date: 2025-05-29 14:41:15
Message-ID: CALDaNm3DoYr7=TEg3pmHYjCWNL-zxyTDL8_LiAP1_Pnyd-SYJg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Some review comments for patch 0001:
> 1. In src/backend/commands/sequence.c
> in pg_sequence_state()
> + /* open and lock sequence */
> + init_sequence(seq_relid, &elm, &seqrel);
> +
> + if (pg_class_aclcheck(elm->relid, GetUserId(),
> + ACL_SELECT | ACL_USAGE) != ACLCHECK_OK)
> + ereport(ERROR,
> + errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
> + errmsg("permission denied for sequence %s",
> + RelationGetRelationName(seqrel)));
> +
>
> How about using aclcheck_error for this, which also supports error messages for specific access errors. Most other objects seem to be using this.
> if (aclresult != ACLCHECK_OK)
> aclcheck_error(aclresult, get_relkind_objtype(seqrel->relkind),
> RelationGetRelationName(seqrel));

I felt this is ok in this case as it is used similarly in
nextval_internal, currval_oid, lastval, do_setval and
pg_sequence_parameters also

> 2. in function pg_sequence_state()
> +
> + UnlockReleaseBuffer(buf);
> + relation_close(seqrel, NoLock);
>
> Ideally the corresponding close for init_sequence is sequence_close() rather than relation_close()

Fixed

The comment for the same is handled in the v2025029 version patch
attached at [1].
[1] - https://www.postgresql.org/message-id/CALDaNm0ssEaHW8by5kd1%3DwE7LPMhhBiV6971JbFWsY6Qwp7NMw%40mail.gmail.com

Regards,
Vignesh

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2025-05-29 14:43:32 Re: pg18: Virtual generated columns are not (yet) safe when superuser selects from them
Previous Message vignesh C 2025-05-29 14:39:13 Re: Logical Replication of sequences