]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change the SQLITE_FCNTL_PRAGMA file-control so that it can return a string
authordrh <drh@noemail.net>
Wed, 22 Feb 2012 16:58:36 +0000 (16:58 +0000)
committerdrh <drh@noemail.net>
Wed, 22 Feb 2012 16:58:36 +0000 (16:58 +0000)
value.

FossilOrigin-Name: fd8d7440277b17f57a6dc0a210f42adf1fa2dcd2

manifest
manifest.uuid
src/os_unix.c
src/pragma.c
src/sqlite.h.in
src/sqliteInt.h
src/test_vfstrace.c
src/util.c
test/attach.test

index a4bb376dd7476624b3eed2f843a50066716fd40a..46df865eb6e97638ab001fdd9a2010c17f4db7ea 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Begin\sadding\ssupport\sfor\sSQLITE_FCNTL_PRAGMA.
-D 2012-02-22T14:45:19.357
+C Change\sthe\sSQLITE_FCNTL_PRAGMA\sfile-control\sso\sthat\sit\scan\sreturn\sa\sstring\nvalue.
+D 2012-02-22T16:58:36.697
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 3f79a373e57c3b92dabf76f40b065e719d31ac34
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -166,7 +166,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c
 F src/os.h 59beba555b65a450bd1d804220532971d4299f60
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
 F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
-F src/os_unix.c 0e3d2942d228d0366fb80a3640f35caf413b66d1
+F src/os_unix.c 497e355ab617a875bf45f4d58bacca82952339d5
 F src/os_win.c 5ac061ae1326a71500cee578ed0fd9113b4f6a37
 F src/pager.c 2d892f7b901a8867a33bc21742086165a3a99af8
 F src/pager.h a435da8421dc7844b7f9c7f37b636c160c50208a
@@ -174,7 +174,7 @@ F src/parse.y 1ddd71ae55f4b7cbb2672526ea4de023de0f519e
 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346
 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c
 F src/pcache1.c b30b1c35908346ecc43d8d9d17f2ddf6817f8f60
-F src/pragma.c 4dfd5b263d459559cbecb877dc5f1e0fc822cc04
+F src/pragma.c 6838f56b049840d015fc9b335ab4118479bdaac9
 F src/prepare.c ec4989f7f480544bdc4192fe663470d2a2d7d61e
 F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699
 F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50
@@ -182,9 +182,9 @@ F src/resolve.c 3d3e80a98f203ac6b9329e9621e29eda85ddfd40
 F src/rowset.c 69afa95a97c524ba6faf3805e717b5b7ae85a697
 F src/select.c 232283a2e60d91cbd9a5ddf2f6f7ecf53d590075
 F src/shell.c aa28f117033ba3e44b5eaaf2ad572222bcdfd66e
-F src/sqlite.h.in d51a37c14123717dec954c848f51fd635620ba00
+F src/sqlite.h.in 5119a5c169c531d819b790957eebc28c4fc7acf6
 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477
-F src/sqliteInt.h ea24b5f2d2e3ae7e0c1126a78c0e025ed4e98f4b
+F src/sqliteInt.h b013dab7d43fb67c3ca2f0253d7863abb37e233c
 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
 F src/status.c 4568e72dfd36b6a5911f93457364deb072e0b03a
 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
@@ -231,14 +231,14 @@ F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae
 F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa
 F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4
 F src/test_vfs.c 07157a0bbfe161cb5e32cad2079abd26cd611c4b
-F src/test_vfstrace.c 374f6807d76e4899f51315469471b85db2703c2a
+F src/test_vfstrace.c f20a32a5fd46feb59a93d2cf650f1ff92da3872b
 F src/test_wholenumber.c 6129adfbe7c7444f2e60cc785927f3aa74e12290
 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
 F src/tokenize.c 1e86210d3976717a19238ea7b047fac481fe8c12
 F src/trigger.c ee7e178fb9188f44b532cebd449a7c1df90fb684
 F src/update.c d3076782c887c10e882996550345da9c4c9f9dea
 F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84
-F src/util.c 9e07bd67dfafe9c75b1da78c87ba030cebbb5388
+F src/util.c 906731099c4397bf8adf3fa90a833355e7472af0
 F src/vacuum.c 0c0ba2242355c6048d65e2b333abe0f7c06348fa
 F src/vdbe.c 21c17c43e579789959efea50f100de60efbb955c
 F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb
@@ -275,7 +275,7 @@ F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b
 F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7
 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a
 F test/async5.test 0dd8701bd588bf6e70c2557a22ae3f22b2567b4c
-F test/attach.test 0d112b7713611fdf0340260192749737135fda5f
+F test/attach.test 064911a24b6692759c661b981ed953c5fd9f441a
 F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966
 F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e
 F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c
@@ -990,10 +990,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
 F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
-P f8ac826f95ae6b7b981e4765d2e65b6839d0eff9
-R f3e55ac02da0d4d13eff7250cbdd55d7
-T *branch * file-control-pragma
-T *sym-file-control-pragma *
-T -sym-trunk *
+P 5be07904baf6e5b8b99ca6f4bb6ddec973e59cd4
+R f8a789f52fcbc32c2be7b7547e20bad5
 U drh
-Z afe420533dd0a9b4e47e7db76c26bdaa
+Z 2d0e9a9b9d36c2e692d7eed74ee06028
index fcbf89b7a613892b2b2eb4ad775cb29abeda17a1..90e28dbbf093baf58fab2ccee766911d729f8662 100644 (file)
@@ -1 +1 @@
-5be07904baf6e5b8b99ca6f4bb6ddec973e59cd4
\ No newline at end of file
+fd8d7440277b17f57a6dc0a210f42adf1fa2dcd2
\ No newline at end of file
index 48c130935e983fe74c8a1f4325fdb55bb95fa91b..651b15f7d2e1b7c4ea6853a3907354cd94b4b982 100644 (file)
@@ -3587,6 +3587,14 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){
       *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
       return SQLITE_OK;
     }
+    case SQLITE_FCNTL_PRAGMA: {
+      char **azArg = (char**)pArg;
+      if( sqlite3_stricmp(azArg[1], "filename")==0 ){
+        azArg[0] = sqlite3_mprintf("%s", pFile->zPath);
+        return SQLITE_OK;
+      }
+      break;
+    }
 #ifndef NDEBUG
     /* The pager calls this method to signal that it has done
     ** a rollback and that the database is therefore unchanged and
index e449baa8fb466a27604f0579ebddae9d252ccd3b..079348e11b24c3baac7f0f03d3bc91566546d5b3 100644 (file)
@@ -312,7 +312,7 @@ void sqlite3Pragma(
   const char *zDb = 0;   /* The database name */
   Token *pId;            /* Pointer to <id> token */
   int iDb;               /* Database index for <database> */
-  const char *aFcntl[3];       /* Argument to SQLITE_FCNTL_PRAGMA */
+  char *aFcntl[4];       /* Argument to SQLITE_FCNTL_PRAGMA */
   int rc;                      /* return value form SQLITE_FCNTL_PRAGMA */
   sqlite3 *db = pParse->db;    /* The database connection */
   Db *pDb;                     /* The specific database being pragmaed */
@@ -353,13 +353,21 @@ void sqlite3Pragma(
   ** connection.  If it returns SQLITE_OK, then assume that the VFS
   ** handled the pragma and generate a no-op prepared statement.
   */
-  aFcntl[0] = zLeft;
-  aFcntl[1] = zRight;
-  aFcntl[2] = 0;
+  aFcntl[0] = 0;
+  aFcntl[1] = zLeft;
+  aFcntl[2] = zRight;
+  aFcntl[3] = 0;
   rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
   if( rc==SQLITE_OK ){
-    zLeft = "";
-  }
+    if( aFcntl[0] ){
+      int mem = ++pParse->nMem;
+      sqlite3VdbeAddOp4(v, OP_String8, 0, mem, 0, aFcntl[0], 0);
+      sqlite3VdbeSetNumCols(v, 1);
+      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC);
+      sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
+      sqlite3_free(aFcntl[0]);
+    }
+  }else
                             
  
 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && !defined(SQLITE_OMIT_DEPRECATED)
index 1bd1b08685ad0fd511dbf443ce4da34b1a28afb5..f0eb1987ec913ef8c60d9f5213a31f6ee3a8a0c4 100644 (file)
@@ -6595,11 +6595,12 @@ int sqlite3_unlock_notify(
 /*
 ** CAPI3REF: String Comparison
 **
-** ^The [sqlite3_strnicmp()] API allows applications and extensions to
-** compare the contents of two buffers containing UTF-8 strings in a
-** case-independent fashion, using the same definition of case independence 
-** that SQLite uses internally when comparing identifiers.
+** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
+** and extensions to compare the contents of two buffers containing UTF-8
+** strings in a case-independent fashion, using the same definition of "case
+** independence" that SQLite uses internally when comparing identifiers.
 */
+int sqlite3_stricmp(const char *, const char *);
 int sqlite3_strnicmp(const char *, const char *, int);
 
 /*
index 8165d05bfff41f19c64010a77952db753b2596c6..cfe8fd64fb8634270d9803947a2714d42e0d2498 100644 (file)
@@ -2553,7 +2553,7 @@ int sqlite3CantopenError(int);
 /*
 ** Internal function prototypes
 */
-int sqlite3StrICmp(const char *, const char *);
+#define sqlite3StrICmp sqlite3_stricmp
 int sqlite3Strlen30(const char*);
 #define sqlite3StrNICmp sqlite3_strnicmp
 
index a1fa6ff4422b195a0b6294ec0f6457009416dc91..44a652454dc0b4592d38b1d614c4ff6e1827536c 100644 (file)
@@ -478,7 +478,7 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){
     case 0xca093fa0:                zOp = "DB_UNCHANGED";       break;
     case SQLITE_FCNTL_PRAGMA: {
       const char *const* a = (const char*const*)pArg;
-      sqlite3_snprintf(sizeof(zBuf), zBuf, "PRAGMA,[%s,%s]",a[0],a[1]);
+      sqlite3_snprintf(sizeof(zBuf), zBuf, "PRAGMA,[%s,%s]",a[1],a[2]);
       zOp = zBuf;
       break;
     }
@@ -496,6 +496,10 @@ static int vfstraceFileControl(sqlite3_file *pFile, int op, void *pArg){
     *(char**)pArg = sqlite3_mprintf("vfstrace.%s/%z",
                                     pInfo->zVfsName, *(char**)pArg);
   }
+  if( op==SQLITE_FCNTL_PRAGMA && rc==SQLITE_OK && *(char**)pArg ){
+    vfstrace_printf(pInfo, "%s.xFileControl(%s,%s) returns %s",
+                    pInfo->zVfsName, p->zFNmae, zOp, *(char**)pArg);
+  }
   return rc;
 }
 
index fd3c858ab73358f8e6b112886c3b60c07cde919c..325c75aae171d5fa955f11b66d062589987d9041 100644 (file)
@@ -222,7 +222,7 @@ int sqlite3Dequote(char *z){
 ** definition of case independence that SQLite uses internally when
 ** comparing identifiers.
 */
-int sqlite3StrICmp(const char *zLeft, const char *zRight){
+int sqlite3_stricmp(const char *zLeft, const char *zRight){
   register unsigned char *a, *b;
   a = (unsigned char *)zLeft;
   b = (unsigned char *)zRight;
index be5f9881c31833e2da37256dfb19f2c66f3c8c9f..b29ba1709a72dc3425cd40e05e2bcce2742f0a7d 100644 (file)
@@ -70,6 +70,7 @@ do_test attach-1.3.5 {
   file tail [sqlite3_db_filename db three]
 } {}
 
+
 do_test attach-1.4 {
   execsql {
     SELECT * FROM t2;
@@ -270,6 +271,16 @@ ifcapable schema_pragmas {
   }
 } ;# ifcapable schema_pragmas
 
+
+if {[regexp unix [file_control_vfsname db]]} {
+  do_test attach-1.30.1 {
+    file tail [db eval {PRAGMA main.filename}]
+  } {test.db}
+  do_test attach-1.30.2 {
+    db eval {PRAGMA temp.filename}
+  } {}
+}
+
 ifcapable {trigger} {  # Only do the following tests if triggers are enabled
 do_test attach-2.1 {
   execsql {