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
Postgres documentation
-->
-->
...
@@ -15,7 +15,7 @@ Postgres documentation
...
@@ -15,7 +15,7 @@ Postgres documentation
LOCK
LOCK
</refname>
</refname>
<refpurpose>
<refpurpose>
Explicitly lock a table inside a transaction
Explicitly lock a table
/ tables
inside a transaction
</refpurpose>
</refpurpose>
</refnamediv>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdiv>
...
@@ -23,8 +23,8 @@ Postgres documentation
...
@@ -23,8 +23,8 @@ Postgres documentation
<date>2001-07-09</date>
<date>2001-07-09</date>
</refsynopsisdivinfo>
</refsynopsisdivinfo>
<synopsis>
<synopsis>
LOCK [ TABLE ] <replaceable class="PARAMETER">name</replaceable>
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>
[,...]
IN <replaceable class="PARAMETER">lockmode</replaceable> MODE
where <replaceable class="PARAMETER">lockmode</replaceable> is one of:
where <replaceable class="PARAMETER">lockmode</replaceable> is one of:
...
@@ -373,6 +373,7 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
...
@@ -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
An example for this rule was given previously when discussing the
use of SHARE ROW EXCLUSIVE mode rather than SHARE mode.
use of SHARE ROW EXCLUSIVE mode rather than SHARE mode.
</para>
</para>
</listitem>
</listitem>
</itemizedlist>
</itemizedlist>
...
@@ -383,6 +384,12 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
...
@@ -383,6 +384,12 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
</para>
</para>
</note>
</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">
<refsect2 id="R2-SQL-LOCK-3">
<refsect2info>
<refsect2info>
<date>1999-06-08</date>
<date>1999-06-08</date>
...
@@ -406,6 +413,7 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
...
@@ -406,6 +413,7 @@ ERROR <replaceable class="PARAMETER">name</replaceable>: Table does not exist.
<para>
<para>
<command>LOCK</command> works only inside transactions.
<command>LOCK</command> works only inside transactions.
</para>
</para>
</refsect2>
</refsect2>
</refsect1>
</refsect1>
...
...
src/backend/commands/command.c
浏览文件 @
16365ac7
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* 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
* NOTES
* The PerformAddAttribute() code, like most of the relation
* The PerformAddAttribute() code, like most of the relation
...
@@ -1984,8 +1984,7 @@ needs_toast_table(Relation rel)
...
@@ -1984,8 +1984,7 @@ needs_toast_table(Relation rel)
MAXALIGN
(
data_length
);
MAXALIGN
(
data_length
);
return
(
tuple_length
>
TOAST_TUPLE_THRESHOLD
);
return
(
tuple_length
>
TOAST_TUPLE_THRESHOLD
);
}
}
/*
/*
*
*
* LOCK TABLE
* LOCK TABLE
...
@@ -1994,26 +1993,104 @@ needs_toast_table(Relation rel)
...
@@ -1994,26 +1993,104 @@ needs_toast_table(Relation rel)
void
void
LockTableCommand
(
LockStmt
*
lockstmt
)
LockTableCommand
(
LockStmt
*
lockstmt
)
{
{
Relation
rel
;
int
relCnt
;
int
aclresult
;
rel
=
heap_openr
(
lockstmt
->
relname
,
NoLock
);
rel
Cnt
=
length
(
lockstmt
->
rellist
);
if
(
rel
->
rd_rel
->
relkind
!=
RELKIND_RELATION
)
/* Handle a single relation lock specially to avoid overhead on likely the
elog
(
ERROR
,
"LOCK TABLE: %s is not a table"
,
lockstmt
->
relname
);
most common case */
if
(
lockstmt
->
mode
==
AccessShareLock
)
if
(
relCnt
==
1
)
aclresult
=
pg_aclcheck
(
lockstmt
->
relname
,
GetUserId
(),
ACL_SELECT
);
{
else
aclresult
=
pg_aclcheck
(
lockstmt
->
relname
,
GetUserId
(),
/* Locking a single table */
ACL_UPDATE
|
ACL_DELETE
);
Relation
rel
;
int
aclresult
;
char
*
relname
;
relname
=
strVal
(
lfirst
(
lockstmt
->
rellist
));
freeList
(
lockstmt
->
rellist
);
rel
=
heap_openr
(
relname
,
NoLock
);
if
(
rel
->
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"
);
LockRelation
(
rel
,
lockstmt
->
mode
);
pfree
(
relname
);
heap_close
(
rel
,
NoLock
);
/* close rel, keep lock */
}
else
{
List
*
p
;
Relation
*
RelationArray
;
Relation
*
pRel
;
if
(
aclresult
!=
ACLCHECK_OK
)
/* Locking multiple tables */
elog
(
ERROR
,
"LOCK TABLE: permission denied"
);
LockRelation
(
rel
,
lockstmt
->
mode
);
/* Create an array of relations */
heap_close
(
rel
,
NoLock
);
/* close rel, keep lock */
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 @@
...
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* 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)
...
@@ -2425,8 +2425,8 @@ _copyLockStmt(LockStmt *from)
{
{
LockStmt
*
newnode
=
makeNode
(
LockStmt
);
LockStmt
*
newnode
=
makeNode
(
LockStmt
);
if
(
from
->
relname
)
Node_Copy
(
from
,
newnode
,
rellist
);
newnode
->
relname
=
pstrdup
(
from
->
relname
);
newnode
->
mode
=
from
->
mode
;
newnode
->
mode
=
from
->
mode
;
return
newnode
;
return
newnode
;
...
...
src/backend/nodes/equalfuncs.c
浏览文件 @
16365ac7
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* 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)
...
@@ -1283,7 +1283,7 @@ _equalDropUserStmt(DropUserStmt *a, DropUserStmt *b)
static
bool
static
bool
_equalLockStmt
(
LockStmt
*
a
,
LockStmt
*
b
)
_equalLockStmt
(
LockStmt
*
a
,
LockStmt
*
b
)
{
{
if
(
!
equal
str
(
a
->
relname
,
b
->
relname
))
if
(
!
equal
(
a
->
rellist
,
b
->
rellist
))
return
false
;
return
false
;
if
(
a
->
mode
!=
b
->
mode
)
if
(
a
->
mode
!=
b
->
mode
)
return
false
;
return
false
;
...
...
src/backend/parser/gram.y
浏览文件 @
16365ac7
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
*
*
* IDENTIFICATION
* 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
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
@@ -3280,11 +3280,11 @@ DeleteStmt: DELETE FROM relation_expr where_clause
...
@@ -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);
LockStmt *n = makeNode(LockStmt);
n->rel
name
= $3;
n->rel
list
= $3;
n->mode = $4;
n->mode = $4;
$$ = (Node *)n;
$$ = (Node *)n;
}
}
...
...
src/include/nodes/parsenodes.h
浏览文件 @
16365ac7
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* 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
...
@@ -760,7 +760,7 @@ typedef struct VariableResetStmt
typedef
struct
LockStmt
typedef
struct
LockStmt
{
{
NodeTag
type
;
NodeTag
type
;
char
*
relname
;
/* relation
to lock */
List
*
rellist
;
/* relations
to lock */
int
mode
;
/* lock mode */
int
mode
;
/* lock mode */
}
LockStmt
;
}
LockStmt
;
...
...
src/interfaces/ecpg/preproc/preproc.y
浏览文件 @
16365ac7
...
@@ -2421,7 +2421,7 @@ DeleteStmt: DELETE FROM relation_expr where_clause
...
@@ -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);
$$ = 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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录