Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(186)

Side by Side Diff: third_party/sqlite_google/src/btree.c

Issue 924: sqlite3 pragma get/set user_version implemented (Closed) SVN Base: http://google-gears.googlecode.com/svn/contrib/dimitri.glazkov/database2/gears/
Patch Set: Removed starting a transaction, just report SQLITE_MISUSE now. Created 4 months, 1 week ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 ** 2004 April 6 2 ** 2004 April 6
3 ** 3 **
4 ** The author disclaims copyright to this source code. In place of 4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing: 5 ** a legal notice, here is a blessing:
6 ** 6 **
7 ** May you do good and not evil. 7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others. 8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give. 9 ** May you share freely, never taking more than you give.
10 ** 10 **
(...skipping 11 matching lines...) Show 10 above Show 10 below
22 ** SQLite database. 22 ** SQLite database.
23 */ 23 */
24 static const char zMagicHeader[] = SQLITE_FILE_HEADER; 24 static const char zMagicHeader[] = SQLITE_FILE_HEADER;
25 25
26 /* 26 /*
27 ** The header string that appears at the beginning of a SQLite 27 ** The header string that appears at the beginning of a SQLite
28 ** database which has been poisoned. 28 ** database which has been poisoned.
29 */ 29 */
30 static const char zPoisonHeader[] = "SQLite poison 3"; 30 static const char zPoisonHeader[] = "SQLite poison 3";
31 31
32 /*
33 ** The user cookie position in the database meta information
34 ** (see prepare.c#215), incremented by one, because first position is actually
35 ** the number of free pages in Btree (see vdbe.c#2521)
36 */
37 static const int kUserCookie = 6;
32 38
33 /* 39 /*
34 ** Set this global variable to 1 to enable tracing using the TRACE 40 ** Set this global variable to 1 to enable tracing using the TRACE
35 ** macro. 41 ** macro.
36 */ 42 */
37 #if SQLITE_TEST 43 #if SQLITE_TEST
38 int sqlite3_btree_trace=0; /* True to enable tracing */ 44 int sqlite3_btree_trace=0; /* True to enable tracing */
39 #endif 45 #endif
40 46
41 /* 47 /*
(...skipping 6373 matching lines...) Show 10 above Show 10 below
6415 /* Push it to the database file. */ 6421 /* Push it to the database file. */
6416 return sqlite3BtreeCommit(p); 6422 return sqlite3BtreeCommit(p);
6417 6423
6418 err: 6424 err:
6419 /* TODO(shess): What about errors, here? */ 6425 /* TODO(shess): What about errors, here? */
6420 sqlite3BtreeRollback(p); 6426 sqlite3BtreeRollback(p);
6421 return rc; 6427 return rc;
6422 } 6428 }
6423 6429
6424 #endif 6430 #endif
6431
6432 int sqlite3_get_user_version(sqlite3 *sqlite, int *user_version) {
Scott.Hess 2008/06/04 17:48:56 Did you copy 'sqlite3 *sqlite' from somewhere? If
Dimitri 2008/06/11 01:31:57 On 2008/06/04 17:48:56, Scott.Hess wrote: > Did yo
6433 Btree *bt;
6434
6435 if( sqlite == NULL ) return SQLITE_ERROR;
Scott.Hess 2008/06/04 17:48:56 SQLite style is 'sqlite==NULL' rather than 'sqlite
Dimitri 2008/06/11 01:31:57 On 2008/06/04 17:48:56, Scott.Hess wrote: > SQLite
6436 if( sqlite->nDb<1 ) return SQLITE_ERROR;
6437
6438 /* Grab main database. */
6439 bt = sqlite->aDb[0].pBt;
6440 /* Because sqlite3BtreeGetMeta sets a table read lock, it is safe to use
6441 ** without explicit read transaction. Besides, it is very unlikely we will
6442 ** ever call this outside of a transaction.
6443 */
Scott.Hess 2008/06/04 17:48:56 Suggest dropping the caveat about unlikely things.
Dimitri 2008/06/11 01:31:57 On 2008/06/04 17:48:56, Scott.Hess wrote: > Sugges
6444 return sqlite3BtreeGetMeta(bt, kUserCookie, (u32 *)user_version);
Scott.Hess 2008/06/04 17:48:56 Why the cast? Alternate phrasing: Why isn't user_
Dimitri 2008/06/11 01:31:57 On 2008/06/04 17:48:56, Scott.Hess wrote: > Why th
6445 }
6446
6447 int sqlite3_set_user_version(sqlite3 *sqlite, int user_version) {
Scott.Hess 2008/06/04 17:48:56 Comparable comments to above on sqlite/db and user
Dimitri 2008/06/11 01:31:57 On 2008/06/04 17:48:56, Scott.Hess wrote: > Compar
6448 Btree *bt;
6449
6450 if( sqlite == NULL ) return SQLITE_ERROR;
Scott.Hess 2008/06/04 17:48:56 No spaces around ==.
Dimitri 2008/06/11 01:31:57 On 2008/06/04 17:48:56, Scott.Hess wrote: > No spa
6451 if( sqlite->nDb<1 ) return SQLITE_ERROR;
6452
6453 bt = sqlite->aDb[0].pBt;
6454
6455 /* If called outside of a transaction, report misuse. */
6456 if( bt->inTrans != TRANS_WRITE ) return SQLITE_MISUSE;
Scott.Hess 2008/06/04 17:48:56 No spaces around !=.
Dimitri 2008/06/11 01:31:57 On 2008/06/04 17:48:56, Scott.Hess wrote: > No spa
6457
6458 return sqlite3BtreeUpdateMeta(bt, kUserCookie, (u32)user_version);
Scott.Hess 2008/06/04 17:48:56 Comparable comment as above around cast.
Dimitri 2008/06/11 01:31:57 On 2008/06/04 17:48:56, Scott.Hess wrote: > Compar
6459 }
OLDNEW

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld r338