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

Commitc117838

Browse files
committed
Disallow SELECT FOR UPDATE/SHARE on sequences.
We can't allow this because such an operation stores its transaction XIDinto the sequence tuple's xmax. Because VACUUM doesn't process sequences(and we don't want it to start doing so), such an xmax value won't getfrozen, meaning it will eventually refer to nonexistent pg_clog storage,and even wrap around completely. Since the row lock is ignored by nextvaland setval, the usefulness of the operation is highly debatable anyway.Per reports of trouble with pgpool 3.0, which had ill-advisedly startedusing such commands as a form of locking.In HEAD, also disallow SELECT FOR UPDATE/SHARE on toast tables. Althoughthis does work safely given the current implementation, there seems nogood reason to allow it. I refrained from changing that behavior inback branches, however.
1 parentb26d8fd commitc117838

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

‎src/backend/executor/execMain.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,45 @@ InitPlan(QueryDesc *queryDesc, int eflags)
722722
break;
723723
}
724724

725+
/*
726+
* Check that relation is a legal target for marking.
727+
*
728+
* In most cases parser and/or planner should have noticed this
729+
* already, but they don't cover all cases.
730+
*/
731+
if (relation)
732+
{
733+
switch (relation->rd_rel->relkind)
734+
{
735+
caseRELKIND_RELATION:
736+
/* OK */
737+
break;
738+
caseRELKIND_SEQUENCE:
739+
/* Must disallow this because we don't vacuum sequences */
740+
ereport(ERROR,
741+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
742+
errmsg("cannot lock rows in sequence \"%s\"",
743+
RelationGetRelationName(relation))));
744+
break;
745+
caseRELKIND_TOASTVALUE:
746+
/* This will be disallowed in 9.1, but for now OK */
747+
break;
748+
caseRELKIND_VIEW:
749+
/* Should not get here */
750+
ereport(ERROR,
751+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
752+
errmsg("cannot lock rows in view \"%s\"",
753+
RelationGetRelationName(relation))));
754+
break;
755+
default:
756+
ereport(ERROR,
757+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
758+
errmsg("cannot lock rows in relation \"%s\"",
759+
RelationGetRelationName(relation))));
760+
break;
761+
}
762+
}
763+
725764
erm= (ExecRowMark*)palloc(sizeof(ExecRowMark));
726765
erm->relation=relation;
727766
erm->rti=rc->rti;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp