-
Notifications
You must be signed in to change notification settings - Fork 312
/
channels2.sql
67 lines (63 loc) · 2.27 KB
/
channels2.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-- Copyright 2018 Tanel Poder. All rights reserved. More info at http://tanelpoder.com
-- Licensed under the Apache License, Version 2.0. See LICENSE.txt for terms & conditions.
--------------------------------------------------------------------------------
--
-- File name: channels.sql
-- Purpose: Report KSR channel message counts by channel endpoints
--
-- Author: Tanel Poder
-- Copyright: (c) http://www.tanelpoder.com
--
-- Usage: @channels
--
--------------------------------------------------------------------------------
--break on channel_name skip 1
col channels_program head PROGRAM for a20 truncate
col channels_descr FOR A30 word_wrap
SELECT * FROM (
SELECT
cd.name_ksrcdes channel_name
, cd.id_ksrcdes channels_descr
, c.ctxp_ksrchdl context_ptr
, c.addr handle_addr
, CASE WHEN BITAND(c.flags_ksrchdl, 1) = 1 THEN 'PUB ' END ||
CASE WHEN BITAND(c.flags_ksrchdl, 2) = 2 THEN 'SUB ' END ||
CASE WHEN BITAND(c.flags_ksrchdl, 16) = 16 THEN 'INA' END flags
, NVL(s.sid, -1) sid
, p.addr paddr
, p.program
, p.spid
, SUBSTR(NVL(s.program,p.program),INSTR(NVL(s.program,p.program),'(')) channels_program
, c.mesgcnt_ksrchdl mesg_count
, CASE WHEN BITAND(cd.scope_ksrcdes, 1) = 1 THEN 'ANY ' END ||
CASE WHEN BITAND(cd.scope_ksrcdes, 2) = 2 THEN 'LGWR ' END ||
CASE WHEN BITAND(cd.scope_ksrcdes, 4) = 4 THEN 'DBWR ' END ||
CASE WHEN BITAND(cd.scope_ksrcdes, 8) = 8 THEN 'PQ ' END ||
CASE WHEN BITAND(cd.scope_ksrcdes, 256) = 256 THEN 'REG ' END ||
CASE WHEN BITAND(cd.scope_ksrcdes, 512) = 512 THEN 'NFY ' END scope
, c.kssobown owning_so
, c.owner_ksrchdl owning_proc
, s.serial#
, s.username
, s.type
, cd.maxsize_ksrcdes
, EVTNUM_KSRCHDL
FROM
x$ksrchdl c
, v$process p
, v$session s
, X$KSRCCTX ctx
, X$KSRCDES cd
WHERE
s.paddr (+) = c.owner_ksrchdl
AND p.addr (+) = c.owner_ksrchdl
AND c.ctxp_ksrchdl = ctx.addr
AND cd.indx = ctx.name_ksrcctx
-- AND bitand(c.kssobflg,1) = 1
-- AND lower(cd.name_ksrcdes) like '%&1%'
)
WHERE &1
ORDER BY
channel_name
, flags
/