/ Changes On Branch dropViewNoStat
Login

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

Changes In Branch dropViewNoStat Excluding Merge-Ins

This is equivalent to a diff from 489f3caf5d to 523ff77925

2018-07-27
22:55
When doing a DROP VIEW do not try to delete entries from the sqlite_stat1 table as there are none. (check-in: 7efdba2bbc user: drh tags: trunk)
2018-07-22
00:45
Remove an unused branch in the FK logic. (Closed-Leaf check-in: 523ff77925 user: drh tags: dropViewNoStat)
2018-07-21
23:15
In 'resetdb.test', close a database prior to trying to delete it. (check-in: 45137053a5 user: mistachkin tags: trunk)
2018-07-20
20:56
When dropping a view, skip trying to delete from 'sqlite_stat*'. (check-in: 2f5be3a2dd user: mistachkin tags: dropViewNoStat)
19:24
Change the SQLITE_Stat34 bit of the optimization test-control so that it prevents STAT4 data from being used but allows it to be loaded into the Index objects. This permits STAT4 to be turned on and off on a per-statement basis. (check-in: 489f3caf5d user: drh tags: trunk)
15:44
New checks in PRAGMA integrity_check to validate the autovacuum settings in the header. (check-in: a4663f09c9 user: drh tags: trunk)

Changes to src/build.c.

  2658   2658   
  2659   2659     /* Generate code to remove the table from the master table
  2660   2660     ** on disk.
  2661   2661     */
  2662   2662     v = sqlite3GetVdbe(pParse);
  2663   2663     if( v ){
  2664   2664       sqlite3BeginWriteOperation(pParse, 1, iDb);
  2665         -    sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName);
  2666         -    sqlite3FkDropTable(pParse, pName, pTab);
         2665  +    if( !isView ){
         2666  +      sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName);
         2667  +      sqlite3FkDropTable(pParse, pName, pTab);
         2668  +    }
  2667   2669       sqlite3CodeDropTable(pParse, pTab, iDb, isView);
  2668   2670     }
  2669   2671   
  2670   2672   exit_drop_table:
  2671   2673     sqlite3SrcListDelete(db, pName);
  2672   2674   }
  2673   2675   

Changes to src/fkey.c.

   706    706   **
   707    707   ** then the equivalent of "DELETE FROM <tbl>" is executed before dropping
   708    708   ** the table from the database. Triggers are disabled while running this
   709    709   ** DELETE, but foreign key actions are not.
   710    710   */
   711    711   void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){
   712    712     sqlite3 *db = pParse->db;
   713         -  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) && !pTab->pSelect ){
          713  +  if( (db->flags&SQLITE_ForeignKeys) && !IsVirtual(pTab) ){
   714    714       int iSkip = 0;
   715    715       Vdbe *v = sqlite3GetVdbe(pParse);
   716    716   
   717    717       assert( v );                  /* VDBE has already been allocated */
          718  +    assert( pTab->pSelect==0 );   /* Not a view */
   718    719       if( sqlite3FkReferences(pTab)==0 ){
   719    720         /* Search for a deferred foreign key constraint for which this table
   720    721         ** is the child table. If one cannot be found, return without 
   721    722         ** generating any VDBE code. If one can be found, then jump over
   722    723         ** the entire DELETE if there are no outstanding deferred constraints
   723    724         ** when this statement is run.  */
   724    725         FKey *p;

Changes to test/view.test.

   670    670   } {123 234 345}
   671    671   do_test view-22.2 {
   672    672     unset -nocomplain x
   673    673     db eval {SELECT * FROM x1} x break
   674    674     lsort [array names x]
   675    675   } {{} * :1 :2}
   676    676   
          677  +do_test view-25.1 {
          678  +  db eval {
          679  +    CREATE TABLE t25 (x);
          680  +    INSERT INTO t25 (x) VALUES (1);
          681  +    ANALYZE;
          682  +  }
          683  +  proc authLogDelete {code arg1 arg2 arg3 arg4 args} {
          684  +    if {$code=="SQLITE_DELETE" && [string match sqlite_stat* $arg1]} {
          685  +      lappend ::log [list $code $arg1 $arg2 $arg3 $arg4 $args]
          686  +    }
          687  +    return SQLITE_OK
          688  +  }
          689  +  set log ""
          690  +  db authorizer ::authLogDelete
          691  +  db eval {DROP VIEW x1;}
          692  +  set log
          693  +} {}
          694  +do_test view-25.2 {
          695  +  set log ""
          696  +  db eval {DROP TABLE t25;}
          697  +  set log
          698  +} {{SQLITE_DELETE sqlite_stat1 {} main {} {}}}
   677    699   
   678    700   finish_test