</para>
<para>
- In order to be able to copy the initial table or sequence data, the role
- used for the replication connection must have the <literal>SELECT</literal>
- privilege on a published table or sequence (or be a superuser).
+ In order to be able to copy the initial table data or synchronize
+ sequences, the role used for the replication connection must have the
+ <literal>SELECT</literal> privilege on a published table or sequence (or be
+ a superuser).
</para>
<para>
security within the database is of no concern.
</para>
+ <para>
+ When synchronizing sequences with
+ <literal>run_as_owner = true</literal>, the subscription owner similarly
+ needs <literal>UPDATE</literal> privilege on the target sequence and does
+ not need privileges to <literal>SET ROLE</literal> to the sequence owner.
+ </para>
+
<para>
On the publisher, privileges are only checked once at the start of a
replication connection and are not re-checked as each change record is read.
if (sub_insuffperm_seqs_idx)
{
get_sequences_string(sub_insuffperm_seqs_idx, &seqstr);
+
+ /*
+ * With run_as_owner enabled, sequence synchronization runs as the
+ * subscription owner, so a missing UPDATE privilege should be granted
+ * to that role. Otherwise, the worker switches to the sequence owner
+ * before checking privileges, so no useful GRANT hint can be
+ * provided.
+ */
ereport(WARNING,
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg_plural("insufficient privileges on subscriber sequence (%s)",
"insufficient privileges on subscriber sequences (%s)",
list_length(sub_insuffperm_seqs_idx),
- seqstr.data));
+ seqstr.data),
+ MySubscription->runasowner ?
+ errhint_plural("Grant UPDATE on the sequence to the subscription "
+ "owner on the subscriber.",
+ "Grant UPDATE on the sequences to the subscription "
+ "owner on the subscriber.",
+ list_length(sub_insuffperm_seqs_idx)) : 0);
}
if (pub_insuffperm_seqs_idx)
errmsg_plural("insufficient privileges on publisher sequence (%s)",
"insufficient privileges on publisher sequences (%s)",
list_length(pub_insuffperm_seqs_idx),
- seqstr.data));
+ seqstr.data),
+ errhint_plural("Grant SELECT on the sequence to the role used for "
+ "the replication connection on the publisher.",
+ "Grant SELECT on the sequences to the role used for "
+ "the replication connection on the publisher.",
+ list_length(pub_insuffperm_seqs_idx)));
}
if (missing_seqs_idx)