Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit94da2a6

Browse files
committed
Use RangeVarGetRelidExtended() in AlterSequence()
This allows us to combine the opening and the ownership check.Reported-by: Robert Haas <robertmhaas@gmail.com>
1 parent41839b7 commit94da2a6

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

‎src/backend/commands/sequence.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,13 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
429429
HeapTupleseqtuple;
430430
HeapTuplenewdatatuple;
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));

‎src/test/regress/expected/sequence.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ DROP SEQUENCE myseq2;
307307
ALTER SEQUENCE IF EXISTS sequence_test2 RESTART WITH 24
308308
INCREMENT BY 4 MAXVALUE 36 MINVALUE 5 CYCLE;
309309
NOTICE: relation "sequence_test2" does not exist, skipping
310-
ALTER SEQUENCEpg_class CYCLE; -- error, not a sequence
311-
ERROR: "pg_class" is not a sequence
310+
ALTER SEQUENCEserialTest1 CYCLE; -- error, not a sequence
311+
ERROR: "serialtest1" is not a sequence
312312
CREATE SEQUENCE sequence_test2 START WITH 32;
313313
CREATE SEQUENCE sequence_test4 INCREMENT BY -1;
314314
SELECT nextval('sequence_test2');

‎src/test/regress/sql/sequence.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ DROP SEQUENCE myseq2;
172172
ALTERSEQUENCE IF EXISTS sequence_test2 RESTART WITH24
173173
INCREMENT BY4 MAXVALUE36 MINVALUE5 CYCLE;
174174

175-
ALTERSEQUENCEpg_class CYCLE;-- error, not a sequence
175+
ALTERSEQUENCEserialTest1 CYCLE;-- error, not a sequence
176176

177177
CREATESEQUENCEsequence_test2 START WITH32;
178178
CREATESEQUENCEsequence_test4 INCREMENT BY-1;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp