Add the journal_mode pragma. This is currently just syntax - it is not
operational. (CVS 5024) FossilOrigin-Name: 8eaa0c71023ac428f6f9f8091341584caa773ab9
This commit is contained in:
parent
f3a87624a2
commit
3b02013e73
20
manifest
20
manifest
@ -1,5 +1,5 @@
|
||||
C In\sexclusive\slocking\smode,\scommit\sby\szeroing\sthe\sfirst\s28\sbytes\sof\sthe\njournal\sfile,\snot\sby\struncating\sthe\sjournal.\s\sOverwriting\sis\smuch\sfaster\nthan\struncating.\s(CVS\s5023)
|
||||
D 2008-04-17T14:16:42
|
||||
C Add\sthe\sjournal_mode\spragma.\s\sThis\sis\scurrently\sjust\ssyntax\s-\sit\sis\snot\noperational.\s(CVS\s5024)
|
||||
D 2008-04-17T17:02:01
|
||||
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
|
||||
F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -82,7 +82,7 @@ F sqlite3.def a1be7b9a4b8b51ac41c6ff6e8e44a14ef66b338b
|
||||
F sqlite3.pc.in 32b8a014799c2028c8e0c9cc5659718262fc493f
|
||||
F src/alter.c b42d782906fc3b92c331efbe06e9389617b47ce7
|
||||
F src/analyze.c 9ee63497ee720728abe630d169ab91323ac7519c
|
||||
F src/attach.c bdc75e759ca25a16f4dc7fbdbc6d37ad2561bb24
|
||||
F src/attach.c 496cc628b2e8c4d8db99d7c136761fcbebd8420b
|
||||
F src/auth.c c8b2ab5c8bad4bd90ed7c294694f48269162c627
|
||||
F src/bitvec.c 8ec2212cfb702bc4f402c0b7ae7623d85320c714
|
||||
F src/btmutex.c 483ced3c52205b04b97df69161fadbf87f4f1ea2
|
||||
@ -127,10 +127,10 @@ F src/os_unix.c fdec4e5ee5dd555a6ad4a69f38ab35f0788536b4
|
||||
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
|
||||
F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403
|
||||
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
|
||||
F src/pager.c 13f1aca7567854ea5470b04de6fd370981d4f11a
|
||||
F src/pager.h b1e2258f03878c14b06a95bfa362e8c5c9638170
|
||||
F src/pager.c 84dc8bc0aa6d010d5904680801f353c4bc83717e
|
||||
F src/pager.h 45ec2188593afd48a25c743529646771d75e83e4
|
||||
F src/parse.y bc1b1cc6f86a0e0b669abdd88ddbdc7c8b67318d
|
||||
F src/pragma.c e659c9e443d11854cff2fd250012365ae0ca81ba
|
||||
F src/pragma.c 113f14da852b4f94edcf4af718702287b15641e8
|
||||
F src/prepare.c adc7e1fc08dfbab63cd213d4c0aff8f3fa70d477
|
||||
F src/printf.c 05d2b44d7b5b80c8a4a09108ddad9c20e254370d
|
||||
F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a
|
||||
@ -139,7 +139,7 @@ F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
|
||||
F src/shell.c be22ec05c8c4a43a95a6ad3b8068542200451e07
|
||||
F src/sqlite.h.in bbb063e9055d1833a3fe3926ffc2ef555cfd1da1
|
||||
F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
|
||||
F src/sqliteInt.h 625375d9327f0d79bf6f0f7864cc4a0543aec440
|
||||
F src/sqliteInt.h f06ba8e00fb8232bfef14d203d131ad96f858e04
|
||||
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
|
||||
F src/table.c 2c48c575dd59b3a6c5c306bc55f51a9402cf429a
|
||||
F src/tclsqlite.c 2877726bf32f7d72ff057b37ed6c93485b667ea1
|
||||
@ -631,7 +631,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
|
||||
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
|
||||
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
|
||||
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
|
||||
P 6765ea52b33270a323c620b060cffd4f59004db1
|
||||
R 4569523d5d602bd2203ece943294a1b5
|
||||
P 8efb7f4ffbfc3ad901a3bb1b4ff9390b8c13760b
|
||||
R 0ca2532289144ce972e1e34dde122f5d
|
||||
U drh
|
||||
Z 4fd5f97a9d54ecd6d758d13ff0d6babf
|
||||
Z 85f8f8b96162a61bffd06c2b76777b7a
|
||||
|
@ -1 +1 @@
|
||||
8efb7f4ffbfc3ad901a3bb1b4ff9390b8c13760b
|
||||
8eaa0c71023ac428f6f9f8091341584caa773ab9
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to implement the ATTACH and DETACH commands.
|
||||
**
|
||||
** $Id: attach.c,v 1.74 2008/03/20 14:03:29 drh Exp $
|
||||
** $Id: attach.c,v 1.75 2008/04/17 17:02:01 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
|
||||
@ -137,6 +137,7 @@ static void attachFunc(
|
||||
db->openFlags | SQLITE_OPEN_MAIN_DB,
|
||||
&aNew->pBt);
|
||||
if( rc==SQLITE_OK ){
|
||||
Pager *pPager;
|
||||
aNew->pSchema = sqlite3SchemaGet(db, aNew->pBt);
|
||||
if( !aNew->pSchema ){
|
||||
rc = SQLITE_NOMEM;
|
||||
@ -145,7 +146,9 @@ static void attachFunc(
|
||||
"attached databases must use the same text encoding as main database");
|
||||
goto attach_error;
|
||||
}
|
||||
sqlite3PagerLockingMode(sqlite3BtreePager(aNew->pBt), db->dfltLockMode);
|
||||
pPager = sqlite3BtreePager(aNew->pBt);
|
||||
sqlite3PagerLockingMode(pPager, db->dfltLockMode);
|
||||
sqlite3PagerJournalMode(pPager, db->dfltJournalMode);
|
||||
}
|
||||
aNew->zName = sqlite3DbStrDup(db, zName);
|
||||
aNew->safety_level = 3;
|
||||
|
25
src/pager.c
25
src/pager.c
@ -18,7 +18,7 @@
|
||||
** file simultaneously, or one process from reading the database while
|
||||
** another is writing.
|
||||
**
|
||||
** @(#) $Id: pager.c,v 1.427 2008/04/17 14:16:42 drh Exp $
|
||||
** @(#) $Id: pager.c,v 1.428 2008/04/17 17:02:01 drh Exp $
|
||||
*/
|
||||
#ifndef SQLITE_OMIT_DISKIO
|
||||
#include "sqliteInt.h"
|
||||
@ -350,6 +350,7 @@ struct Pager {
|
||||
u8 setMaster; /* True if a m-j name has been written to jrnl */
|
||||
u8 doNotSync; /* Boolean. While true, do not spill the cache */
|
||||
u8 exclusiveMode; /* Boolean. True if locking_mode==EXCLUSIVE */
|
||||
u8 persistJournal; /* True if persistent_journal=ON */
|
||||
u8 changeCountDone; /* Set after incrementing the change-counter */
|
||||
u32 vfsFlags; /* Flags for sqlite3_vfs.xOpen() */
|
||||
int errCode; /* One of several kinds of errors */
|
||||
@ -5203,6 +5204,28 @@ int sqlite3PagerLockingMode(Pager *pPager, int eMode){
|
||||
return (int)pPager->exclusiveMode;
|
||||
}
|
||||
|
||||
/*
|
||||
** Get/set the journal-mode for this pager. Parameter eMode must be one
|
||||
** of PAGER_JOURNALMODE_QUERY, PAGER_JOURNALMODE_DELETE or
|
||||
** PAGER_JOURNALMODE_PERSIST. If the parameter is not _QUERY, then
|
||||
** the journal-mode is set to the value specified.
|
||||
**
|
||||
** The returned value is either PAGER_JOURNALMODE_DELETE or
|
||||
** PAGER_JOURNALMODE_PERSIST, indicating the current (possibly updated)
|
||||
** journal-mode.
|
||||
*/
|
||||
int sqlite3PagerJournalMode(Pager *pPager, int eMode){
|
||||
assert( eMode==PAGER_JOURNALMODE_QUERY
|
||||
|| eMode==PAGER_JOURNALMODE_DELETE
|
||||
|| eMode==PAGER_JOURNALMODE_PERSIST );
|
||||
assert( PAGER_JOURNALMODE_QUERY<0 );
|
||||
assert( PAGER_JOURNALMODE_DELETE>=0 && PAGER_JOURNALMODE_PERSIST>=0 );
|
||||
if( eMode>=0 && !pPager->tempFile ){
|
||||
pPager->persistJournal = eMode;
|
||||
}
|
||||
return (int)pPager->persistJournal;
|
||||
}
|
||||
|
||||
#ifdef SQLITE_TEST
|
||||
/*
|
||||
** Print a listing of all referenced pages and their ref count.
|
||||
|
11
src/pager.h
11
src/pager.h
@ -13,7 +13,7 @@
|
||||
** subsystem. The page cache subsystem reads and writes a file a page
|
||||
** at a time and provides a journal for rollback.
|
||||
**
|
||||
** @(#) $Id: pager.h,v 1.70 2008/03/20 11:04:21 danielk1977 Exp $
|
||||
** @(#) $Id: pager.h,v 1.71 2008/04/17 17:02:01 drh Exp $
|
||||
*/
|
||||
|
||||
#ifndef _PAGER_H_
|
||||
@ -50,6 +50,14 @@ typedef struct PgHdr DbPage;
|
||||
#define PAGER_LOCKINGMODE_NORMAL 0
|
||||
#define PAGER_LOCKINGMODE_EXCLUSIVE 1
|
||||
|
||||
/*
|
||||
** Valid values for the second argument to sqlite3PagerJournalMode().
|
||||
*/
|
||||
#define PAGER_JOURNALMODE_QUERY -1
|
||||
#define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */
|
||||
#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */
|
||||
#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */
|
||||
|
||||
/*
|
||||
** See source code comments for a detailed description of the following
|
||||
** routines:
|
||||
@ -94,6 +102,7 @@ int sqlite3PagerMovepage(Pager*,DbPage*,Pgno);
|
||||
void *sqlite3PagerGetData(DbPage *);
|
||||
void *sqlite3PagerGetExtra(DbPage *);
|
||||
int sqlite3PagerLockingMode(Pager *, int);
|
||||
int sqlite3PagerJournalMode(Pager *, int);
|
||||
void *sqlite3PagerTempSpace(Pager*);
|
||||
int sqlite3PagerSync(Pager *pPager);
|
||||
|
||||
|
57
src/pragma.c
57
src/pragma.c
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** This file contains code used to implement the PRAGMA command.
|
||||
**
|
||||
** $Id: pragma.c,v 1.174 2008/03/27 22:42:52 drh Exp $
|
||||
** $Id: pragma.c,v 1.175 2008/04/17 17:02:02 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include <ctype.h>
|
||||
@ -424,6 +424,61 @@ void sqlite3Pragma(
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, zRet, 0);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
|
||||
}else
|
||||
|
||||
/*
|
||||
** PRAGMA [database.]journal_mode
|
||||
** PRAGMA [database.]journal_mode = (delete|persist|off)
|
||||
*/
|
||||
if( sqlite3StrICmp(zLeft,"journal_mode")==0 ){
|
||||
int eMode;
|
||||
static const char *azModeName[] = {"delete", "persist", "off"};
|
||||
|
||||
if( zRight==0 ){
|
||||
eMode = PAGER_JOURNALMODE_QUERY;
|
||||
}else{
|
||||
int n = strlen(zRight);
|
||||
eMode = 2;
|
||||
while( eMode>=0 && sqlite3StrNICmp(zRight, azModeName[eMode], n)!=0 ){
|
||||
eMode--;
|
||||
}
|
||||
}
|
||||
if( pId2->n==0 && eMode==PAGER_JOURNALMODE_QUERY ){
|
||||
/* Simple "PRAGMA persistent_journal;" statement. This is a query for
|
||||
** the current default journal mode (which may be different to
|
||||
** the journal-mode of the main database).
|
||||
*/
|
||||
eMode = db->dfltJournalMode;
|
||||
}else{
|
||||
Pager *pPager;
|
||||
if( pId2->n==0 ){
|
||||
/* This indicates that no database name was specified as part
|
||||
** of the PRAGMA command. In this case the journal-mode must be
|
||||
** set on all attached databases, as well as the main db file.
|
||||
**
|
||||
** Also, the sqlite3.dfltJournalMode variable is set so that
|
||||
** any subsequently attached databases also use the specified
|
||||
** journal mode.
|
||||
*/
|
||||
int ii;
|
||||
assert(pDb==&db->aDb[0]);
|
||||
for(ii=2; ii<db->nDb; ii++){
|
||||
pPager = sqlite3BtreePager(db->aDb[ii].pBt);
|
||||
sqlite3PagerJournalMode(pPager, eMode);
|
||||
}
|
||||
db->dfltJournalMode = eMode;
|
||||
}
|
||||
pPager = sqlite3BtreePager(pDb->pBt);
|
||||
eMode = sqlite3PagerJournalMode(pPager, eMode);
|
||||
}
|
||||
assert( eMode==PAGER_JOURNALMODE_DELETE
|
||||
|| eMode==PAGER_JOURNALMODE_PERSIST
|
||||
|| eMode==PAGER_JOURNALMODE_OFF );
|
||||
sqlite3VdbeSetNumCols(v, 1);
|
||||
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "journal_mode", P4_STATIC);
|
||||
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0,
|
||||
azModeName[eMode], P4_STATIC);
|
||||
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 1);
|
||||
}else
|
||||
#endif /* SQLITE_OMIT_PAGER_PRAGMAS */
|
||||
|
||||
/*
|
||||
|
@ -11,7 +11,7 @@
|
||||
*************************************************************************
|
||||
** Internal interface definitions for SQLite.
|
||||
**
|
||||
** @(#) $Id: sqliteInt.h,v 1.693 2008/04/15 14:36:42 drh Exp $
|
||||
** @(#) $Id: sqliteInt.h,v 1.694 2008/04/17 17:02:02 drh Exp $
|
||||
*/
|
||||
#ifndef _SQLITEINT_H_
|
||||
#define _SQLITEINT_H_
|
||||
@ -553,6 +553,8 @@ struct sqlite3 {
|
||||
u8 autoCommit; /* The auto-commit flag. */
|
||||
u8 temp_store; /* 1: file 2: memory 0: default */
|
||||
u8 mallocFailed; /* True if we have seen a malloc failure */
|
||||
u8 dfltLockMode; /* Default locking-mode for attached dbs */
|
||||
u8 dfltJournalMode; /* Default journal mode for attached dbs */
|
||||
signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */
|
||||
int nextPagesize; /* Pagesize after VACUUM if >0 */
|
||||
int nTable; /* Number of tables in the database */
|
||||
@ -617,7 +619,6 @@ struct sqlite3 {
|
||||
#ifdef SQLITE_SSE
|
||||
sqlite3_stmt *pFetch; /* Used by SSE to fetch stored statements */
|
||||
#endif
|
||||
u8 dfltLockMode; /* Default locking-mode for attached dbs */
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user