/ Check-in [7834cf6c]
Login

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

Overview
Comment:Add a test case for the fix on this branch.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | testFixes
Files: files | file ages | folders
SHA3-256: 7834cf6c28c63f6ca0e29a508c0f6e3ec9c5c48715344c2db99a9866e92ef205
User & Date: dan 2018-03-20 12:12:06
Context
2018-03-20
13:26
Fix handling of "UPDATE OR REPLACE" statements run on zipfile virtual tables. Closed-Leaf check-in: 9a5ef341 user: dan tags: testFixes
12:12
Add a test case for the fix on this branch. check-in: 7834cf6c user: dan tags: testFixes
2018-03-17
02:13
For 'zipfile', detect attempts to cause a duplicate entry via UPDATE. check-in: cf78a882 user: mistachkin tags: testFixes
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/zipfile.c.

  1520   1520     int nPath = 0;                  /* strlen(zPath) */
  1521   1521     const u8 *pData = 0;            /* Pointer to buffer containing content */
  1522   1522     int nData = 0;                  /* Size of pData buffer in bytes */
  1523   1523     int iMethod = 0;                /* Compression method for new entry */
  1524   1524     u8 *pFree = 0;                  /* Free this */
  1525   1525     char *zFree = 0;                /* Also free this */
  1526   1526     ZipfileEntry *pOld = 0;
  1527         -  int bUpdate = 0;
         1527  +  int bUpdate = 0;                /* True for an update that modifies "name" */
  1528   1528     int bIsDir = 0;
  1529   1529     u32 iCrc32 = 0;
  1530   1530   
  1531   1531     if( pTab->pWriteFd==0 ){
  1532   1532       rc = zipfileBegin(pVtab);
  1533   1533       if( rc!=SQLITE_OK ) return rc;
  1534   1534     }

Changes to test/zipfile2.test.

   205    205   
   206    206     set hex [binary encode hex $blob]
   207    207     set hex [string map {6e6f7461646972 6e6f746164692f} $hex] 
   208    208     set blob2 [binary decode hex $hex]
   209    209   
   210    210     execsql { SELECT name, data IS NULL FROM zipfile($blob2) }
   211    211   } {notadi/ 1}
          212  +
          213  +#-------------------------------------------------------------------------
          214  +# Test that duplicate entries may not be created using UPDATE
          215  +# statements.
          216  +#
          217  +forcedelete test.zip
          218  +do_execsql_test 6.0 {
          219  +  CREATE VIRTUAL TABLE temp.zip USING zipfile('test.zip'); 
          220  +  INSERT INTO temp.zip (name,data) VALUES ('test1','test'); 
          221  +  INSERT INTO temp.zip (name,data) VALUES ('test2','test'); 
          222  +}
          223  +do_catchsql_test 6.1 {
          224  +  UPDATE temp.zip SET name='test1' WHERE name='test2'
          225  +} {1 {duplicate name: "test1"}}
          226  +
          227  +forcedelete test.zip
          228  +do_catchsql_test 6.2 {
          229  +  DROP TABLE zip;
          230  +  CREATE VIRTUAL TABLE temp.zip USING zipfile('test.zip'); 
          231  +  INSERT INTO temp.zip (name,data) VALUES ('test','test'); 
          232  +  UPDATE  temp.zip set name=name||'new' where name='test'; 
          233  +  INSERT INTO temp.zip (name,data) VALUES ('test','test'); 
          234  +  UPDATE  temp.zip set name=name||'new' where name='test'; 
          235  +} {1 {duplicate name: "testnew"}}
   212    236   
   213    237   
   214    238   finish_test
   215    239