summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-02-06 15:17:27 -0500
committerPeter Eisentraut <peter_e@gmx.net>2017-02-06 15:27:01 -0500
commitab82340a43bebe57a3db0e52bb74120b3bb53ae5 (patch)
tree66a8ace42acbc116e9d9e6fbe27f03cf31dc3b78 /src/backend
parentad6af3fc4256c0e1eecf5d93d510da4b44e0d480 (diff)
Avoid permission failure in pg_sequences.last_value
Before, reading pg_sequences.last_value would fail unless the user had appropriate sequence permissions, which would make the pg_sequences view cumbersome to use. Instead, return null instead of the real value when there are no permissions. From: Michael Paquier <michael.paquier@gmail.com> Reported-by: Shinoda, Noriyoshi <noriyoshi.shinoda@hpe.com>
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/catalog/system_views.sql6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql
index 28be27a07ec..907e0fb6301 100644
--- a/src/backend/catalog/system_views.sql
+++ b/src/backend/catalog/system_views.sql
@@ -175,7 +175,11 @@ CREATE OR REPLACE VIEW pg_sequences AS
S.seqincrement AS increment_by,
S.seqcycle AS cycle,
S.seqcache AS cache_size,
- pg_sequence_last_value(C.oid) AS last_value
+ CASE
+ WHEN has_sequence_privilege(C.oid, 'SELECT,USAGE'::text)
+ THEN pg_sequence_last_value(C.oid)
+ ELSE NULL
+ END AS last_value
FROM pg_sequence S JOIN pg_class C ON (C.oid = S.seqrelid)
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE NOT pg_is_other_temp_schema(N.oid)