• <tfoot id='Fc00O'></tfoot>
    <i id='Fc00O'><tr id='Fc00O'><dt id='Fc00O'><q id='Fc00O'><span id='Fc00O'><b id='Fc00O'><form id='Fc00O'><ins id='Fc00O'></ins><ul id='Fc00O'></ul><sub id='Fc00O'></sub></form><legend id='Fc00O'></legend><bdo id='Fc00O'><pre id='Fc00O'><center id='Fc00O'></center></pre></bdo></b><th id='Fc00O'></th></span></q></dt></tr></i><div id='Fc00O'><tfoot id='Fc00O'></tfoot><dl id='Fc00O'><fieldset id='Fc00O'></fieldset></dl></div>
        <bdo id='Fc00O'></bdo><ul id='Fc00O'></ul>

      <small id='Fc00O'></small><noframes id='Fc00O'>

      1. <legend id='Fc00O'><style id='Fc00O'><dir id='Fc00O'><q id='Fc00O'></q></dir></style></legend>
      2. 在 iOS 5 上设置 sqlite config SQLITE_CONFIG_SERIALIZED 返回

        时间:2023-06-01

          <small id='j1hkd'></small><noframes id='j1hkd'>

            <bdo id='j1hkd'></bdo><ul id='j1hkd'></ul>

            <tfoot id='j1hkd'></tfoot>

              <i id='j1hkd'><tr id='j1hkd'><dt id='j1hkd'><q id='j1hkd'><span id='j1hkd'><b id='j1hkd'><form id='j1hkd'><ins id='j1hkd'></ins><ul id='j1hkd'></ul><sub id='j1hkd'></sub></form><legend id='j1hkd'></legend><bdo id='j1hkd'><pre id='j1hkd'><center id='j1hkd'></center></pre></bdo></b><th id='j1hkd'></th></span></q></dt></tr></i><div id='j1hkd'><tfoot id='j1hkd'></tfoot><dl id='j1hkd'><fieldset id='j1hkd'></fieldset></dl></div>

              • <legend id='j1hkd'><style id='j1hkd'><dir id='j1hkd'><q id='j1hkd'></q></dir></style></legend>
                    <tbody id='j1hkd'></tbody>

                1. 本文介绍了在 iOS 5 上设置 sqlite config SQLITE_CONFIG_SERIALIZED 返回 SQLITE_MISUSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  随着 iOS 5 的发布,我们在为 sqlite 数据库设置序列化选项时遇到越来越多的错误(因此它的保存用于多线程).我们在 sqlite3_config 上收到 SQLITE_MISUSE 错误代码.有人注意到这种奇怪的行为吗?有人知道我该如何解决这个问题吗?它在以前的 iOS 版本上运行良好.

                  With the release of iOS 5 we are getting more and more errors when setting the serialized option for the sqlite database (so its save to be used for multithreading). We are getting SQLITE_MISUSE error code on sqlite3_config. Has someone noticed this odd behavior? And does someone know how I can fix this? It works perfectly fine on previous iOS versions.

                  代码如下:

                  - (sqlite3 *)getNewDBConnection {
                      NSLog(@"sqlite3 lib version: %s", sqlite3_libversion());
                  
                      //sqlite3_config() has to be called before any sqlite3_open calls.
                  
                      if (sqlite3_threadsafe() > 0) {
                          int retCode = sqlite3_config(SQLITE_CONFIG_SERIALIZED);
                          if (retCode == SQLITE_OK) {
                              NSLog(@"Can now use sqlite on multiple threads, using the same connection");
                          } else {
                              NSLog(@"setting sqlite thread safe mode to serialized failed!!! return code: %d", retCode);
                          }
                      } else {
                          NSLog(@"Your SQLite database is not compiled to be threadsafe.");
                      }
                  
                      sqlite3 *newDBconnection;
                  
                      // Open the database
                      if (sqlite3_open([[self getDatabaseFilePath] UTF8String], &newDBconnection) == SQLITE_OK) {
                          NSLog(@"Database Successfully Opened :)");
                      } else {
                          sqlite3_close(newDBconnection);
                          NSLog(@"Error in opening database :(");
                      }
                  
                      return newDBconnection; 
                  }
                  

                  这是输出:

                  sqlite3 lib version: 3.7.7
                  setting sqlite thread safe mode to serialized failed!!! return code: 21
                  Database Successfully Opened :)
                  

                  推荐答案

                  我也为此苦苦挣扎,终于找到了解决方案.

                  I struggled long and hard with this as well and finally got the solution.

                  正如@enobufs 所说,sqlite3_config() 需要在sqlite3_initialize() 之前调用.但是,操作系统可能会为我们初始化 SQLite,所以我还在 sqlite3_config() 之前做了一个 sqlite3_shutdown().

                  As @enobufs said, sqlite3_config() needs to be called before sqlite3_initialize(). However, the OS might initialize SQLite for us so I also do a sqlite3_shutdown() before the sqlite3_config().

                  1. sqlite3_shutdown()
                  2. sqlite3_config()
                  3. sqlite3_initialize().

                  然后它还需要为每个查询使用相同的连接,因为它是对被序列化的数据库连接的访问​​.如此处所述 http://www.sqlite.org/capi3ref.html#sqliteconfigserialized

                  Then its also necessary to use the same connection for every query as it is the access to the database connection that gets serialized. As described here http://www.sqlite.org/capi3ref.html#sqliteconfigserialized

                  因此,我会在应用启动后立即创建一个连接,并将该连接传递给每个需要它的类.

                  So I create a connection as soon as the app starts up and the pass that connection to every class that needs it.

                  这篇关于在 iOS 5 上设置 sqlite config SQLITE_CONFIG_SERIALIZED 返回 SQLITE_MISUSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 Xcode 升级到 4.5 后,Restkit 10.0 项目无法为 iO 下一篇:在 UITablView 单元格的选定状态上更改图像

                  相关文章

                  最新文章

                    <bdo id='nCgcu'></bdo><ul id='nCgcu'></ul>

                  <small id='nCgcu'></small><noframes id='nCgcu'>

                    <i id='nCgcu'><tr id='nCgcu'><dt id='nCgcu'><q id='nCgcu'><span id='nCgcu'><b id='nCgcu'><form id='nCgcu'><ins id='nCgcu'></ins><ul id='nCgcu'></ul><sub id='nCgcu'></sub></form><legend id='nCgcu'></legend><bdo id='nCgcu'><pre id='nCgcu'><center id='nCgcu'></center></pre></bdo></b><th id='nCgcu'></th></span></q></dt></tr></i><div id='nCgcu'><tfoot id='nCgcu'></tfoot><dl id='nCgcu'><fieldset id='nCgcu'></fieldset></dl></div>
                    <legend id='nCgcu'><style id='nCgcu'><dir id='nCgcu'><q id='nCgcu'></q></dir></style></legend>
                    1. <tfoot id='nCgcu'></tfoot>