Index: src/test_multiplex.c ================================================================== --- src/test_multiplex.c +++ src/test_multiplex.c @@ -94,30 +94,18 @@ */ #ifndef SQLITE_MULTIPLEX_CHUNK_SIZE # define SQLITE_MULTIPLEX_CHUNK_SIZE 2147418112 #endif -/* Default limit on number of chunks. Care should be taken -** so that values for chunks numbers fit in the SQLITE_MULTIPLEX_EXT_FMT -** format specifier. It may be changed by calling +/* Default limit on number of chunks. +** May be changed by calling ** the xFileControl() interface. */ #ifndef SQLITE_MULTIPLEX_MAX_CHUNKS # define SQLITE_MULTIPLEX_MAX_CHUNKS 32 #endif -/* If SQLITE_MULTIPLEX_EXT_OVWR is defined, the -** last SQLITE_MULTIPLEX_EXT_SZ characters of the -** filename will be overwritten, otherwise, the -** multiplex extension is simply appended to the filename. -** Ex. (undefined) test.db -> test.db01 -** (defined) test.db -> test.01 -** Chunk 0 does not have a modified extension. -*/ -#define SQLITE_MULTIPLEX_EXT_FMT "%02d" -#define SQLITE_MULTIPLEX_EXT_SZ 2 - /************************ Object Definitions ******************************/ /* Forward declaration of all object types */ typedef struct multiplexGroup multiplexGroup; typedef struct multiplexConn multiplexConn; @@ -302,24 +290,22 @@ pGroup->nReal = iChunk+1; } if( pGroup->aReal[iChunk].z==0 ){ char *z; int n = pGroup->nName; - pGroup->aReal[iChunk].z = z = sqlite3_malloc( n+3 ); + pGroup->aReal[iChunk].z = z = sqlite3_malloc( n+4 ); if( z==0 ){ return SQLITE_NOMEM; } memcpy(z, pGroup->zName, n+1); if( iChunk>0 ){ #ifdef SQLITE_ENABLE_8_3_NAMES - if( n>3 && z[n-3]=='.' ){ - n--; - }else if( n>4 && z[n-4]=='.' ){ - n -= 2; - } + int i; + for(i=n-1; i>0 && i>=n-4 && z[i]!='.'; i--){} + if( i>=n-4 ) n = i+1; #endif - sqlite3_snprintf(3,&z[n],"%02d",iChunk); + sqlite3_snprintf(4,&z[n],"%03d",iChunk); } } return SQLITE_OK; } Index: test/multiplex.test ================================================================== --- test/multiplex.test +++ test/multiplex.test @@ -22,11 +22,11 @@ # SQLITE_MULTIPLEX_EXT_OVWR is defined, then # it overwrites the last 2 bytes of the # file name with the chunk number. proc multiplex_name {name chunk} { if {$chunk==0} { return $name } - set num [format "%02d" $chunk] + set num [format "%03d" $chunk] ifcapable {multiplex_ext_overwrite} { set name [string range $name 0 [expr [string length $name]-2-1]] } return $name$num }