/ Check-in [fa835145]
Login

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

Overview
Comment:Fix a problem in ALTER TABLE with SQLITE_OMIT_VIRTUALTABLE builds.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fa835145e63749e06e04bd50ff992afaeae05dcdd1df597d13911f944e62076b
User & Date: dan 2018-09-06 17:47:09
Context
2018-09-06
18:56
Fix a problem with ALTER TABLE when there are views or triggers in the schema that contain "<expr> IS NULL" expressions. check-in: 91aab32e user: dan tags: trunk
17:47
Fix a problem in ALTER TABLE with SQLITE_OMIT_VIRTUALTABLE builds. check-in: fa835145 user: dan tags: trunk
17:23
Fix test script problems causing SQLITE_OMIT_VIRTUALTABLE builds to fail. check-in: 37ad064e user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/alter.c.

478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
*/
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
static int isRealTable(Parse *pParse, Table *pTab){
  const char *zType = 0;
#ifndef SQLITE_OMIT_VIEW
  if( pTab->pSelect ){
    zType = "view";
  }else 
#endif
#ifndef SQLITE_OMIT_VIRTUALTABLE
  if( IsVirtual(pTab) ){
    zType = "virtual table";
  }
#endif
  if( zType ){







|







478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
*/
#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)
static int isRealTable(Parse *pParse, Table *pTab){
  const char *zType = 0;
#ifndef SQLITE_OMIT_VIEW
  if( pTab->pSelect ){
    zType = "view";
  }
#endif
#ifndef SQLITE_OMIT_VIRTUALTABLE
  if( IsVirtual(pTab) ){
    zType = "virtual table";
  }
#endif
  if( zType ){

Changes to test/altertab.test.

205
206
207
208
209
210
211

212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246

247
248
249
250
251
252
253

do_catchsql_test 5.6 {
  ALTER TABLE t2 RENAME TO one;
} {1 {error in view vv after rename: ambiguous column name: one.a}}

#-------------------------------------------------------------------------


register_tcl_module db
proc tcl_command {method args} {
  switch -- $method {
    xConnect {
      return "CREATE TABLE t1(a, b, c)"
    }
  }
  return {}
}

do_execsql_test 6.0 {
  CREATE VIRTUAL TABLE x1 USING tcl(tcl_command);
}

do_execsql_test 6.1 {
  ALTER TABLE x1 RENAME TO x2;
  SELECT sql FROM sqlite_master WHERE name = 'x2'
} {{CREATE VIRTUAL TABLE "x2" USING tcl(tcl_command)}}

do_execsql_test 7.1 {
  CREATE TABLE ddd(db, sql, zOld, zNew, bTemp);
  INSERT INTO ddd VALUES(
      'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', 'ddd', NULL, 0
  ), (
      'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', NULL, 'eee', 0
  ), (
      'main', NULL, 'ddd', 'eee', 0
  );
} {}

do_execsql_test 7.2 {
  SELECT 
  sqlite_rename_table(db, 0, 0, sql, zOld, zNew, bTemp)
  FROM ddd;
} {{} {} {}}


#-------------------------------------------------------------------------
#
reset_db
forcedelete test.db2
do_execsql_test 8.1 {
  ATTACH 'test.db2' AS aux;







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







205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255

do_catchsql_test 5.6 {
  ALTER TABLE t2 RENAME TO one;
} {1 {error in view vv after rename: ambiguous column name: one.a}}

#-------------------------------------------------------------------------

ifcapable vtab {
  register_tcl_module db
  proc tcl_command {method args} {
    switch -- $method {
      xConnect {
        return "CREATE TABLE t1(a, b, c)"
      }
    }
    return {}
  }
  
  do_execsql_test 6.0 {
    CREATE VIRTUAL TABLE x1 USING tcl(tcl_command);
  }
  
  do_execsql_test 6.1 {
    ALTER TABLE x1 RENAME TO x2;
    SELECT sql FROM sqlite_master WHERE name = 'x2'
  } {{CREATE VIRTUAL TABLE "x2" USING tcl(tcl_command)}}
  
  do_execsql_test 7.1 {
    CREATE TABLE ddd(db, sql, zOld, zNew, bTemp);
    INSERT INTO ddd VALUES(
        'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', 'ddd', NULL, 0
    ), (
        'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', NULL, 'eee', 0
    ), (
        'main', NULL, 'ddd', 'eee', 0
    );
  } {}
  
  do_execsql_test 7.2 {
    SELECT 
    sqlite_rename_table(db, 0, 0, sql, zOld, zNew, bTemp)
    FROM ddd;
  } {{} {} {}}
}

#-------------------------------------------------------------------------
#
reset_db
forcedelete test.db2
do_execsql_test 8.1 {
  ATTACH 'test.db2' AS aux;

Changes to test/auth.test.

2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
#    MAIN: CREATE TABLE "t2"(a,b,c);
#    MAIN: CREATE TABLE t4(a,b,c);
#    MAIN: CREATE INDEX t4i1 ON t4(a);
#    MAIN: CREATE INDEX t4i2 ON t4(b,a,c);
#    MAIN: CREATE TABLE sqlite_stat1(tbl,idx,stat);
#    MAIN: CREATE TABLE t1(a,b);
#
ifcapable altertable {
  do_test 1.350 {
    proc auth {code arg1 arg2 arg3 arg4 args} {
      if {$code=="SQLITE_ALTER_TABLE"} {
        set ::authargs [list $arg1 $arg2 $arg3 $arg4]
        return SQLITE_OK
      }
      return SQLITE_OK







|







2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
#    MAIN: CREATE TABLE "t2"(a,b,c);
#    MAIN: CREATE TABLE t4(a,b,c);
#    MAIN: CREATE INDEX t4i1 ON t4(a);
#    MAIN: CREATE INDEX t4i2 ON t4(b,a,c);
#    MAIN: CREATE TABLE sqlite_stat1(tbl,idx,stat);
#    MAIN: CREATE TABLE t1(a,b);
#
ifcapable altertable&&vtab {
  do_test 1.350 {
    proc auth {code arg1 arg2 arg3 arg4 args} {
      if {$code=="SQLITE_ALTER_TABLE"} {
        set ::authargs [list $arg1 $arg2 $arg3 $arg4]
        return SQLITE_OK
      }
      return SQLITE_OK