File tree Expand file tree Collapse file tree 3 files changed +10
-12
lines changed Expand file tree Collapse file tree 3 files changed +10
-12
lines changed Original file line number Diff line number Diff line change @@ -429,10 +429,13 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
429429 HeapTuple seqtuple ;
430430 HeapTuple newdatatuple ;
431431
432- /* Open and lock sequence. */
433- relid = RangeVarGetRelid (stmt -> sequence ,
434- ShareRowExclusiveLock ,
435- stmt -> missing_ok );
432+ /* Open and lock sequence, and check for ownership along the way. */
433+ relid = RangeVarGetRelidExtended (stmt -> sequence ,
434+ ShareRowExclusiveLock ,
435+ stmt -> missing_ok ,
436+ false,
437+ RangeVarCallbackOwnsRelation ,
438+ NULL );
436439 if (relid == InvalidOid )
437440 {
438441 ereport (NOTICE ,
@@ -443,11 +446,6 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
443446
444447 init_sequence (relid , & elm , & seqrel );
445448
446- /* allow ALTER to sequence owner only */
447- if (!pg_class_ownercheck (relid , GetUserId ()))
448- aclcheck_error (ACLCHECK_NOT_OWNER , ACL_KIND_CLASS ,
449- stmt -> sequence -> relname );
450-
451449 rel = heap_open (SequenceRelationId , RowExclusiveLock );
452450 seqtuple = SearchSysCacheCopy1 (SEQRELID ,
453451 ObjectIdGetDatum (relid ));
Original file line number Diff line number Diff line change @@ -307,8 +307,8 @@ DROP SEQUENCE myseq2;
307307ALTER SEQUENCE IF EXISTS sequence_test2 RESTART WITH 24
308308 INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE;
309309NOTICE: relation "sequence_test2" does not exist, skipping
310- ALTER SEQUENCE pg_class CYCLE; -- error, not a sequence
311- ERROR: "pg_class " is not a sequence
310+ ALTER SEQUENCE serialTest1 CYCLE; -- error, not a sequence
311+ ERROR: "serialtest1 " is not a sequence
312312CREATE SEQUENCE sequence_test2 START WITH 32;
313313CREATE SEQUENCE sequence_test4 INCREMENT BY -1;
314314SELECT nextval('sequence_test2');
Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ DROP SEQUENCE myseq2;
172172ALTER SEQUENCE IF EXISTS sequence_test2 RESTART WITH 24
173173 INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE;
174174
175- ALTER SEQUENCE pg_class CYCLE; -- error, not a sequence
175+ ALTER SEQUENCE serialTest1 CYCLE; -- error, not a sequence
176176
177177CREATE SEQUENCE sequence_test2 START WITH 32 ;
178178CREATE SEQUENCE sequence_test4 INCREMENT BY - 1 ;
You can’t perform that action at this time.
0 commit comments