aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/sequence.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2017-06-13 14:58:17 -0400
committerPeter Eisentraut <peter_e@gmx.net>2017-06-16 10:24:50 -0400
commit94da2a6a9a05776953524424a3d8079e54bc5d94 (patch)
tree348b53acd03dddebedbc1648c3094a9cb68c7eaa /src/backend/commands/sequence.c
parent41839b7abc85f21dd7ce76ab9cd1d7533c53cf9c (diff)
downloadpostgresql-94da2a6a9a05776953524424a3d8079e54bc5d94.tar.gz
postgresql-94da2a6a9a05776953524424a3d8079e54bc5d94.zip
Use RangeVarGetRelidExtended() in AlterSequence()
This allows us to combine the opening and the ownership check. Reported-by: Robert Haas <robertmhaas@gmail.com>
Diffstat (limited to 'src/backend/commands/sequence.c')
-rw-r--r--src/backend/commands/sequence.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 2d820e5cebc..031bbc874de 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -429,10 +429,13 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
HeapTuple seqtuple;
HeapTuple newdatatuple;
- /* Open and lock sequence. */
- relid = RangeVarGetRelid(stmt->sequence,
- ShareRowExclusiveLock,
- stmt->missing_ok);
+ /* Open and lock sequence, and check for ownership along the way. */
+ relid = RangeVarGetRelidExtended(stmt->sequence,
+ ShareRowExclusiveLock,
+ stmt->missing_ok,
+ false,
+ RangeVarCallbackOwnsRelation,
+ NULL);
if (relid == InvalidOid)
{
ereport(NOTICE,
@@ -443,11 +446,6 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
init_sequence(relid, &elm, &seqrel);
- /* allow ALTER to sequence owner only */
- if (!pg_class_ownercheck(relid, GetUserId()))
- aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_CLASS,
- stmt->sequence->relname);
-
rel = heap_open(SequenceRelationId, RowExclusiveLock);
seqtuple = SearchSysCacheCopy1(SEQRELID,
ObjectIdGetDatum(relid));