SQLite

Check-in [b123c165fd]
Login

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

Overview
Comment:Move the implementation of VACUUM into a separate source file. (CVS 901)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b123c165fd3d0a5a86ee8a7baa669105dafb481a
User & Date: drh 2003-04-06 20:52:32.000
Context
2003-04-06
21:08
Split the implementation of COPY, PRAGMA, and ATTACH into separate source code files. (CVS 902) (check-in: 73359037ea user: drh tags: trunk)
20:52
Move the implementation of VACUUM into a separate source file. (CVS 901) (check-in: b123c165fd user: drh tags: trunk)
20:44
Simplify the BTree interface by shortening names. Added two new methods for accessing the current filename and for changing the name of the database file. (CVS 900) (check-in: 185d8dc8d0 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to Makefile.in.
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# You should not have to change anything below this line
###############################################################################

# Object files for the SQLite library.
#
LIBOBJ = auth.lo btree.lo build.lo delete.lo expr.lo func.lo hash.lo insert.lo \
         main.lo opcodes.lo os.lo pager.lo parse.lo printf.lo random.lo \
         select.lo table.lo tokenize.lo update.lo util.lo vdbe.lo \
         where.lo trigger.lo

# All of the source code files.
#
SRC = \
  $(TOP)/src/auth.c \
  $(TOP)/src/btree.c \







|







60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# You should not have to change anything below this line
###############################################################################

# Object files for the SQLite library.
#
LIBOBJ = auth.lo btree.lo build.lo delete.lo expr.lo func.lo hash.lo insert.lo \
         main.lo opcodes.lo os.lo pager.lo parse.lo printf.lo random.lo \
         select.lo table.lo tokenize.lo update.lo util.lo vacuum.lo vdbe.lo \
         where.lo trigger.lo

# All of the source code files.
#
SRC = \
  $(TOP)/src/auth.c \
  $(TOP)/src/btree.c \
93
94
95
96
97
98
99

100
101
102
103
104
105
106
  $(TOP)/src/sqliteInt.h \
  $(TOP)/src/table.c \
  $(TOP)/src/tclsqlite.c \
  $(TOP)/src/tokenize.c \
  $(TOP)/src/trigger.c \
  $(TOP)/src/update.c \
  $(TOP)/src/util.c \

  $(TOP)/src/vdbe.c \
  $(TOP)/src/vdbe.h \
  $(TOP)/src/where.c

# Source code to the test files.
#
TESTSRC = \







>







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  $(TOP)/src/sqliteInt.h \
  $(TOP)/src/table.c \
  $(TOP)/src/tclsqlite.c \
  $(TOP)/src/tokenize.c \
  $(TOP)/src/trigger.c \
  $(TOP)/src/update.c \
  $(TOP)/src/util.c \
  $(TOP)/src/vacuum.c \
  $(TOP)/src/vdbe.c \
  $(TOP)/src/vdbe.h \
  $(TOP)/src/where.c

# Source code to the test files.
#
TESTSRC = \
266
267
268
269
270
271
272



273
274
275
276
277
278
279

trigger.lo:	$(TOP)/src/trigger.c $(HDR)
	$(LIBTOOL) $(TCC) -c $(TOP)/src/trigger.c

update.lo:	$(TOP)/src/update.c $(HDR)
	$(LIBTOOL) $(TCC) -c $(TOP)/src/update.c




tclsqlite.lo:	$(TOP)/src/tclsqlite.c $(HDR)
	$(LIBTOOL) $(TCC) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c

printf.lo:	$(TOP)/src/printf.c $(HDR)
	$(LIBTOOL) $(TCC) $(TCL_FLAGS) -c $(TOP)/src/printf.c

auth.lo:	$(TOP)/src/auth.c $(HDR)







>
>
>







267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283

trigger.lo:	$(TOP)/src/trigger.c $(HDR)
	$(LIBTOOL) $(TCC) -c $(TOP)/src/trigger.c

update.lo:	$(TOP)/src/update.c $(HDR)
	$(LIBTOOL) $(TCC) -c $(TOP)/src/update.c

vacuum.lo:	$(TOP)/src/vacuum.c $(HDR)
	$(LIBTOOL) $(TCC) -c $(TOP)/src/vacuum.c

tclsqlite.lo:	$(TOP)/src/tclsqlite.c $(HDR)
	$(LIBTOOL) $(TCC) $(TCL_FLAGS) -c $(TOP)/src/tclsqlite.c

printf.lo:	$(TOP)/src/printf.c $(HDR)
	$(LIBTOOL) $(TCC) $(TCL_FLAGS) -c $(TOP)/src/printf.c

auth.lo:	$(TOP)/src/auth.c $(HDR)
Changes to main.mk.
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src

# Object files for the SQLite library.
#
LIBOBJ = auth.o btree.o build.o delete.o expr.o func.o hash.o insert.o \
         main.o opcodes.o os.o pager.o parse.o printf.o random.o \
         select.o table.o tokenize.o trigger.o update.o util.o \
         vdbe.o where.o tclsqlite.o

# All of the source code files.
#
SRC = \
  $(TOP)/src/auth.c \
  $(TOP)/src/btree.c \
  $(TOP)/src/btree.h \







|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
TCCX = $(TCC) $(OPTS) $(THREADSAFE) $(USLEEP) -I. -I$(TOP)/src

# Object files for the SQLite library.
#
LIBOBJ = auth.o btree.o build.o delete.o expr.o func.o hash.o insert.o \
         main.o opcodes.o os.o pager.o parse.o printf.o random.o \
         select.o table.o tokenize.o trigger.o update.o util.o \
         vacuum.o vdbe.o where.o tclsqlite.o

# All of the source code files.
#
SRC = \
  $(TOP)/src/auth.c \
  $(TOP)/src/btree.c \
  $(TOP)/src/btree.h \
85
86
87
88
89
90
91

92
93
94
95
96
97
98
  $(TOP)/src/sqliteInt.h \
  $(TOP)/src/table.c \
  $(TOP)/src/tclsqlite.c \
  $(TOP)/src/tokenize.c \
  $(TOP)/src/trigger.c \
  $(TOP)/src/update.c \
  $(TOP)/src/util.c \

  $(TOP)/src/vdbe.c \
  $(TOP)/src/vdbe.h \
  $(TOP)/src/where.c

# Source code to the test files.
#
TESTSRC = \







>







85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  $(TOP)/src/sqliteInt.h \
  $(TOP)/src/table.c \
  $(TOP)/src/tclsqlite.c \
  $(TOP)/src/tokenize.c \
  $(TOP)/src/trigger.c \
  $(TOP)/src/update.c \
  $(TOP)/src/util.c \
  $(TOP)/src/vacuum.c \
  $(TOP)/src/vdbe.c \
  $(TOP)/src/vdbe.h \
  $(TOP)/src/where.c

# Source code to the test files.
#
TESTSRC = \
221
222
223
224
225
226
227



228
229
230
231
232
233
234
	$(TCCX) -c $(TOP)/src/tokenize.c

trigger.o:	$(TOP)/src/trigger.c $(HDR)
	$(TCCX) -c $(TOP)/src/trigger.c

util.o:	$(TOP)/src/util.c $(HDR)
	$(TCCX) -c $(TOP)/src/util.c




vdbe.o:	$(TOP)/src/vdbe.c $(HDR)
	$(TCCX) -c $(TOP)/src/vdbe.c

where.o:	$(TOP)/src/where.c $(HDR)
	$(TCCX) -c $(TOP)/src/where.c








>
>
>







222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
	$(TCCX) -c $(TOP)/src/tokenize.c

trigger.o:	$(TOP)/src/trigger.c $(HDR)
	$(TCCX) -c $(TOP)/src/trigger.c

util.o:	$(TOP)/src/util.c $(HDR)
	$(TCCX) -c $(TOP)/src/util.c

vacuum.o:	$(TOP)/src/vacuum.c $(HDR)
	$(TCCX) -c $(TOP)/src/vacuum.c

vdbe.o:	$(TOP)/src/vdbe.c $(HDR)
	$(TCCX) -c $(TOP)/src/vdbe.c

where.o:	$(TOP)/src/where.c $(HDR)
	$(TCCX) -c $(TOP)/src/where.c

Changes to src/build.c.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
**
**     CREATE TABLE
**     DROP TABLE
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     COPY
**     VACUUM
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**     PRAGMA
**
** $Id: build.c,v 1.141 2003/04/05 16:56:29 drh 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







<





|







15
16
17
18
19
20
21

22
23
24
25
26
27
28
29
30
31
32
33
34
**
**     CREATE TABLE
**     DROP TABLE
**     CREATE INDEX
**     DROP INDEX
**     creating ID lists
**     COPY

**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**     PRAGMA
**
** $Id: build.c,v 1.142 2003/04/06 20:52:32 drh 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
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
  
copy_cleanup:
  sqliteSrcListDelete(pTableName);
  sqliteFree(zFile);
  return;
}

/*
** The non-standard VACUUM command is used to clean up the database,
** collapse free space, etc.  It is modelled after the VACUUM command
** in PostgreSQL.
**
** In version 1.0.x of SQLite, the VACUUM command would call
** gdbm_reorganize() on all the database tables.  But beginning
** with 2.0.0, SQLite no longer uses GDBM so this command has
** become a no-op.
*/
void sqliteVacuum(Parse *pParse, Token *pTableName){
  /* Do nothing */
}

/*
** Begin a transaction
*/
void sqliteBeginTransaction(Parse *pParse, int onError){
  sqlite *db;

  if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;







<
<
<
<
<
<
<
<
<
<
<
<
<
<







2076
2077
2078
2079
2080
2081
2082














2083
2084
2085
2086
2087
2088
2089
  
copy_cleanup:
  sqliteSrcListDelete(pTableName);
  sqliteFree(zFile);
  return;
}















/*
** Begin a transaction
*/
void sqliteBeginTransaction(Parse *pParse, int onError){
  sqlite *db;

  if( pParse==0 || (db=pParse->db)==0 || db->aDb[0].pBt==0 ) return;
Changes to src/pager.c.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.80 2003/04/06 20:44:45 drh Exp $
*/
#include "os.h"         /* Must be first to enable large file support */
#include "sqliteInt.h"
#include "pager.h"
#include <assert.h>
#include <string.h>








|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
** The pager is used to access a database disk file.  It implements
** atomic commit and rollback through the use of a journal file that
** is separate from the database file.  The pager also implements file
** locking to prevent two processes from writing the same database
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.81 2003/04/06 20:52:32 drh Exp $
*/
#include "os.h"         /* Must be first to enable large file support */
#include "sqliteInt.h"
#include "pager.h"
#include <assert.h>
#include <string.h>

2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
    return SQLITE_NOMEM;
  }
  memcpy(zNew, zNewName, nName+1);
  zJournal = &zNew[nName+1];
  memcpy(zJournal, zNew, nName);
  strcpy(&zJournal[nName], "-journal");
  if( pPager->journalOpen ){
    rc = sqliteOsRename(pPager->zJournal, zJournal);
    if( rc ){
      sqliteFree(zNew);
      return rc;
    }
  }
  rc = sqliteOsRename(pPager->zFilename, zNew);
  if( rc ){
    sqliteFree(zNew);
    return rc;
  }
  if( pPager->zFilename!=(char*)&pPager[1] ){
    sqliteFree(pPager->zFilename);
  }







|





|







2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
    return SQLITE_NOMEM;
  }
  memcpy(zNew, zNewName, nName+1);
  zJournal = &zNew[nName+1];
  memcpy(zJournal, zNew, nName);
  strcpy(&zJournal[nName], "-journal");
  if( pPager->journalOpen ){
    rc = sqliteOsFileRename(pPager->zJournal, zJournal);
    if( rc ){
      sqliteFree(zNew);
      return rc;
    }
  }
  rc = sqliteOsFileRename(pPager->zFilename, zNew);
  if( rc ){
    sqliteFree(zNew);
    return rc;
  }
  if( pPager->zFilename!=(char*)&pPager[1] ){
    sqliteFree(pPager->zFilename);
  }