/ Check-in [c267893a]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix a case where an error code was being overwritten in multiplexDelete().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c267893a0813beb1764071409025e178318e1ca3
User & Date: dan 2012-02-28 11:52:12
Context
2012-02-28
17:57
Fix spurious errors that may occur if an empty database is opened and then initialized as a WAL database by a second connection. check-in: 16330a2f user: dan tags: trunk
11:52
Fix a case where an error code was being overwritten in multiplexDelete(). check-in: c267893a user: dan tags: trunk
2012-02-27
14:28
Fix the xDelete implementation of the multiplexor VFS so that it correctly deletes overflow WAL files. check-in: e44e2677 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/test_multiplex.c.

653
654
655
656
657
658
659

660
661
662
663
664
665
666
667

668
669
670
671
672
673
674
        multiplexFilename(zName, nName, SQLITE_OPEN_MAIN_JOURNAL, ++iChunk, z);
        rc = pOrigVfs->xAccess(pOrigVfs, z, SQLITE_ACCESS_EXISTS, &bExists);
      }while( rc==SQLITE_OK && bExists );
      while( rc==SQLITE_OK && iChunk>1 ){
        multiplexFilename(zName, nName, SQLITE_OPEN_MAIN_JOURNAL, --iChunk, z);
        rc = pOrigVfs->xDelete(pOrigVfs, z, syncDir);
      }

      iChunk = 0;
      do{
        multiplexFilename(zName, nName, SQLITE_OPEN_WAL, ++iChunk, z);
        rc = pOrigVfs->xAccess(pOrigVfs, z, SQLITE_ACCESS_EXISTS, &bExists);
      }while( rc==SQLITE_OK && bExists );
      while( rc==SQLITE_OK && iChunk>1 ){
        multiplexFilename(zName, nName, SQLITE_OPEN_WAL, --iChunk, z);
        rc = pOrigVfs->xDelete(pOrigVfs, z, syncDir);

      }
    }
    sqlite3_free(z);
  }
  return rc;
}








>
|
|
|
|
|
|
|
|
>







653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
        multiplexFilename(zName, nName, SQLITE_OPEN_MAIN_JOURNAL, ++iChunk, z);
        rc = pOrigVfs->xAccess(pOrigVfs, z, SQLITE_ACCESS_EXISTS, &bExists);
      }while( rc==SQLITE_OK && bExists );
      while( rc==SQLITE_OK && iChunk>1 ){
        multiplexFilename(zName, nName, SQLITE_OPEN_MAIN_JOURNAL, --iChunk, z);
        rc = pOrigVfs->xDelete(pOrigVfs, z, syncDir);
      }
      if( rc==SQLITE_OK ){
        iChunk = 0;
        do{
          multiplexFilename(zName, nName, SQLITE_OPEN_WAL, ++iChunk, z);
          rc = pOrigVfs->xAccess(pOrigVfs, z, SQLITE_ACCESS_EXISTS, &bExists);
        }while( rc==SQLITE_OK && bExists );
        while( rc==SQLITE_OK && iChunk>1 ){
          multiplexFilename(zName, nName, SQLITE_OPEN_WAL, --iChunk, z);
          rc = pOrigVfs->xDelete(pOrigVfs, z, syncDir);
        }
      }
    }
    sqlite3_free(z);
  }
  return rc;
}

Changes to test/multiplex3.test.

123
124
125
126
127
128
129

130




























131




132
133
    foreach f [glob -nocomplain test.*] {forcecopy $f "xx_$f"}
    sqlite3 db2 file:xx_test.db?8_3_names=1
    execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2
  } $::cksum1

  db2 close
}






























catch { db close }




sqlite3_multiplex_shutdown
finish_test







>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>


123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
    foreach f [glob -nocomplain test.*] {forcecopy $f "xx_$f"}
    sqlite3 db2 file:xx_test.db?8_3_names=1
    execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2
  } $::cksum1

  db2 close
}
catch { db close }


do_test 3.0 { setup_and_save_db } {}
do_faultsim_test 3 -faults ioerr-trans* -prep {

  forcedelete test2.db
  set fd [open test2.wal w]
  seek $fd 4095
  puts -nonewline $fd x
  close $fd

  multiplex_restore_db
  sqlite3 db file:test.db?8_3_names=1
  sqlite3 db2 file:test2.db?8_3_names=1
  sqlite3_multiplex_control db main chunk_size [expr 256*1024]
  sqlite3_multiplex_control db2 main chunk_size [expr 256*1024]
} -body {
  sqlite3_backup B db2 main db main
  B step 100000
  set rc [B finish]
  if { [string match SQLITE_IOERR_* $rc] } {error "disk I/O error"}
  set rc
} -test {
  faultsim_test_result {0 SQLITE_OK}
  if {$testrc==0} {
    set cksum2 [execsql {SELECT md5sum(a, b) FROM t1 ORDER BY a} db2]
    if {$cksum2 != $::cksum1} { error "data mismatch" }
  }
  catch { B finish }
  catch { db close }
  catch { db2 close }
}

catch { db close }
sqlite3_multiplex_shutdown
finish_test