回答編集履歴

2

微修正

2019/08/03 02:10

投稿

退会済みユーザー
test CHANGED
@@ -70,9 +70,9 @@
70
70
 
71
71
 
72
72
 
73
- ```
73
+ ```psql
74
74
 
75
- SELECT l.pid,d.datname,l.locktype,relation::regclass,transactionid,l.mode,l.granted
75
+ > SELECT l.pid,d.datname,l.locktype,relation::regclass,transactionid,l.mode,l.granted
76
76
 
77
77
  FROM pg_locks l LEFT JOIN pg_database d ON l.database = d.oid
78
78
 
@@ -108,9 +108,9 @@
108
108
 
109
109
 
110
110
 
111
- ```
111
+ ```psql
112
112
 
113
- SELECT l.pid,d.datname,l.locktype,relation::regclass,transactionid,l.mode,l.granted
113
+ > SELECT l.pid,d.datname,l.locktype,relation::regclass,transactionid,l.mode,l.granted
114
114
 
115
115
  FROM pg_locks l LEFT JOIN pg_database d ON l.database = d.oid
116
116
 
@@ -156,9 +156,9 @@
156
156
 
157
157
 
158
158
 
159
- ```
159
+ ```psql
160
160
 
161
- SELECT l.pid,d.datname,l.locktype,relation::regclass,transactionid,l.mode,l.granted
161
+ > SELECT l.pid,d.datname,l.locktype,relation::regclass,transactionid,l.mode,l.granted
162
162
 
163
163
  FROM pg_locks l LEFT JOIN pg_database d ON l.database = d.oid
164
164
 
@@ -184,9 +184,9 @@
184
184
 
185
185
  hoge_pkey は index
186
186
 
187
- ```
187
+ ```psql
188
188
 
189
- select * from hoge_pkey;
189
+ > select * from hoge_pkey;
190
190
 
191
191
  ERROR: "hoge_pkey" is an index
192
192
 

1

微修正

2019/08/03 02:10

投稿

退会済みユーザー
test CHANGED
@@ -58,7 +58,11 @@
58
58
 
59
59
 
60
60
 
61
- > トランザクションの実行中は常に、サーバプロセスはその仮想トランザクションID上に排他的ロックをかけます。 もしある永続IDがトランザクションに割り当てられる普通はトランザクションがデータベースの状態を変化させるときのみに発生しますと、トランザクションは終了するまで永続トランザクションIDに対して排他ロックを保持します。 **あるトランザクションが他のトランザクションを特定して終了まで待機しなければならないと判断した場合、他とみなしたトランザクションのIDに対し共有ロックを獲得するように試み、目的を達します。 (仮想IDであるか永続IDであるかは、その状況によります)。 これは、他とみなしたトランザクションが完了し、そしてロックを解放した場合のみ成功します。**
61
+ [pg_locks原文](https://www.postgresql.org/docs/9.6/view-pg-locks.html)
62
+
63
+
64
+
65
+ > Throughout running a transaction, a server process holds an exclusive lock on the transaction's virtual transaction ID. If a permanent ID is assigned to the transaction (which normally happens only if the transaction changes the state of the database), it also holds an exclusive lock on the transaction's permanent transaction ID until it ends. **When a process finds it necessary to wait specifically for another transaction to end, it does so by attempting to acquire share lock on the other transaction's ID (either virtual or permanent ID depending on the situation). That will succeed only when the other transaction terminates and releases its locks.**
62
66
 
63
67
 
64
68