Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
16365ac7
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
16365ac7
编写于
8月 04, 2001
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add LOCK A,B,C functionality as LOCK A;LOCK B;LOCK C; as agreed.
Neil Padgett
上级
0bfc64b3
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
117 addition
and
32 deletion
+117
-32
doc/src/sgml/ref/lock.sgml
doc/src/sgml/ref/lock.sgml
+12
-4
src/backend/commands/command.c
src/backend/commands/command.c
+94
-17
src/backend/nodes/copyfuncs.c
src/backend/nodes/copyfuncs.c
+3
-3
src/backend/nodes/equalfuncs.c
src/backend/nodes/equalfuncs.c
+2
-2
src/backend/parser/gram.y
src/backend/parser/gram.y
+3
-3
src/include/nodes/parsenodes.h
src/include/nodes/parsenodes.h
+2
-2
src/interfaces/ecpg/preproc/preproc.y
src/interfaces/ecpg/preproc/preproc.y
+1
-1
未找到文件。
doc/src/sgml/ref/lock.sgml
浏览文件 @
16365ac7
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/lock.sgml,v 1.2
4 2001/07/09 22:18:33 tgl
Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/ref/lock.sgml,v 1.2
5 2001/08/04 19:38:59 momjian
Exp $
Postgres documentation
-->
...
...
@@ -15,7 +15,7 @@ Postgres documentation
LOCK
</refname>
<refpurpose>
Explicitly lock a table inside a transaction
Explicitly lock a table
/ tables
inside a transaction
</refpurpose>
</refnamediv>
<refsynopsisdiv>
...
...
@@ -23,8 +23,8 @@ Postgres documentation
<date>2001-07-09</date>
</refsynopsisdivinfo>
<synopsis>
LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable>
LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable> IN <replaceable class="PARAMETER">lockmode</replaceable> MODE
LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable>
[,...]
LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable>
[,...]
IN <replaceable class="PARAMETER">lockmode</replaceable> MODE
where <replaceable class="PARAMETER">lockmode</replaceable> is one of:
...
...
@@ -373,6 +373,7 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
An example for this rule was given previously when discussing the
use of SHARE ROW EXCLUSIVE mode rather than SHARE mode.
</para>
</listitem>
</itemizedlist>
...
...
@@ -383,6 +384,12 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
</para>
</note>
<para>
When locking multiple tables, the command LOCK a, b; is equivalent to LOCK
a; LOCK b;. The tables are locked one-by-one in the order specified in the
<command>LOCK</command> command.
</para>
<refsect2 id="R2-SQL-LOCK-3">
<refsect2info>
<date>1999-06-08</date>
...
...
@@ -406,6 +413,7 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
<para>
<command>LOCK</command> works only inside transactions.
</para>
</refsect2>
</refsect1>
...
...
src/backend/commands/command.c
浏览文件 @
16365ac7
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.13
6 2001/07/16 05:06:57 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.13
7 2001/08/04 19:38:59 momjian
Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
...
...
@@ -1985,7 +1985,6 @@ needs_toast_table(Relation rel)
return
(
tuple_length
>
TOAST_TUPLE_THRESHOLD
);
}
/*
*
* LOCK TABLE
...
...
@@ -1994,18 +1993,36 @@ needs_toast_table(Relation rel)
void
LockTableCommand
(
LockStmt
*
lockstmt
)
{
int
relCnt
;
relCnt
=
length
(
lockstmt
->
rellist
);
/* Handle a single relation lock specially to avoid overhead on likely the
most common case */
if
(
relCnt
==
1
)
{
/* Locking a single table */
Relation
rel
;
int
aclresult
;
char
*
relname
;
relname
=
strVal
(
lfirst
(
lockstmt
->
rellist
));
rel
=
heap_openr
(
lockstmt
->
relname
,
NoLock
);
freeList
(
lockstmt
->
rellist
);
rel
=
heap_openr
(
relname
,
NoLock
);
if
(
rel
->
rd_rel
->
relkind
!=
RELKIND_RELATION
)
elog
(
ERROR
,
"LOCK TABLE: %s is not a table"
,
lockstmt
->
relname
);
elog
(
ERROR
,
"LOCK TABLE: %s is not a table"
,
relname
);
if
(
lockstmt
->
mode
==
AccessShareLock
)
aclresult
=
pg_aclcheck
(
lockstmt
->
relname
,
GetUserId
(),
ACL_SELECT
);
aclresult
=
pg_aclcheck
(
relname
,
GetUserId
(),
ACL_SELECT
);
else
aclresult
=
pg_aclcheck
(
lockstmt
->
relname
,
GetUserId
(),
aclresult
=
pg_aclcheck
(
relname
,
GetUserId
(),
ACL_UPDATE
|
ACL_DELETE
);
if
(
aclresult
!=
ACLCHECK_OK
)
...
...
@@ -2013,7 +2030,67 @@ LockTableCommand(LockStmt *lockstmt)
LockRelation
(
rel
,
lockstmt
->
mode
);
pfree
(
relname
);
heap_close
(
rel
,
NoLock
);
/* close rel, keep lock */
}
else
{
List
*
p
;
Relation
*
RelationArray
;
Relation
*
pRel
;
/* Locking multiple tables */
/* Create an array of relations */
RelationArray
=
palloc
(
relCnt
*
sizeof
(
Relation
));
pRel
=
RelationArray
;
/* Iterate over the list and populate the relation array */
foreach
(
p
,
lockstmt
->
rellist
)
{
char
*
relname
=
strVal
(
lfirst
(
p
));
int
aclresult
;
*
pRel
=
heap_openr
(
relname
,
NoLock
);
if
((
*
pRel
)
->
rd_rel
->
relkind
!=
RELKIND_RELATION
)
elog
(
ERROR
,
"LOCK TABLE: %s is not a table"
,
relname
);
if
(
lockstmt
->
mode
==
AccessShareLock
)
aclresult
=
pg_aclcheck
(
relname
,
GetUserId
(),
ACL_SELECT
);
else
aclresult
=
pg_aclcheck
(
relname
,
GetUserId
(),
ACL_UPDATE
|
ACL_DELETE
);
if
(
aclresult
!=
ACLCHECK_OK
)
elog
(
ERROR
,
"LOCK TABLE: permission denied"
);
pRel
++
;
pfree
(
relname
);
}
/* Now, lock all the relations, closing each after it is locked
(Keeping the locks)
*/
for
(
pRel
=
RelationArray
;
pRel
<
RelationArray
+
relCnt
;
pRel
++
)
{
LockRelation
(
*
pRel
,
lockstmt
->
mode
);
heap_close
(
*
pRel
,
NoLock
);
}
/* Free the relation array */
pfree
(
RelationArray
);
}
}
...
...
src/backend/nodes/copyfuncs.c
浏览文件 @
16365ac7
...
...
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.14
8 2001/07/16 19:07:37
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.14
9 2001/08/04 19:38:59
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -2425,8 +2425,8 @@ _copyLockStmt(LockStmt *from)
{
LockStmt
*
newnode
=
makeNode
(
LockStmt
);
if
(
from
->
relname
)
newnode
->
relname
=
pstrdup
(
from
->
relname
);
Node_Copy
(
from
,
newnode
,
rellist
);
newnode
->
mode
=
from
->
mode
;
return
newnode
;
...
...
src/backend/nodes/equalfuncs.c
浏览文件 @
16365ac7
...
...
@@ -20,7 +20,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.9
6 2001/07/16 19:07:38
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.9
7 2001/08/04 19:38:59
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1283,7 +1283,7 @@ _equalDropUserStmt(DropUserStmt *a, DropUserStmt *b)
static
bool
_equalLockStmt
(
LockStmt
*
a
,
LockStmt
*
b
)
{
if
(
!
equal
str
(
a
->
relname
,
b
->
relname
))
if
(
!
equal
(
a
->
rellist
,
b
->
rellist
))
return
false
;
if
(
a
->
mode
!=
b
->
mode
)
return
false
;
...
...
src/backend/parser/gram.y
浏览文件 @
16365ac7
...
...
@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.23
8 2001/07/16 19:07:40
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.23
9 2001/08/04 19:38:59
momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -3280,11 +3280,11 @@ DeleteStmt: DELETE FROM relation_expr where_clause
}
;
LockStmt: LOCK_P opt_table relation_name opt_lock
LockStmt: LOCK_P opt_table relation_name
_list
opt_lock
{
LockStmt *n = makeNode(LockStmt);
n->rel
name
= $3;
n->rel
list
= $3;
n->mode = $4;
$$ = (Node *)n;
}
...
...
src/include/nodes/parsenodes.h
浏览文件 @
16365ac7
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parsenodes.h,v 1.13
6 2001/07/16 19:07:40
momjian Exp $
* $Id: parsenodes.h,v 1.13
7 2001/08/04 19:38:59
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -760,7 +760,7 @@ typedef struct VariableResetStmt
typedef
struct
LockStmt
{
NodeTag
type
;
char
*
relname
;
/* relation
to lock */
List
*
rellist
;
/* relations
to lock */
int
mode
;
/* lock mode */
}
LockStmt
;
...
...
src/interfaces/ecpg/preproc/preproc.y
浏览文件 @
16365ac7
...
...
@@ -2421,7 +2421,7 @@ DeleteStmt: DELETE FROM relation_expr where_clause
}
;
LockStmt: LOCK_P opt_table relation_name opt_lock
LockStmt: LOCK_P opt_table relation_name
_list
opt_lock
{
$$ = cat_str(4, make_str("lock"), $2, $3, $4);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录