<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andrew Fraser DBA &#187; bugs</title>
	<atom:link href="http://andrewfraserdba.com/category/bugs/feed/" rel="self" type="application/rss+xml" />
	<link>http://andrewfraserdba.com</link>
	<description>Oracle DBA (plus SQL Server)</description>
	<lastBuildDate>Fri, 16 Jul 2010 13:26:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>10.2.0.3 patch fails if database word size had ever been changed in the past</title>
		<link>http://andrewfraserdba.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/</link>
		<comments>http://andrewfraserdba.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/#comments</comments>
		<pubDate>Wed, 02 May 2007 14:38:11 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[old]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/</guid>
		<description><![CDATA[Thanks to Chris Carr for pointing out this:
If you are upgrading or patching to 10.2.0.3 and the word size is different to the word size when the database was created the upgrade will fail with an ora-600. This applies even if the wordsize has been changed in an interim upgrade i.e. 8.1.7 32bit upgraded to [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to Chris Carr for pointing out this:</p>
<p>If you are upgrading or patching to 10.2.0.3 and the word size is different to the word size when the database was created the upgrade will fail with an ora-600. This applies even if the wordsize has been changed in an interim upgrade i.e. 8.1.7 32bit upgraded to 9.2.0 64bit will not upgrade to 10.2.0.3 64 bit, (but will upgrade to 10.2.0.3 32 bit).</p>
<p>To identify whether a database was created as 32-bit or 64-bit, execute the following SQL statement:</p>
<p><code>SQL&gt; select metadata from sys.kopm$ ;<code></p>
<p>If the output references the string 'B023' then it indicates that the database was created as 32-bit If the output references the string 'B047' then it indicates that the database was created as 64-bit</p>
<p>Metalink note on this is <a href="https://metalink.oracle.com/metalink/plsql/f?p=130:14:5544754951127751721::::p14_database_id,p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,412271.1,1,1,1,helvetica#OCCURRENCE">Note 412271.1</a>.</p>
<p>There is a patch to fix this before applying 10.2.0.3, although it is available on Linux, Solaris, HPUX and AIX only so far, not on Windows for some reason.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/05/02/10203-patch-fails-if-database-word-had-ever-been-changed-in-the-past/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>And on the seventh day, God fiddled with His NLS settings</title>
		<link>http://andrewfraserdba.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/</link>
		<comments>http://andrewfraserdba.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/#comments</comments>
		<pubDate>Wed, 25 Apr 2007 09:45:55 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[old]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/</guid>
		<description><![CDATA[This would seem to be pretty authoritative:
&#8220;And on the seventh day God ended his work which He had made; and he rested on the seventh day from all his work which He had made. And God blessed the seventh day, and sanctified it; because that in it he had rested from all his work which [...]]]></description>
			<content:encoded><![CDATA[<p>This would seem to be pretty authoritative:</p>
<blockquote><p>&#8220;And on the seventh day God ended his work which He had made; and he rested on the seventh day from all his work which He had made. And God blessed the seventh day, and sanctified it; because that in it he had rested from all his work which God created and made&#8221; (Genesis 2:2-3).</p></blockquote>
<p>But, only in America.<a href="http://andrewfraser.wordpress.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/#more-38">*</a></p>
<p>In many other NLS territories, Saturday is the sixth day of the week, not the seventh:</p>
<pre class="brush:sql">SQL> alter session set NLS_TERRITORY = 'AMERICA';

Session altered.

SQL> select to_char(sysdate+3,'D Dy') from dual;

TO_CH
-----
7 Sat

SQL> alter session set NLS_TERRITORY='UNITED KINGDOM';

Session altered.

SQL>select to_char(sysdate+3,'D Dy') from dual;

TO_CH
-----
6 Sat</pre>
<p>Now that&#8217;s a real pain, because different Windows PCs will inevitably end up having different registry/environment variable settings for NLS_LANG (NLS_TERRITORY forms the middle part of the NLS_LANG variable). And NLS_LANG also gets set a lot in unix .profile&#8217;s. And those all override the databases settings.</p>
<p>So this week when I had users reporting different results from different PCs, I had initially assumed tnsnames.ora differences were pointing them off to different databases. But really it was because they were running code like this:</p>
<pre class="brush:sql">select address, 'These customers want visited Saturdays'
from customer
where to_char(workdate,'D') = 6 ;</pre>
<p>The fix is to name the day of the week rather than count to it:</p>
<pre class="brush:sql">select address, 'These customers want visited Saturdays'
from customer
where to_char(workdate,'Dy') = 'Sat' ;</pre>
<p>Essentially this issue makes the &#8220;D&#8221; date format unusable.</p>
<p>If code like the above absolutely couldn&#8217;t be changed, then a logon trigger would be the only way to set NLS_TERRITORY the same for all users:</p>
<pre class="brush:sql">create or replace trigger my_logon_trigger
after logon on database
begin
execute immediate 'alter session set nls_territory = ''UNITED KINGDOM'' ' ;
end ;
/</pre>
<p>See <a href="http://asktom.oracle.com/tkyte/Misc/NLSDateFormat.html">Tom Kyte on NLS Date Format</a> and <a href="http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:433227339578">asktom &#8220;language issue&#8221;</a></p>
<p><span id="more-38"></span>* I&#8217;m exaggerating: most countries follow American usage. It&#8217;s Europe which has the Saturday=6 convention, along with some of Europe&#8217;s former possessions: including Mexico (European numbering), but not Canada (American numbering). India, perhaps surprisingly, follows American rather than British day numbering. Israel sticks with the Biblical definition. For extra confusion, some Muslim countries set Friday as their seventh day:</p>
<pre class="brush:sql">SQL> alter session set NLS_TERRITORY = 'EGYPT';

Session altered.

SQL> select to_char(sysdate+3,'D Dy') from dual;

TO_CH
-----
1 Sat</pre>
<p>But others (Turkey, Indonesia) go with European numbering.</p>
<p>Bottom line, keep the &#8220;D&#8221; date format out of your code.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/04/25/and-on-the-seventh-day-god-fiddled-with-his-nls-settings/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bug? with wrong results from all_objects in stored plsql procedures</title>
		<link>http://andrewfraserdba.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/</link>
		<comments>http://andrewfraserdba.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/#comments</comments>
		<pubDate>Fri, 02 Mar 2007 12:44:49 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[old]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/</guid>
		<description><![CDATA[Wouldn&#8217;t it be nice if sql code produced the same result, regardless of whether it is inside a stored procedure or is a standalone plsql block? But that&#8217;s not what happens when the all_ views are used.
Run this code to see the anomaly for yourself:
set serverout on
declare
&#160;&#160;var1 number ;
begin
&#160;&#160;select count(*) into var1 from all_objects ;
&#160;&#160;dbms_output.put_line('all_objects: [...]]]></description>
			<content:encoded><![CDATA[<p>Wouldn&#8217;t it be nice if sql code produced the same result, regardless of whether it is inside a stored procedure or is a standalone plsql block? But that&#8217;s not what happens when the <em>all_ </em>views are used.</p>
<p>Run this code to see the anomaly for yourself:</p>
<p><code>set serverout on<br />
declare<br />
&nbsp;&nbsp;var1 number ;<br />
begin<br />
&nbsp;&nbsp;select count(*) into var1 from all_objects ;<br />
&nbsp;&nbsp;dbms_output.put_line('all_objects: '||var1) ;<br />
end ;<br />
/<br />
create or replace procedure af_temp as<br />
&nbsp;&nbsp;var1 number ;<br />
begin<br />
&nbsp;&nbsp;select count(*) into var1 from all_objects ;<br />
&nbsp;&nbsp;dbms_output.put_line('all_objects: '||var1) ;<br />
end ;<br />
/<br />
exec af_temp ;<br />
drop procedure af_temp ;</code></p>
<p>It&#8217;s the exact same plsql each time, but very different results reported. For example:</p>
<p><code>all_objects: 13501</code></p>
<p><code>PL/SQL procedure successfully completed.</code></p>
<p><code>Procedure created.</code><br />
<code><br />
all_objects: 4929</code></p>
<p><code>PL/SQL procedure successfully completed.</code></p>
<p><code>Procedure dropped.</code></p>
<p>This behaviour appears to occur on all versions &#8211; I tested from 7.3 through 10gR2. The biggest discrepancies in results seem to be with DBA users other than SYS, but all users show some discrepancy.</p>
<p>This issue doesn&#8217;t occur with the <em>dba_</em> views, so best to use them instead in stored plsql objects. That does mean explicitly granting select privileges on the dba_ views being used in stored procedures, which isn&#8217;t necessary for the <em>all_</em> views.</p>
<p>So, is this a bug? I can&#8217;t see any mention of it all in metalink.</p>
<p>It&#8217;s not just an academic issue either: it caused <a href="http://andrewfraser.wordpress.com/2007/02/01/using-10g-datapump-and-scheduler-to-copy-schemas/#more-19">this code of mine</a> to fail to find and drop the objects it was meant to drop.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/03/02/bug-with-wrong-results-from-all_objects-in-stored-plsql-procedures/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Pre 9202/9014: Advanced queuing runs away with server memory.</title>
		<link>http://andrewfraserdba.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/</link>
		<comments>http://andrewfraserdba.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/#comments</comments>
		<pubDate>Mon, 15 Jan 2007 14:00:35 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[bugs]]></category>
		<category><![CDATA[old]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/</guid>
		<description><![CDATA[Using the below memory listing script, I found two databases with large PGAs. That was strange since pga_aggregate_target was unset, sort_area_size was just 64k, and there were very few sessions. Checking PGA at session level showed the QMN sessions had high memory usage (over 200mb each). Which pointed to bug 2227360 &#8220;QMN process leaking memory&#8221;
It [...]]]></description>
			<content:encoded><![CDATA[<p>Using the <a href="http://andrewfraser.wordpress.com/2007/01/15/script-run-against-every-running-database-listing-total-oracle-memory-sgapga/">below memory listing script</a>, I found two databases with large PGAs. That was strange since pga_aggregate_target was unset, sort_area_size was just 64k, and there were very few sessions. Checking PGA at session level showed the QMN sessions had high memory usage (over 200mb each). Which pointed to bug 2227360 &#8220;QMN process leaking memory&#8221;</p>
<p>It is fixed in 9.0.1.4/9.2.0.2 and above, but I was on 9.2.0.1. So the workaround is to kill the QMN (=AQ) sessions. Sounds drastic, but oracle restarts the processes apparently cleanly, with just a message in the alert log like:</p>
<blockquote><p><code>Restarting dead background process QMN0<br />
QMN0 started with pid=9</code></p></blockquote>
<p>And that is the memory then freed up &#8211; for a while at least, you have to be prepared to kill those sessions every so often as the memory leaks build up, if, that is, you can&#8217;t patch up.</p>
<p>I used the below script to kill the sessions. I didn&#8217;t need to use the drastic &#8220;<code>kill -9</code>&#8221; on this occasion, but sometimes sessions take forever to go without that.</p>
<pre class="brush:sql">select 'alter system kill session '''||s.sid||','||s.serial#||''' ;',
'kill -9 '||p.spid
from v$session s, v$process p
where s.paddr = p.addr
and s.program like '%QMN%'
/</pre>
<p>Reference: <a href="https://metalink.oracle.com/metalink/plsql/showdoc?db=NOT&amp;id=233101.1&amp;blackframe=1">Metalink Note 233101.1</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/01/15/pre-92029014-advanced-queuing-runs-away-with-server-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>useful simple vi commands for DBAs</title>
		<link>http://andrewfraserdba.com/2007/01/12/useful-simple-vi-commands-for-dbas/</link>
		<comments>http://andrewfraserdba.com/2007/01/12/useful-simple-vi-commands-for-dbas/#comments</comments>
		<pubDate>Fri, 12 Jan 2007 12:09:51 +0000</pubDate>
		<dc:creator>Andrew Fraser</dc:creator>
				<category><![CDATA[book review]]></category>
		<category><![CDATA[bugs]]></category>
		<category><![CDATA[general musings]]></category>
		<category><![CDATA[old]]></category>

		<guid isPermaLink="false">http://andrewfraser.wordpress.com/2007/01/12/useful-simple-vi-commands-for-dbas/</guid>
		<description><![CDATA[These 32 are the only commands I ever seem to use in vi:

	
	
		Command
		Effect
	
	
	
		:.=
		find out the current line number
	
	
		:1
		go to line 1
	
	
		Ctrl-d
		page down
	
	
		Ctrl-u
		page up
	
	
		Shift-G
		go to end of file
	
	
		i
		insert text at current position
	
	
		Shift-A
		append text after end of current line
	
	
		Shift-I
		insert text before start of current line
	
	
		Esc
		get out of edit mode, back into normal vi command mode
	
	
		dd
		delete current line
	
	
		10dd
		delete [...]]]></description>
			<content:encoded><![CDATA[<p>These 32 are the <em>only</em> commands I ever seem to use in vi:</p>
<table class="wptable rowstyle-alt" id="wptable-2"  cellspacing="1" cellpadding="1">
	<thead>
	<tr>
		<th class="sortable" style="width:1px" align="center">Command</th>
		<th class="sortable" style="width:195px" align="left">Effect</th>
	</tr>
	</thead>
	<tr>
		<td style="width:1px" align="center">:.=</td>
		<td style="width:195px" align="left">find out the current line number</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">:1</td>
		<td style="width:195px" align="left">go to line 1</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">Ctrl-d</td>
		<td style="width:195px" align="left">page down</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">Ctrl-u</td>
		<td style="width:195px" align="left">page up</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">Shift-G</td>
		<td style="width:195px" align="left">go to end of file</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">i</td>
		<td style="width:195px" align="left">insert text at current position</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">Shift-A</td>
		<td style="width:195px" align="left">append text after end of current line</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">Shift-I</td>
		<td style="width:195px" align="left">insert text before start of current line</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">Esc</td>
		<td style="width:195px" align="left">get out of edit mode, back into normal vi command mode</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">dd</td>
		<td style="width:195px" align="left">delete current line</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">10dd</td>
		<td style="width:195px" align="left">delete 10 lines from current line on down</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">d Shift-G</td>
		<td style="width:195px" align="left">delete all lines from current line and below</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">d 1 shift-G</td>
		<td style="width:195px" align="left">delete all lines from current line and above</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">.</td>
		<td style="width:195px" align="left">repeat previous command</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">Shift-Y</td>
		<td style="width:195px" align="left">yank (copy) current line</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">p</td>
		<td style="width:195px" align="left">paste that copy into line below</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">/data</td>
		<td style="width:195px" align="left">search forward for occurencies of string "data"</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">/</td>
		<td style="width:195px" align="left">search forward for next occurrence of remembered search string</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">?</td>
		<td style="width:195px" align="left">search backward for next occurrence of remembered search string</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">:set ic</td>
		<td style="width:195px" align="left">make searches case insensitive</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">:%s/data/index/g</td>
		<td style="width:195px" align="left">replace all occurrencies of "data" with "index"</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">:%s/"//g</td>
		<td style="width:195px" align="left">remove all " characters</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">:%s/$/ ;/</td>
		<td style="width:195px" align="left">append ";" to the end of every line</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">:%s/^/rem /</td>
		<td style="width:195px" align="left">insert "rem " to the start of every line</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">:w</td>
		<td style="width:195px" align="left">write (save) file</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">:q</td>
		<td style="width:195px" align="left">quit out of vi</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">:q!</td>
		<td style="width:195px" align="left">quit out of vi without saving changes</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">:wq</td>
		<td style="width:195px" align="left">write (save) file and quit out of vi</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">shift-Z shift-Z</td>
		<td style="width:195px" align="left">same as above ":wq" except does not write (change file modification times) if you have not made any changes.</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">:n</td>
		<td style="width:195px" align="left">next file (when vi'ing a series of files, e.g. with using "vi *" at the command prompt)</td>
	</tr>
	<tr>
		<td style="width:1px" align="center">u</td>
		<td style="width:195px" align="left">undo last command</td>
	</tr>
	<tr class="alt">
		<td style="width:1px" align="center">Shift-J</td>
		<td style="width:195px" align="left">Join next line onto end of current line</td>
	</tr>
</table><p>
</p>
]]></content:encoded>
			<wfw:commentRss>http://andrewfraserdba.com/2007/01/12/useful-simple-vi-commands-for-dbas/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
