<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Geek Stuff &#8211; 2</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Fri, 24 May 2013 13:27:07 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-41336</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 19 Aug 2011 09:55:01 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-41336</guid>
		<description><![CDATA[Anuj,

1) The ORA-03113 is not surprising if you&#039;re querying a location which hasn&#039;t been mapped by Oracle in &lt;em&gt;&lt;strong&gt;x$ksmmem&lt;/strong&gt;&lt;/em&gt;.

2) If you read the code you will see that it shows 10.2.0.3 and 11.1.0.6 needing different offset values. You appear to be using 11.2.0.1, and you have given no indication that you&#039;ve taken the necessary action to prove that it uses the same offset as 11.1.0.6. (I don&#039;t know if it does as I haven&#039;t had any reason to look)]]></description>
		<content:encoded><![CDATA[<p>Anuj,</p>
<p>1) The ORA-03113 is not surprising if you&#8217;re querying a location which hasn&#8217;t been mapped by Oracle in <em><strong>x$ksmmem</strong></em>.</p>
<p>2) If you read the code you will see that it shows 10.2.0.3 and 11.1.0.6 needing different offset values. You appear to be using 11.2.0.1, and you have given no indication that you&#8217;ve taken the necessary action to prove that it uses the same offset as 11.1.0.6. (I don&#8217;t know if it does as I haven&#8217;t had any reason to look)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anuj singh</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-41326</link>
		<dc:creator><![CDATA[anuj singh]]></dc:creator>
		<pubDate>Thu, 18 Aug 2011 15:26:27 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-41326</guid>
		<description><![CDATA[Hi Jonathan

I am getting this error ... on your function 


on
SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 18 15:20:02 2011

=========================
also getting error on this as well .... just testing 
[sourcecode]
select ksmmmval  from x$ksmmem where addr = hextoraw(&#039;20009108&#039;)
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 2160
Session ID: 42 Serial number: 6014


SQL&gt; select ksmmmval  from x$ksmmem where addr =&#039;000&#039; ;
select ksmmmval  from x$ksmmem where addr =&#039;000&#039;
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 2293
Session ID: 59 Serial number: 3492

========================



USER is &quot;SYS&quot;


SQL&gt; create or replace function session_uso
return varchar2
as
    uso     varchar2(30);
    mem_addr    x$ksmmem.addr%type := hextoraw(&#039;0E9A7838&#039;);
    mem_ct      number;
    mem_indx    number;
    raw_val     x$ksmmem.ksmmmval%type;
    indx_temp   number;
    col_size    number;
    raw_char    varchar2(64) := null;
 
begin
    select
        type_size
    into
        session_uso.col_size
    from
        v$type_size
    where
        type = &#039;SIZE_T&#039;
    ;
 
    select
        ksmchptr,
        ksmchsiz
    into
        session_uso.mem_addr,
        session_uso.mem_ct
    from
        x$ksmpp
    where
        ksmchcom = &#039;Fixed Uga&#039;
    ;
 
    select
        indx
    into
        session_uso.mem_indx
    from
        x$ksmmem
    where
        addr = session_uso.mem_addr
    ;
 
    dbms_output.put_line(&#039;Memory address: &#039; &#124;&#124; rawtohex(session_uso.mem_addr));
    dbms_output.put_line(&#039;Start location: &#039; &#124;&#124; session_uso.mem_indx);
    dbms_output.put_line(&#039;Nominal Length: &#039; &#124;&#124; session_uso.mem_ct);
 
--
--  Assume that the 11.1.0.6 offset to USO is 2504 bytes
--  And that the first t_type is a counter, then each
--  value after that is a letter until we hit 00 for a
--  maximum of 32 letters
--
 
    mem_indx := mem_indx + 2504/col_size;       -- 11.1.0.6 on Windows XP 32-bit
--  mem_indx := mem_indx + 1620/col_size;       -- 10.2.0.3 on windows XP 32 bit
 
    for i in 1 .. 32 loop
 
--      Have to do the silly addition, or
--      we get a &quot;tablescan&quot;  of x$ksmmem
 
        session_uso.indx_temp := session_uso.mem_indx + i;
 
        select
            --+ index(x$ksmmem)
            ksmmmval
        into
            session_uso.raw_val
        from
            x$ksmmem
        where
            indx = session_uso.indx_temp
        ;
 
        dbms_output.put_line(session_uso.raw_val);
        exit when session_uso.raw_val = hextoraw(&#039;00&#039;);
 
        raw_char :=
            rawtohex(session_uso.raw_val) &#124;&#124;
            rawtohex(session_uso.raw_char);
 
    end loop;
 
    if session_uso.raw_char is null then
        session_uso.uso := &#039;use_stored_outlines is not set&#039;;
    else
        for i in reverse 1..(length(session_uso.raw_char)-4) / 2 loop
            exit when substr(session_uso.raw_char, 2*i - 1, 2) = &#039;00&#039;;
            session_uso.uso :=
                session_uso.uso &#124;&#124;
                chr(to_number(substr(session_uso.raw_char, 2*i - 1, 2), &#039;XX&#039;));
        end loop;
    end if;
    return  session_uso.uso;
 
end;
/  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   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99  100  

Function created.

SQL&gt; execute dbms_output.put_line(session_uso);

BEGIN dbms_output.put_line(session_uso); END;

*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at &quot;SYS.SESSION_USO&quot;, line 36
ORA-06512: at line 1
[/sourcecode]
]]></description>
		<content:encoded><![CDATA[<p>Hi Jonathan</p>
<p>I am getting this error &#8230; on your function </p>
<p>on<br />
SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 18 15:20:02 2011</p>
<p>=========================<br />
also getting error on this as well &#8230;. just testing </p>
<pre class="brush: plain; title: ; notranslate">
select ksmmmval  from x$ksmmem where addr = hextoraw('20009108')
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 2160
Session ID: 42 Serial number: 6014


SQL&amp;gt; select ksmmmval  from x$ksmmem where addr ='000' ;
select ksmmmval  from x$ksmmem where addr ='000'
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 2293
Session ID: 59 Serial number: 3492

========================



USER is &quot;SYS&quot;


SQL&amp;gt; create or replace function session_uso
return varchar2
as
    uso     varchar2(30);
    mem_addr    x$ksmmem.addr%type := hextoraw('0E9A7838');
    mem_ct      number;
    mem_indx    number;
    raw_val     x$ksmmem.ksmmmval%type;
    indx_temp   number;
    col_size    number;
    raw_char    varchar2(64) := null;
 
begin
    select
        type_size
    into
        session_uso.col_size
    from
        v$type_size
    where
        type = 'SIZE_T'
    ;
 
    select
        ksmchptr,
        ksmchsiz
    into
        session_uso.mem_addr,
        session_uso.mem_ct
    from
        x$ksmpp
    where
        ksmchcom = 'Fixed Uga'
    ;
 
    select
        indx
    into
        session_uso.mem_indx
    from
        x$ksmmem
    where
        addr = session_uso.mem_addr
    ;
 
    dbms_output.put_line('Memory address: ' || rawtohex(session_uso.mem_addr));
    dbms_output.put_line('Start location: ' || session_uso.mem_indx);
    dbms_output.put_line('Nominal Length: ' || session_uso.mem_ct);
 
--
--  Assume that the 11.1.0.6 offset to USO is 2504 bytes
--  And that the first t_type is a counter, then each
--  value after that is a letter until we hit 00 for a
--  maximum of 32 letters
--
 
    mem_indx := mem_indx + 2504/col_size;       -- 11.1.0.6 on Windows XP 32-bit
--  mem_indx := mem_indx + 1620/col_size;       -- 10.2.0.3 on windows XP 32 bit
 
    for i in 1 .. 32 loop
 
--      Have to do the silly addition, or
--      we get a &quot;tablescan&quot;  of x$ksmmem
 
        session_uso.indx_temp := session_uso.mem_indx + i;
 
        select
            --+ index(x$ksmmem)
            ksmmmval
        into
            session_uso.raw_val
        from
            x$ksmmem
        where
            indx = session_uso.indx_temp
        ;
 
        dbms_output.put_line(session_uso.raw_val);
        exit when session_uso.raw_val = hextoraw('00');
 
        raw_char :=
            rawtohex(session_uso.raw_val) ||
            rawtohex(session_uso.raw_char);
 
    end loop;
 
    if session_uso.raw_char is null then
        session_uso.uso := 'use_stored_outlines is not set';
    else
        for i in reverse 1..(length(session_uso.raw_char)-4) / 2 loop
            exit when substr(session_uso.raw_char, 2*i - 1, 2) = '00';
            session_uso.uso :=
                session_uso.uso ||
                chr(to_number(substr(session_uso.raw_char, 2*i - 1, 2), 'XX'));
        end loop;
    end if;
    return  session_uso.uso;
 
end;
/  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   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99  100  

Function created.

SQL&amp;gt; execute dbms_output.put_line(session_uso);

BEGIN dbms_output.put_line(session_uso); END;

*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at &quot;SYS.SESSION_USO&quot;, line 36
ORA-06512: at line 1
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Prusinski</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-38662</link>
		<dc:creator><![CDATA[Ben Prusinski]]></dc:creator>
		<pubDate>Sat, 11 Dec 2010 07:15:39 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-38662</guid>
		<description><![CDATA[Jonathan,

As a fan of oradebug, its nice to see some new things illustrated clearly for dumping UGA memory. 

Cheers,
Ben]]></description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>As a fan of oradebug, its nice to see some new things illustrated clearly for dumping UGA memory. </p>
<p>Cheers,<br />
Ben</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joel garry</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-38635</link>
		<dc:creator><![CDATA[joel garry]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 17:49:45 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-38635</guid>
		<description><![CDATA[OK. Junping had asked about other sessions, should have replied there, perhaps with &quot;why do you want to do that?&quot;]]></description>
		<content:encoded><![CDATA[<p>OK. Junping had asked about other sessions, should have replied there, perhaps with &#8220;why do you want to do that?&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aswath Rao</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-38634</link>
		<dc:creator><![CDATA[Aswath Rao]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 16:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-38634</guid>
		<description><![CDATA[Jonathan,

Thanks you so much for sharing it. You have explained it so nicely.

Thanks
Aswath Rao]]></description>
		<content:encoded><![CDATA[<p>Jonathan,</p>
<p>Thanks you so much for sharing it. You have explained it so nicely.</p>
<p>Thanks<br />
Aswath Rao</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-38629</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 10 Dec 2010 08:25:10 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-38629</guid>
		<description><![CDATA[Joel,

You only need to be logged in as sys to find a critical value and create the function.

The point of the function is that anyone can run it (after sys has granted execute to them) so ordinary programs can discover their current setting.]]></description>
		<content:encoded><![CDATA[<p>Joel,</p>
<p>You only need to be logged in as sys to find a critical value and create the function.</p>
<p>The point of the function is that anyone can run it (after sys has granted execute to them) so ordinary programs can discover their current setting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joel garry</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-38624</link>
		<dc:creator><![CDATA[joel garry]]></dc:creator>
		<pubDate>Thu, 09 Dec 2010 23:16:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-38624</guid>
		<description><![CDATA[If you have to be sys anyways, why not just keep using oradebug?  10.2.0.4 on hp-ux:

SYS@TTST&gt; select ksmchptr from x$ksmpp where KSMCHCOM =&#039;Fixed Uga&#039;;

KSMCHPTR
----------------
9FFFFFFFBF3A6710

SYS@TTST&gt; oradebug setmypid
Statement processed.
SYS@TTST&gt; oradebug dumpvar uqa ugauso_p
ORA-00084: global area must be PGA, SGA, or UGA
SYS@TTST&gt; oradebug dumpvar UGA ugauso_p
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
SYS@TTST&gt; alter session set use_stored_outlines=ABCDEFG;

Session altered.

SYS@TTST&gt; oradebug dumpvar UGA ugauso_p
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000001 00074142 43444546 47000000 00000000 00000000 00000000 00000000 00000000
SYS@TTST&gt; oradebug setospid 9507
Oracle pid: 37, Unix process pid: 9507, image: oracle@THOR
-- boss&#039;s session :-O

SYS@TTST&gt;  alter session set use_stored_outlines=ABCDEFG;

Session altered.

-- my session, of course

SYS@TTST&gt; oradebug dumpvar UGA ugauso_p
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
-- boss&#039;s session not affected.

-- start another user session, ps -ef to find OS id (or you could check v$&#039;s), then:
SYS@TTST&gt; oradebug setospid 19677
Oracle pid: 34, Unix process pid: 19677, image: oracle@THOR
-- here I&#039;ve started another session elsewhere, found it and attached to it

SYS@TTST&gt; oradebug dumpvar UGA ugauso_p
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

-- now I alter the other session alter session set use_stored_outlines=ABCDEFG and...;
SYS@TTST&gt; oradebug dumpvar UGA ugauso_p
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000001 00074142 43444546 47000000 00000000 00000000 00000000 00000000 00000000

So the hack would be, find out the ospid (or orapid), use oradebug setospid (or setorapid) to get the raw value, then parse and translate.]]></description>
		<content:encoded><![CDATA[<p>If you have to be sys anyways, why not just keep using oradebug?  10.2.0.4 on hp-ux:</p>
<p>SYS@TTST&gt; select ksmchptr from x$ksmpp where KSMCHCOM =&#8217;Fixed Uga&#8217;;</p>
<p>KSMCHPTR<br />
&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
9FFFFFFFBF3A6710</p>
<p>SYS@TTST&gt; oradebug setmypid<br />
Statement processed.<br />
SYS@TTST&gt; oradebug dumpvar uqa ugauso_p<br />
ORA-00084: global area must be PGA, SGA, or UGA<br />
SYS@TTST&gt; oradebug dumpvar UGA ugauso_p<br />
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br />
SYS@TTST&gt; alter session set use_stored_outlines=ABCDEFG;</p>
<p>Session altered.</p>
<p>SYS@TTST&gt; oradebug dumpvar UGA ugauso_p<br />
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000001 00074142 43444546 47000000 00000000 00000000 00000000 00000000 00000000<br />
SYS@TTST&gt; oradebug setospid 9507<br />
Oracle pid: 37, Unix process pid: 9507, image: oracle@THOR<br />
&#8211; boss&#8217;s session :-O</p>
<p>SYS@TTST&gt;  alter session set use_stored_outlines=ABCDEFG;</p>
<p>Session altered.</p>
<p>&#8211; my session, of course</p>
<p>SYS@TTST&gt; oradebug dumpvar UGA ugauso_p<br />
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000<br />
&#8211; boss&#8217;s session not affected.</p>
<p>&#8211; start another user session, ps -ef to find OS id (or you could check v$&#8217;s), then:<br />
SYS@TTST&gt; oradebug setospid 19677<br />
Oracle pid: 34, Unix process pid: 19677, image: oracle@THOR<br />
&#8211; here I&#8217;ve started another session elsewhere, found it and attached to it</p>
<p>SYS@TTST&gt; oradebug dumpvar UGA ugauso_p<br />
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000</p>
<p>&#8211; now I alter the other session alter session set use_stored_outlines=ABCDEFG and&#8230;;<br />
SYS@TTST&gt; oradebug dumpvar UGA ugauso_p<br />
qolprm ugauso_p [9FFFFFFFBF3A70A8, 9FFFFFFFBF3A70CC) = 00000001 00074142 43444546 47000000 00000000 00000000 00000000 00000000 00000000</p>
<p>So the hack would be, find out the ospid (or orapid), use oradebug setospid (or setorapid) to get the raw value, then parse and translate.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nakinov</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-38622</link>
		<dc:creator><![CDATA[Nakinov]]></dc:creator>
		<pubDate>Thu, 09 Dec 2010 20:34:55 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-38622</guid>
		<description><![CDATA[This is brilliant! Thanks for sharing Jonathan!]]></description>
		<content:encoded><![CDATA[<p>This is brilliant! Thanks for sharing Jonathan!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Junping Zhang</title>
		<link>http://jonathanlewis.wordpress.com/2010/12/09/geek-stuff-2/#comment-38621</link>
		<dc:creator><![CDATA[Junping Zhang]]></dc:creator>
		<pubDate>Thu, 09 Dec 2010 20:10:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/?p=5096#comment-38621</guid>
		<description><![CDATA[Hi, Jonathan,

Thank you so much! It is simply awesome! 

Junping]]></description>
		<content:encoded><![CDATA[<p>Hi, Jonathan,</p>
<p>Thank you so much! It is simply awesome! </p>
<p>Junping</p>
]]></content:encoded>
	</item>
</channel>
</rss>
