mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Rearchitect the way in which filenames are stored in the Pager object so that
the sqlite3_uri_parameter() interface will work from journal and WAL filenames too. This check-in implements the central idea, and compile and runs somewhat, but crashes on an extended test. FossilOrigin-Name: 2ae77bd2335708343bce4541b4d2cf16edfe3fd5bc2dfb93757238c926aa960b
This commit is contained in:
42
src/main.c
42
src/main.c
@@ -4272,13 +4272,17 @@ int sqlite3UriCount(const char *z){
|
||||
** returns a NULL pointer.
|
||||
*/
|
||||
const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
|
||||
const Pager *pPager;
|
||||
const char *z;
|
||||
if( zFilename==0 || zParam==0 ) return 0;
|
||||
zFilename += sqlite3Strlen30(zFilename) + 1;
|
||||
while( zFilename[0] ){
|
||||
int x = strcmp(zFilename, zParam);
|
||||
zFilename += sqlite3Strlen30(zFilename) + 1;
|
||||
if( x==0 ) return zFilename;
|
||||
zFilename += sqlite3Strlen30(zFilename) + 1;
|
||||
pPager = sqlite3PagerFromFilename(zFilename);
|
||||
assert( pPager!=0 );
|
||||
z = sqlite3PagerQueryParameters(pPager);
|
||||
while( z[0] ){
|
||||
int x = strcmp(z, zParam);
|
||||
z += sqlite3Strlen30(z) + 1;
|
||||
if( x==0 ) return z;
|
||||
z += sqlite3Strlen30(z) + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -4308,6 +4312,32 @@ sqlite3_int64 sqlite3_uri_int64(
|
||||
return bDflt;
|
||||
}
|
||||
|
||||
/*
|
||||
** Translate a filename that was handed to a VFS routine into the corresponding
|
||||
** database, journal, or WAL file.
|
||||
**
|
||||
** It is an error to pass this routine a filename string that was not
|
||||
** passed into the VFS from the SQLite core. Doing so is similar to
|
||||
** passing free() a pointer that was not obtained from malloc() - it is
|
||||
** an error that we cannot easily detect but that will likely cause memory
|
||||
** corruption.
|
||||
*/
|
||||
const char *sqlite3_filename_database(const char *zFilename){
|
||||
const Pager *pPager = sqlite3PagerFromFilename(zFilename);
|
||||
assert( pPager!=0 );
|
||||
return sqlite3PagerFilename(pPager, 0);
|
||||
}
|
||||
const char *sqlite3_filename_journal(const char *zFilename){
|
||||
const Pager *pPager = sqlite3PagerFromFilename(zFilename);
|
||||
assert( pPager!=0 );
|
||||
return sqlite3PagerJournalFilename(pPager);
|
||||
}
|
||||
const char *sqlite3_filename_wal(const char *zFilename){
|
||||
const Pager *pPager = sqlite3PagerFromFilename(zFilename);
|
||||
assert( pPager!=0 );
|
||||
return sqlite3PagerWalFilename(pPager);
|
||||
}
|
||||
|
||||
/*
|
||||
** Return the Btree pointer identified by zDbName. Return NULL if not found.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user