/ Check-in [6c100887]
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:Use read-only transactions. (CVS 1504)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 6c100887eeb32631e1aa914a69db959e1f58f192
User & Date: danielk1977 2004-05-31 11:51:45
Context
2004-05-31
12:34
Some test cases for read locks (CVS 1505) check-in: 0e070067 user: danielk1977 tags: trunk
11:51
Use read-only transactions. (CVS 1504) check-in: 6c100887 user: danielk1977 tags: trunk
10:08
Bugfix for previous checkin. (CVS 1503) check-in: 5f869fbf user: danielk1977 tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
....
2222
2223
2224
2225
2226
2227
2228

2229
2230
2231

2232
2233
2234
2235
2236
2237
2238
....
2249
2250
2251
2252
2253
2254
2255

2256
2257
2258
2259



2260
2261
2262
2263
2264
2265
2266
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**     PRAGMA
**
** $Id: build.c,v 1.203 2004/05/31 10:01:35 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Check to see if the schema for the database needs
................................................................................
/*
** Generate VDBE code that will verify the schema cookie for all
** named database files.
*/
void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
  sqlite *db = pParse->db;
  Vdbe *v = sqlite3GetVdbe(pParse);

  assert( iDb>=0 && iDb<db->nDb );
  assert( db->aDb[iDb].pBt!=0 );
  if( iDb!=1 && (iDb>63 || !(pParse->cookieMask & ((u64)1<<iDb))) ){

    sqlite3VdbeAddOp(v, OP_VerifyCookie, iDb, db->aDb[iDb].schema_cookie);
    pParse->cookieMask |= ((u64)1<<iDb);
  }
}

/*
** Generate VDBE code that prepares for doing an operation that
................................................................................
**
** Only database iDb and the temp database are made writable by this call.
** If iDb==0, then the main and temp databases are made writable.   If
** iDb==1 then only the temp database is made writable.  If iDb>1 then the
** specified auxiliary database and the temp database are made writable.
*/
void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){

  Vdbe *v = sqlite3GetVdbe(pParse);
  if( v==0 ) return;
  sqlite3VdbeAddOp(v, OP_Transaction, iDb, 1);
  sqlite3CodeVerifySchema(pParse, iDb);



  if( setStatement ){
    sqlite3VdbeAddOp(v, OP_Statement, iDb, 0);
  }
  if( iDb!=1 ){
    sqlite3BeginWriteOperation(pParse, setStatement, 1);
  }
}







|







 







>



>







 







>



|
>
>
>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
....
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
....
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
**     DROP INDEX
**     creating ID lists
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**     PRAGMA
**
** $Id: build.c,v 1.204 2004/05/31 11:51:45 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Check to see if the schema for the database needs
................................................................................
/*
** Generate VDBE code that will verify the schema cookie for all
** named database files.
*/
void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
  sqlite *db = pParse->db;
  Vdbe *v = sqlite3GetVdbe(pParse);
  if( v==0 ) return;
  assert( iDb>=0 && iDb<db->nDb );
  assert( db->aDb[iDb].pBt!=0 );
  if( iDb!=1 && (iDb>63 || !(pParse->cookieMask & ((u64)1<<iDb))) ){
    sqlite3VdbeAddOp(v, OP_Transaction, iDb, 0);
    sqlite3VdbeAddOp(v, OP_VerifyCookie, iDb, db->aDb[iDb].schema_cookie);
    pParse->cookieMask |= ((u64)1<<iDb);
  }
}

/*
** Generate VDBE code that prepares for doing an operation that
................................................................................
**
** Only database iDb and the temp database are made writable by this call.
** If iDb==0, then the main and temp databases are made writable.   If
** iDb==1 then only the temp database is made writable.  If iDb>1 then the
** specified auxiliary database and the temp database are made writable.
*/
void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){
  sqlite *db = pParse->db;
  Vdbe *v = sqlite3GetVdbe(pParse);
  if( v==0 ) return;
  sqlite3VdbeAddOp(v, OP_Transaction, iDb, 1);
  if( iDb!=1 && (iDb>63 || !(pParse->cookieMask & ((u64)1<<iDb))) ){
    sqlite3VdbeAddOp(v, OP_VerifyCookie, iDb, db->aDb[iDb].schema_cookie);
    pParse->cookieMask |= ((u64)1<<iDb);
  }
  if( setStatement ){
    sqlite3VdbeAddOp(v, OP_Statement, iDb, 0);
  }
  if( iDb!=1 ){
    sqlite3BeginWriteOperation(pParse, setStatement, 1);
  }
}