/ Check-in [d65f6353]
Login

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

Overview
Comment:Fix the virtual table rename logic so that it works even if the database encoding is something other than UTF8. Ticket [8290242b2a9a81683]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d65f63531c3f8e3e55e656f049240714a3d7433f
User & Date: drh 2011-10-18 22:07:47
Context
2011-10-19
16:20
Merge the fts4-content branch with the trunk. check-in: 8a407705 user: dan tags: trunk
2011-10-18
22:07
Fix the virtual table rename logic so that it works even if the database encoding is something other than UTF8. Ticket [8290242b2a9a81683] check-in: d65f6353 user: drh tags: trunk
19:14
Fix an uninitialized variable in OR-clause processing. check-in: 54aecd92 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbe.c.

  5884   5884   
  5885   5885     pVtab = pOp->p4.pVtab->pVtab;
  5886   5886     pName = &aMem[pOp->p1];
  5887   5887     assert( pVtab->pModule->xRename );
  5888   5888     assert( memIsValid(pName) );
  5889   5889     REGISTER_TRACE(pOp->p1, pName);
  5890   5890     assert( pName->flags & MEM_Str );
  5891         -  rc = pVtab->pModule->xRename(pVtab, pName->z);
  5892         -  importVtabErrMsg(p, pVtab);
  5893         -  p->expired = 0;
  5894         -
         5891  +  testcase( pName->enc==SQLITE_UTF8 );
         5892  +  testcase( pName->enc==SQLITE_UTF16BE );
         5893  +  testcase( pName->enc==SQLITE_UTF16LE );
         5894  +  rc = sqlite3VdbeChangeEncoding(pName, SQLITE_UTF8);
         5895  +  if( rc==SQLITE_OK ){
         5896  +    rc = pVtab->pModule->xRename(pVtab, pName->z);
         5897  +    importVtabErrMsg(p, pVtab);
         5898  +    p->expired = 0;
         5899  +  }
  5895   5900     break;
  5896   5901   }
  5897   5902   #endif
  5898   5903   
  5899   5904   #ifndef SQLITE_OMIT_VIRTUALTABLE
  5900   5905   /* Opcode: VUpdate P1 P2 P3 P4 *
  5901   5906   **

Changes to test/fts3d.test.

   300    300     execsql {
   301    301       UPDATE t1_segdir SET level = 2 WHERE level = 1 AND idx = 0;
   302    302       SELECT OPTIMIZE(t1) FROM t1 LIMIT 1;
   303    303       SELECT level, idx FROM t1_segdir ORDER BY level, idx;
   304    304     }
   305    305   } {{Index already optimal} 2 0}
   306    306   
          307  +
          308  +# ALTER TABLE RENAME should work regardless of the database encoding.
          309  +#
          310  +do_test fts3d-6.0 {
          311  +  db close
          312  +  forcedelete test.db
          313  +  sqlite3 db test.db
          314  +  db eval {
          315  +    PRAGMA encoding=UTF8;
          316  +    CREATE VIRTUAL TABLE fts USING fts3(a,b,c);
          317  +    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
          318  +  }
          319  +} {fts_content fts_segdir fts_segments}
          320  +do_test fts3d-6.1 {
          321  +  db eval {
          322  +    ALTER TABLE fts RENAME TO xyz;
          323  +    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
          324  +  }
          325  +} {xyz_content xyz_segdir xyz_segments}
          326  +do_test fts3d-6.2 {
          327  +  db close
          328  +  forcedelete test.db
          329  +  sqlite3 db test.db
          330  +  db eval {
          331  +    PRAGMA encoding=UTF16le;
          332  +    CREATE VIRTUAL TABLE fts USING fts3(a,b,c);
          333  +    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
          334  +  }
          335  +} {fts_content fts_segdir fts_segments}
          336  +do_test fts3d-6.3 {
          337  +  db eval {
          338  +    ALTER TABLE fts RENAME TO xyz;
          339  +    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
          340  +  }
          341  +} {xyz_content xyz_segdir xyz_segments}
          342  +do_test fts3d-6.4 {
          343  +  db close
          344  +  forcedelete test.db
          345  +  sqlite3 db test.db
          346  +  db eval {
          347  +    PRAGMA encoding=UTF16be;
          348  +    CREATE VIRTUAL TABLE fts USING fts3(a,b,c);
          349  +    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
          350  +  }
          351  +} {fts_content fts_segdir fts_segments}
          352  +do_test fts3d-6.5 {
          353  +  db eval {
          354  +    ALTER TABLE fts RENAME TO xyz;
          355  +    SELECT name FROM sqlite_master WHERE name GLOB '???_*' ORDER BY 1;
          356  +  }
          357  +} {xyz_content xyz_segdir xyz_segments}
          358  + 
          359  +
   307    360   finish_test