From 02bcb728a8c6bfe21aab54ce15cb75266c42dfe3 Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Thu, 18 Jun 2026 21:46:27 +0900
Subject: [PATCH v2 2/2] doc: Clarify pg_get_sequence_data() privileges and
 NULL results

The documentation for pg_get_sequence_data() did not match the
function's behavior. It stated that either USAGE or SELECT privilege
was sufficient, but the function returns sequence data only when the
caller has SELECT privilege.

The documentation also did not explain that the function returns a row
containing all NULL values when sequence data cannot be returned, such
as when the sequence does not exist or the caller lacks the required
privilege.

Update the documentation to reflect the actual behavior, including the
required privilege and the result returned when sequence data is
unavailable.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Tristan Partin <tristan@partin.io>
Discussion: https://postgr.es/m/CAHGQGwGNTaXnBKUV510_P1KwhdbHT+kgZ4zU5njBHy7nCqdhzg@mail.gmail.com
---
 doc/src/sgml/func/func-sequence.sgml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/src/sgml/func/func-sequence.sgml b/doc/src/sgml/func/func-sequence.sgml
index 4a2a6dc9369..de266c36296 100644
--- a/doc/src/sgml/func/func-sequence.sgml
+++ b/doc/src/sgml/func/func-sequence.sgml
@@ -163,12 +163,13 @@ SELECT setval('myseq', 42, false);    <lineannotation>Next <function>nextval</fu
         <structfield>is_called</structfield> indicates whether the sequence has
         been used. <structfield>page_lsn</structfield> is the LSN corresponding
         to the most recent WAL record that modified this sequence relation.
+        This function returns a row of NULL values if the sequence does not
+        exist or if the current user lacks privileges on it.
        </para>
        <para>
         This function is primarily intended for internal use by pg_dump and by
         logical replication to synchronize sequences. It requires
-        <literal>USAGE</literal> or <literal>SELECT</literal> privilege on the
-        sequence.
+        <literal>SELECT</literal> privilege on the sequence.
        </para></entry>
       </row>
      </tbody>
-- 
2.53.0

