/ Check-in [37ad064e]
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 test script problems causing SQLITE_OMIT_VIRTUALTABLE builds to fail.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 37ad064e5f5704cf345d23b38b3f6d627fbcf20dbb78c8a91e96c9704760a1b8
User & Date: dan 2018-09-06 17:23:08
Context
2018-09-06
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
16:50
Merge accidental fork. check-in: ebadb7dc user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/altercol.test.

421
422
423
424
425
426
427

428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477

478
479
480
481
482
483
484

#-------------------------------------------------------------------------
# Test that views can be edited even if there are missing collation 
# sequences or user defined functions.
#
reset_db


foreach {tn old new lSchema} {
  1 _x_ _xxx_ {
    { CREATE TABLE t1(a, b, _x_) }
    { CREATE VIEW s1 AS SELECT a, b, _x_ FROM t1 WHERE _x_='abc' COLLATE xyz }
  }

  2 _x_ _xxx_ {
    { CREATE TABLE t1(a, b, _x_) }
    { CREATE VIEW v1 AS SELECT a, b, _x_ FROM t1 WHERE scalar(_x_) }
  }

  3 _x_ _xxx_ {
    { CREATE TABLE t1(a, b, _x_) }
    { CREATE VIEW v1 AS SELECT a, b, _x_ FROM t1 WHERE _x_ = unicode(1, 2, 3) }
  }

  4 _x_ _xxx_ {
    { CREATE TABLE t1(a, b, _x_) }
    { CREATE VIRTUAL TABLE e1 USING echo(t1) }
  }
} {
  register_echo_module db
  do_rename_column_test 10.$tn $old $new $lSchema
}

#--------------------------------------------------------------------------
# Test that if a view or trigger refers to a virtual table for which the
# module is not available, RENAME COLUMN cannot proceed.
#
reset_db
register_echo_module db
do_execsql_test 11.0 {
  CREATE TABLE x1(a, b, c);
  CREATE VIRTUAL TABLE e1 USING echo(x1);
}
db close
sqlite3 db test.db

do_execsql_test 11.1 {
  ALTER TABLE x1 RENAME b TO bbb;
  SELECT sql FROM sqlite_master;
} { {CREATE TABLE x1(a, bbb, c)} {CREATE VIRTUAL TABLE e1 USING echo(x1)} }

do_execsql_test 11.2 {
  CREATE VIEW v1 AS SELECT e1.*, x1.c FROM e1, x1;
}

do_catchsql_test 11.3 {
  ALTER TABLE x1 RENAME c TO ccc;
} {1 {error in view v1: no such module: echo}}


#-------------------------------------------------------------------------
# Test some error conditions:
#
#   1. Renaming a column of a system table,
#   2. Renaming a column of a VIEW,
#   3. Renaming a column of a virtual table.







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







421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486

#-------------------------------------------------------------------------
# Test that views can be edited even if there are missing collation 
# sequences or user defined functions.
#
reset_db

ifcapable vtab {
  foreach {tn old new lSchema} {
    1 _x_ _xxx_ {
      { CREATE TABLE t1(a, b, _x_) }
      { CREATE VIEW s1 AS SELECT a, b, _x_ FROM t1 WHERE _x_='abc' COLLATE xyz }
    }
  
    2 _x_ _xxx_ {
      { CREATE TABLE t1(a, b, _x_) }
      { CREATE VIEW v1 AS SELECT a, b, _x_ FROM t1 WHERE scalar(_x_) }
    }
  
    3 _x_ _xxx_ {
      { CREATE TABLE t1(a, b, _x_) }
      { CREATE VIEW v1 AS SELECT a, b, _x_ FROM t1 WHERE _x_ = unicode(1, 2, 3) }
    }
  
    4 _x_ _xxx_ {
      { CREATE TABLE t1(a, b, _x_) }
      { CREATE VIRTUAL TABLE e1 USING echo(t1) }
    }
  } {
    register_echo_module db
    do_rename_column_test 10.$tn $old $new $lSchema
  }
  
  #--------------------------------------------------------------------------
  # Test that if a view or trigger refers to a virtual table for which the
  # module is not available, RENAME COLUMN cannot proceed.
  #
  reset_db
  register_echo_module db
  do_execsql_test 11.0 {
    CREATE TABLE x1(a, b, c);
    CREATE VIRTUAL TABLE e1 USING echo(x1);
  }
  db close
  sqlite3 db test.db
  
  do_execsql_test 11.1 {
    ALTER TABLE x1 RENAME b TO bbb;
    SELECT sql FROM sqlite_master;
  } { {CREATE TABLE x1(a, bbb, c)} {CREATE VIRTUAL TABLE e1 USING echo(x1)} }
  
  do_execsql_test 11.2 {
    CREATE VIEW v1 AS SELECT e1.*, x1.c FROM e1, x1;
  }
  
  do_catchsql_test 11.3 {
    ALTER TABLE x1 RENAME c TO ccc;
  } {1 {error in view v1: no such module: echo}}
}

#-------------------------------------------------------------------------
# Test some error conditions:
#
#   1. Renaming a column of a system table,
#   2. Renaming a column of a VIEW,
#   3. Renaming a column of a virtual table.

Changes to test/altertab.test.

64
65
66
67
68
69
70

71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

91
92
93
94
95
96
97
  {CREATE TABLE "t2new"(a, b)}
  {CREATE INDEX t2expr ON "t2new"(a) WHERE "t2new".b>0}
}


#-------------------------------------------------------------------------
reset_db

register_echo_module db

do_execsql_test 2.0 {
  CREATE TABLE abc(a, b, c);
  INSERT INTO abc VALUES(1, 2, 3);
  CREATE VIRTUAL TABLE eee USING echo('abc');
  SELECT * FROM eee;
} {1 2 3}

do_execsql_test 2.1 {
  ALTER TABLE eee RENAME TO fff;
  SELECT * FROM fff;
} {1 2 3}

db close
sqlite3 db test.db

do_catchsql_test 2.2 {
  ALTER TABLE fff RENAME TO ggg;
} {1 {no such module: echo}}


#-------------------------------------------------------------------------
reset_db

do_execsql_test 3.0 {
  CREATE TABLE txx(a, b, c);
  INSERT INTO txx VALUES(1, 2, 3);







>
|

|
|
|
|
|
|

|
|
|
|

|
|

|
|
|
>







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  {CREATE TABLE "t2new"(a, b)}
  {CREATE INDEX t2expr ON "t2new"(a) WHERE "t2new".b>0}
}


#-------------------------------------------------------------------------
reset_db
ifcapable vtab {
  register_echo_module db

  do_execsql_test 2.0 {
    CREATE TABLE abc(a, b, c);
    INSERT INTO abc VALUES(1, 2, 3);
    CREATE VIRTUAL TABLE eee USING echo('abc');
    SELECT * FROM eee;
  } {1 2 3}

  do_execsql_test 2.1 {
    ALTER TABLE eee RENAME TO fff;
    SELECT * FROM fff;
  } {1 2 3}

  db close
  sqlite3 db test.db

  do_catchsql_test 2.2 {
    ALTER TABLE fff RENAME TO ggg;
  } {1 {no such module: echo}}
}

#-------------------------------------------------------------------------
reset_db

do_execsql_test 3.0 {
  CREATE TABLE txx(a, b, c);
  INSERT INTO txx VALUES(1, 2, 3);