SQLite

Changes On Branch vcreate-stmt
Login

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

Changes In Branch vcreate-stmt Excluding Merge-Ins

This is equivalent to a diff from f6a88ccc to d0a3853b

2016-03-29
10:14
Version 3.12.0 (check-in: e9bb4cf4 user: drh tags: trunk, release, version-3.12.0)
2016-03-28
15:06
Integrate the vcreate-stmt branch into this one. (check-in: 06039d90 user: dan tags: fts5)
14:57
Open a statement transaction for "CREATE VIRTUAL TABLE" statements in order to ensure that if the xCreate() call fails, changes made to the sqlite_master and possibly other tables are rolled back. (Closed-Leaf check-in: d0a3853b user: dan tags: vcreate-stmt)
11:01
Fix the multiplexor so that it does not assume that the xGetLastError method is non-NULL in the child VFS. (check-in: f6a88ccc user: drh tags: trunk)
2016-03-26
15:36
More changes to the shellN.test scripts to get them working on all variations of Windows. (check-in: 8213c2f5 user: drh tags: trunk)

Changes to ext/fts5/test/fts5simple3.test.

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82















83
84
85
    set vals [list]
    for {set i 1} {$i <= 998} {incr i} {
      lappend cols "c$i"
      lappend vals "'val$i'"
    }
    execsql "CREATE VIRTUAL TABLE t2 USING fts5(detail=%DETAIL%,[join $cols ,])"
  } {}
  
  do_test 2.2 {
    execsql "INSERT INTO t2 VALUES([join $vals ,])"
  } {}
  
  foreach {tn q res} {
    1 { c1:val1 }     1
    2 { c300:val300 } 1
    3 { c300:val1 } {}
    4 { c1:val300 } {}
  } {
    do_execsql_test 2.3.$tn {
      SELECT rowid FROM t2($q)
    } $res
  }
}

do_execsql_test 3.0 {
  CREATE VIRTUAL TABLE x3 USING fts5(one);
  INSERT INTO x3 VALUES('a b c');
  INSERT INTO x3 VALUES('c b a');
  INSERT INTO x3 VALUES('o t t');
  SELECT * FROM x3('x OR y OR z');
}

















finish_test








|



|




















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



51
52
53
54
55
56
57
58
59
60
61
62
63
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
100
    set vals [list]
    for {set i 1} {$i <= 998} {incr i} {
      lappend cols "c$i"
      lappend vals "'val$i'"
    }
    execsql "CREATE VIRTUAL TABLE t2 USING fts5(detail=%DETAIL%,[join $cols ,])"
  } {}

  do_test 2.2 {
    execsql "INSERT INTO t2 VALUES([join $vals ,])"
  } {}
 
  foreach {tn q res} {
    1 { c1:val1 }     1
    2 { c300:val300 } 1
    3 { c300:val1 } {}
    4 { c1:val300 } {}
  } {
    do_execsql_test 2.3.$tn {
      SELECT rowid FROM t2($q)
    } $res
  }
}

do_execsql_test 3.0 {
  CREATE VIRTUAL TABLE x3 USING fts5(one);
  INSERT INTO x3 VALUES('a b c');
  INSERT INTO x3 VALUES('c b a');
  INSERT INTO x3 VALUES('o t t');
  SELECT * FROM x3('x OR y OR z');
}


#-------------------------------------------------------------------------
# Check that if a CREATE VIRTUAL TABLE statement fails within a 
# transaction, any changes made to the database are reverted before
# continuing.
#
reset_db
do_catchsql_test 4.0 {
  BEGIN;
    CREATE VIRTUAL TABLE t1 USING fts5;
} {1 {vtable constructor failed: t1}}

do_execsql_test 4.1 { SELECT * FROM sqlite_master } {}
do_execsql_test 4.2 { COMMIT }
do_execsql_test 4.3 { SELECT * FROM sqlite_master } {}

finish_test

Changes to src/vdbeaux.c.

505
506
507
508
509
510
511



512
513
514
515
516
517
518
     || ((opcode==OP_Halt || opcode==OP_HaltIfNull) 
      && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
    ){
      hasAbort = 1;
      break;
    }
    if( opcode==OP_CreateTable ) hasCreateTable = 1;



    if( opcode==OP_InitCoroutine ) hasInitCoroutine = 1;
#ifndef SQLITE_OMIT_FOREIGN_KEY
    if( opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1 ){
      hasFkCounter = 1;
    }
#endif
  }







>
>
>







505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
     || ((opcode==OP_Halt || opcode==OP_HaltIfNull) 
      && ((pOp->p1&0xff)==SQLITE_CONSTRAINT && pOp->p2==OE_Abort))
    ){
      hasAbort = 1;
      break;
    }
    if( opcode==OP_CreateTable ) hasCreateTable = 1;
#ifndef SQLITE_OMIT_VIRTUALTABLE
    if( opcode==OP_VCreate ) hasAbort = 1;
#endif
    if( opcode==OP_InitCoroutine ) hasInitCoroutine = 1;
#ifndef SQLITE_OMIT_FOREIGN_KEY
    if( opcode==OP_FkCounter && pOp->p1==0 && pOp->p2==1 ){
      hasFkCounter = 1;
    }
#endif
  }

Changes to src/vtab.c.

312
313
314
315
316
317
318

319
320
321
322
323
324
325
  int ifNotExists       /* No error if the table already exists */
){
  int iDb;              /* The database the table is being created in */
  Table *pTable;        /* The new virtual table */
  sqlite3 *db;          /* Database connection */

  sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);

  pTable = pParse->pNewTable;
  if( pTable==0 ) return;
  assert( 0==pTable->pIndex );

  db = pParse->db;
  iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
  assert( iDb>=0 );







>







312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
  int ifNotExists       /* No error if the table already exists */
){
  int iDb;              /* The database the table is being created in */
  Table *pTable;        /* The new virtual table */
  sqlite3 *db;          /* Database connection */

  sqlite3StartTable(pParse, pName1, pName2, 0, 0, 1, ifNotExists);
  sqlite3MayAbort(pParse);
  pTable = pParse->pNewTable;
  if( pTable==0 ) return;
  assert( 0==pTable->pIndex );

  db = pParse->db;
  iDb = sqlite3SchemaToIndex(db, pTable->pSchema);
  assert( iDb>=0 );