<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://sqlite.phxsoftware.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Bugs</title><link>http://sqlite.phxsoftware.com/forums/5.aspx</link><description>All the finger-pointing goes here</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Re: Device Emulator &amp; DB file on Storage Card =&gt; Problems</title><link>http://sqlite.phxsoftware.com/forums/thread/7675.aspx</link><pubDate>Wed, 01 Jul 2009 15:54:46 GMT</pubDate><guid isPermaLink="false">fa762dca-388a-4e6a-93ef-b5a7a7439be2:7675</guid><dc:creator>Tilman</dc:creator><slash:comments>0</slash:comments><comments>http://sqlite.phxsoftware.com/forums/thread/7675.aspx</comments><wfw:commentRss>http://sqlite.phxsoftware.com/forums/commentrss.aspx?SectionID=5&amp;PostID=7675</wfw:commentRss><description>&lt;blockquote&gt;&lt;p&gt;In theory, there is no difference between theory and practice. In practice, theory and practice don&amp;#39;t even relate. &lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;Since the problem showed up only with the emulator, and since it showed up very rarely and in a very nondeterministic fashion, and since it didn&amp;#39;t show up when disabling the code optimization for at
least the &amp;quot;winceLockFile&amp;quot; function, it looks a lot like a very weird
Device Emulator bug. I agree, that the reasoning for the change is rather weak. &lt;/p&gt;&lt;p&gt;Unfortunately, I most probably won&amp;#39;t be able to spend more time to find and create a test case scenario that demonstrates the problem on the Device Emulator, since I already spent 3-4 days figuring out the problem in the first place. But with the Device Emulator being closed source, I&amp;#39;m stuck to the code that I have a chance to change in order to work around the problem.&lt;/p&gt;&lt;p&gt;But this would be exactly my reasoning: Why not add an #ifndef to disable the test code that can change the value of PENDING_BYTE. It could be enabled by default, but you could add another #define and we&amp;#39;re done.&lt;br /&gt;We would not ask to remove the functionality, instead we&amp;#39;d ask to make it optional.&lt;/p&gt;&lt;p&gt;On a desktop computer there is not too much need to do optimization anymore, but my expericence with Win Mobile devices speak a different language: Less code instructions =&amp;gt; faster code. Replacing PENDING_BYTE by a const value will reduce memory access on the device. I was also thinking about whether we need locking on a WinCE based app at all, since usually there is only one thread accessing the DB, but that is another topic.&lt;br /&gt;(There is quite a number of calls to the locking / unlocking functions)&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Device Emulator &amp; DB file on Storage Card =&gt; Problems</title><link>http://sqlite.phxsoftware.com/forums/thread/7674.aspx</link><pubDate>Wed, 01 Jul 2009 15:32:59 GMT</pubDate><guid isPermaLink="false">fa762dca-388a-4e6a-93ef-b5a7a7439be2:7674</guid><dc:creator>Robert Simpson</dc:creator><slash:comments>0</slash:comments><comments>http://sqlite.phxsoftware.com/forums/thread/7674.aspx</comments><wfw:commentRss>http://sqlite.phxsoftware.com/forums/commentrss.aspx?SectionID=5&amp;PostID=7674</wfw:commentRss><description>&lt;p&gt;The biggest problem with proposing this change to the pending byte is I can&amp;#39;t give a clear and concise reason why this change affects anything.&amp;nbsp; In theory, changing it to const int should really do nothing compared to when it was a static int.&lt;/p&gt;
&lt;p&gt;I doubt seriously I&amp;#39;ll be able to get Dr. Hipp to make this change unless I can give him a compelling argument as to why it works.&amp;nbsp; He&amp;#39;s also not keen on removing functionality from the codebase -- this change would require changes to the test suite -- and I suspect that the pending byte was made changeable because of a request from someone else ... who&amp;#39;d then complain about that functionality being removed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Device Emulator &amp; DB file on Storage Card =&gt; Problems</title><link>http://sqlite.phxsoftware.com/forums/thread/7673.aspx</link><pubDate>Wed, 01 Jul 2009 14:52:39 GMT</pubDate><guid isPermaLink="false">fa762dca-388a-4e6a-93ef-b5a7a7439be2:7673</guid><dc:creator>Tilman</dc:creator><slash:comments>0</slash:comments><comments>http://sqlite.phxsoftware.com/forums/thread/7673.aspx</comments><wfw:commentRss>http://sqlite.phxsoftware.com/forums/commentrss.aspx?SectionID=5&amp;PostID=7673</wfw:commentRss><description>&lt;span class="Apple-style-span" style="border-collapse:separate;font-family:Arial,Helvetica;font-size:medium;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;orphans:2;text-indent:0px;text-transform:none;white-space:normal;widows:2;word-spacing:0px;"&gt;&lt;span class="Apple-style-span" style="font-size:12px;white-space:pre-wrap;"&gt;I made another change to the code base of SQLite:&lt;br /&gt;The value of PENDING_BYTE is calculated from a static int which supposedly should not change at all, so I decided to replace the static int with a const int and remove the SQLITE_TESTCTRL_PENDING_BYTE code in a function called &amp;#39;sqlite3_test_control()&amp;#39; which one is not supposed to call at all. So with this changes, the code seems to run without any problems.&lt;br /&gt;@Robert Simpson&lt;br /&gt;How about proposing a change to the SQLite code base removes the usage of the static int in favour of a const definition for this?&lt;br /&gt;It doesn&amp;#39;t make sense to say: &amp;quot;Hey don&amp;#39;t change this, but for release builds we still want to be able to fumble with it!&amp;quot;, does it?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Below is the content of the unified diff TortoiseMerge came up with (Paths changed though)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
&lt;code&gt;--- SQLite-1.0.63.0-source/SQLite.Interop/src/sqlite3.c	Sa Jun 27 10:17:44 2009&lt;br /&gt;+++ SQLite-1.0.63.0-source-patched/SQLite.Interop/src/sqlite3.c	Mi Jul  1 16:23:34 2009&lt;br /&gt;@@ -10550,7 +10550,8 @@&lt;br /&gt; ** Changing the pending byte during operating results in undefined&lt;br /&gt; ** and dileterious behavior.&lt;br /&gt; */&lt;br /&gt;-SQLITE_PRIVATE int sqlite3PendingByte = 0x40000000;&lt;br /&gt;+//SQLITE_PRIVATE &lt;br /&gt;+const int sqlite3PendingByte = 0x40000000;&lt;br /&gt; &lt;br /&gt; /************** End of global.c **********************************************/&lt;br /&gt; /************** Begin file status.c ******************************************/&lt;br /&gt;@@ -27852,6 +27853,10 @@&lt;br /&gt;   if( isNT() ){&lt;br /&gt;     do{&lt;br /&gt;       DeleteFileW(zConverted);&lt;br /&gt;+// BUG FIX for DB file being used on a simulated storage card on a device emulator&lt;br /&gt;+#if SQLITE_OS_WINCE&lt;br /&gt;+			SetLastError(ERROR_FILE_NOT_FOUND);&lt;br /&gt;+#endif&lt;br /&gt;     }while(   (   ((rc = GetFileAttributesW(zConverted)) != INVALID_FILE_ATTRIBUTES)&lt;br /&gt;                || ((error = GetLastError()) == ERROR_ACCESS_DENIED))&lt;br /&gt;            &amp;amp;&amp;amp; (++cnt &amp;lt; MX_DELETION_ATTEMPTS)&lt;br /&gt;@@ -92835,9 +92840,9 @@&lt;br /&gt;     ** dileterious behavior.&lt;br /&gt;     */&lt;br /&gt;     case SQLITE_TESTCTRL_PENDING_BYTE: {&lt;br /&gt;-      unsigned int newVal = va_arg(ap, unsigned int);&lt;br /&gt;-      rc = sqlite3PendingByte;&lt;br /&gt;-      if( newVal ) sqlite3PendingByte = newVal;&lt;br /&gt;+      //unsigned int newVal = va_arg(ap, unsigned int);&lt;br /&gt;+      //rc = sqlite3PendingByte;&lt;br /&gt;+      //if( newVal ) sqlite3PendingByte = newVal;&lt;br /&gt;       break;&lt;br /&gt;     }&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;</description></item><item><title>Re: Device Emulator &amp; DB file on Storage Card =&gt; Problems</title><link>http://sqlite.phxsoftware.com/forums/thread/7670.aspx</link><pubDate>Tue, 30 Jun 2009 16:09:59 GMT</pubDate><guid isPermaLink="false">fa762dca-388a-4e6a-93ef-b5a7a7439be2:7670</guid><dc:creator>Robert Simpson</dc:creator><slash:comments>0</slash:comments><comments>http://sqlite.phxsoftware.com/forums/thread/7670.aspx</comments><wfw:commentRss>http://sqlite.phxsoftware.com/forums/commentrss.aspx?SectionID=5&amp;PostID=7670</wfw:commentRss><description>&lt;p&gt;The short-term solution may be to set the last error value -- but in the long term Microsoft should really fix this bug.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll see what I can do.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Device Emulator &amp; DB file on Storage Card =&gt; Problems</title><link>http://sqlite.phxsoftware.com/forums/thread/7669.aspx</link><pubDate>Tue, 30 Jun 2009 15:45:21 GMT</pubDate><guid isPermaLink="false">fa762dca-388a-4e6a-93ef-b5a7a7439be2:7669</guid><dc:creator>Tilman</dc:creator><slash:comments>0</slash:comments><comments>http://sqlite.phxsoftware.com/forums/thread/7669.aspx</comments><wfw:commentRss>http://sqlite.phxsoftware.com/forums/commentrss.aspx?SectionID=5&amp;PostID=7669</wfw:commentRss><description>&lt;p&gt;Hello everybody,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;due to the limit of 32MB storage memory in the Device Emulator I was forced to store my apps main DB file&amp;nbsp; on the storage card (SC). This worked with SQLite 1.0.39 but not with later versions: I was able to read form the DB but not to write, so I had to provide two versions of my app: one for the emulator using V1.0.39 and one release version with the latest &amp;amp; greatest. This was last year during preparition of a trade fair, so I had no time to spare whatsoever.&lt;br /&gt;&lt;br /&gt;Since I could afford to spare some time on this issue, and since I want to get rid of a special emulator version of my app (that contains all the bugs already fixed) I tried to get my app working with DB files on a SC with the latest release (1.0.63) but the problem remained: Reading is possible, but writing is not.&lt;br /&gt;&lt;br /&gt;I want to share the results of my research doing this:&lt;br /&gt;&lt;br /&gt;1.&amp;nbsp;&amp;nbsp; &amp;nbsp;GetFileAttributeW sets wrong LastError code for files stored on SC&lt;br /&gt;Normally, GetFileAttributeW returns INVALID_FILE_ATTRIBUTES if a file is not found and GetLastError() is supposed to return ERROR_FILE_NOT_FOUND. This works for files that reside in the storage memory of a device.&lt;br /&gt;I wrote some test code that shows, that no last error is set if the file resides on the SC. So with a small fix in the winDelete() functions I could get rid of that problem.&lt;br /&gt;Although I posted a fix at &amp;#39;sqlite.org&amp;#39; nobody seems to have taken any notice of it.&lt;br /&gt;@Robert Simpson: maybe you have more luck than I do:&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;http://www.sqlite.org/cvstrac/tktview?tn=3644&lt;br /&gt;&lt;br /&gt;2.&amp;nbsp;&amp;nbsp; &amp;nbsp;Locking sometimes fails&lt;br /&gt;The second problem that remaines / remained is a very strange issue that has to do with locking. &lt;br /&gt;Looking a bit deeper into the code (like 3-4 days work), I found out, that winceLockFile screws up every now and then:&lt;br /&gt;One needs to look a bit deeper into the code to understand what&amp;#39;s going on there, but the very short version of it is, that every now and then, winceLockFile does not do what it is supposed to do.&lt;br /&gt;&lt;br /&gt;Adding quite some debugging output to this function, I figured that some times winceLockFile performs a SHARED_LOCK while being requested a PENDING_LOCK. As a result, the values of pFile-&amp;gt;local.nReaders is set wrongly and the following lock requests fail due to wrong values.&lt;br /&gt;&lt;br /&gt;I cannot explain this problem what so ever, but explicetly disabling optimizations for this function seems to do the trick. It may be a bug in the emulator or some very weird side effect that keeps the ARM emulator from doing this right. From looking at the debug output, I haven&amp;#39;t found a clue what really went wrong on this.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I hope this helps other from getting too frustrated doing DB files on the storage card on an emulator&lt;/p&gt;&lt;p&gt;Tilman &lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>