Skip to content

Commit d40a3aa

Browse files
committed
fix
1 parent 8e88426 commit d40a3aa

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

201705/20170521_01.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ string_agg(
108108
'Lock_Granted: '||case when granted is null then 'NULL' else granted::text end||' , Mode: '||case when mode is null then 'NULL' else mode::text end||' , FastPath: '||case when fastpath is null then 'NULL' else fastpath::text end||' , VirtualTransaction: '||case when virtualtransaction is null then 'NULL' else virtualtransaction::text end||' , Session_State: '||case when state is null then 'NULL' else state::text end||chr(10)||
109109
'Username: '||case when usename is null then 'NULL' else usename::text end||' , Database: '||case when datname is null then 'NULL' else datname::text end||' , Client_Addr: '||case when client_addr is null then 'NULL' else client_addr::text end||' , Client_Port: '||case when client_port is null then 'NULL' else client_port::text end||' , Application_Name: '||case when application_name is null then 'NULL' else application_name::text end||chr(10)||
110110
'Xact_Start: '||case when xact_start is null then 'NULL' else xact_start::text end||' , Query_Start: '||case when query_start is null then 'NULL' else query_start::text end||' , Xact_Elapse: '||case when (now()-xact_start) is null then 'NULL' else (now()-xact_start)::text end||' , Query_Elapse: '||case when (now()-query_start) is null then 'NULL' else (now()-query_start)::text end||chr(10)||
111-
'Query: '||case when query is null then 'NULL' else query::text end,
111+
'SQL (Current SQL in Transaction): '||chr(10)||
112+
case when query is null then 'NULL' else query::text end,
112113
chr(10)||'--------'||chr(10)
113114
order by
114115
( case mode
@@ -123,11 +124,11 @@ order by
123124
when 'AccessExclusiveLock' then 8
124125
else 0
125126
end ) desc,
126-
(case when granted then 0 else 1 end)
127+
(case when granted then 0 else 1 end)
127128
) as lock_conflict
128129
from t_unionall
129130
group by
130-
locktype,datname,relation,page,tuple,virtualxid,transactionid::text,classid,objid,objsubid ;
131+
locktype,datname,relation,page,tuple,virtualxid,transactionid::text,classid,objid,objsubid ;
131132
```
132133

133134
如果觉得写SQL麻烦,可以将它创建为视图
@@ -178,7 +179,8 @@ string_agg(
178179
'Lock_Granted: '||case when granted is null then 'NULL' else granted::text end||' , Mode: '||case when mode is null then 'NULL' else mode::text end||' , FastPath: '||case when fastpath is null then 'NULL' else fastpath::text end||' , VirtualTransaction: '||case when virtualtransaction is null then 'NULL' else virtualtransaction::text end||' , Session_State: '||case when state is null then 'NULL' else state::text end||chr(10)||
179180
'Username: '||case when usename is null then 'NULL' else usename::text end||' , Database: '||case when datname is null then 'NULL' else datname::text end||' , Client_Addr: '||case when client_addr is null then 'NULL' else client_addr::text end||' , Client_Port: '||case when client_port is null then 'NULL' else client_port::text end||' , Application_Name: '||case when application_name is null then 'NULL' else application_name::text end||chr(10)||
180181
'Xact_Start: '||case when xact_start is null then 'NULL' else xact_start::text end||' , Query_Start: '||case when query_start is null then 'NULL' else query_start::text end||' , Xact_Elapse: '||case when (now()-xact_start) is null then 'NULL' else (now()-xact_start)::text end||' , Query_Elapse: '||case when (now()-query_start) is null then 'NULL' else (now()-query_start)::text end||chr(10)||
181-
'Query: '||case when query is null then 'NULL' else query::text end,
182+
'SQL (Current SQL in Transaction): '||chr(10)||
183+
case when query is null then 'NULL' else query::text end,
182184
chr(10)||'--------'||chr(10)
183185
order by
184186
( case mode
@@ -193,11 +195,11 @@ order by
193195
when 'AccessExclusiveLock' then 8
194196
else 0
195197
end ) desc,
196-
(case when granted then 0 else 1 end)
198+
(case when granted then 0 else 1 end)
197199
) as lock_conflict
198200
from t_unionall
199201
group by
200-
locktype,datname,relation,page,tuple,virtualxid,transactionid::text,classid,objid,objsubid ;
202+
locktype,datname,relation,page,tuple,virtualxid,transactionid::text,classid,objid,objsubid ;
201203
```
202204

203205
## 例子

0 commit comments

Comments
 (0)