#pragma ident "%Z%%M% %I% %E% SMI"
/*
** 2003 April 6
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to implement the VACUUM command.
**
** Most of the code in this file may be omitted by defining the
** SQLITE_OMIT_VACUUM macro.
**
** $Id: vacuum.c,v 1.13.2.2 2004/06/04 19:07:54 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
/*
** A structure for holding a dynamic string - a string that can grow
** without bound.
*/
struct dynStr {
char *z; /* Text of the string in space obtained from sqliteMalloc() */
};
/*
** A structure that holds the vacuum context
*/
struct vacuumStruct {
};
#if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM
/*
** Append text to a dynamic string
*/
char *zNew;
if( zNew==0 ){
sqliteFree(p->z);
memset(p, 0, sizeof(*p));
return;
}
p->z = zNew;
}
}
/*
** Append text to a dynamic string, having first put the text in quotes.
*/
int i, j;
for(i=j=0; zText[i]; i++){
if( zText[i]=='\'' ){
j = i + 1;
}
}
if( j<i ){
appendText(p, &zText[j], i-j);
}
}
/*
** Execute statements of SQL. If an error occurs, write the error
** message into *pzErrMsg and return non-zero.
*/
char *zErrMsg = 0;
int rc;
/* printf("***** executing *****\n%s\n", zSql); */
if( zErrMsg ){
}
return rc;
}
/*
** This is the second stage callback. Each invocation contains all the
** data for a single row of a single table in the original database. This
** routine must write that information into the new database.
*/
int i;
if( argv==0 ) return 0;
for(i=0; i<argc; i++){
zSep = ",";
if( argv[i]==0 ){
}else{
}
}
return p->rc;
}
/*
** This is the first stage callback. Each invocation contains three
** arguments where are taken from the SQLITE_MASTER table of the original
** database: (1) the entry type, (2) the entry name, and (3) the SQL for
** the entry. In all cases, execute the SQL of the third argument.
** For tables, run a query to select all entries in that table and
** transfer them to the second-stage callback.
*/
int rc = 0;
if( argv==0 ) return 0;
char *zErrMsg = 0;
if( zErrMsg ){
}
}
return rc;
}
/*
** This callback is used to transfer PRAGMA settings from one database
** to the other. The value in argv[0] should be passed to a pragma
** identified by ((vacuumStruct*)pArg)->zPragma.
*/
if( argv==0 ) return 0;
return p->rc;
}
/*
** Generate a random name of 20 character in length.
*/
static const unsigned char zChars[] =
"abcdefghijklmnopqrstuvwxyz"
"0123456789";
int i;
for(i=0; i<20; i++){
}
}
#endif
/*
** 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.
*/
sqliteVdbeAddOp(v, OP_Vacuum, 0, 0);
return;
}
/*
** This routine implements the OP_Vacuum opcode of the VDBE.
*/
#if !defined(SQLITE_OMIT_VACUUM) || SQLITE_OMIT_VACUUM
int i; /* Loop counter */
/* These are all of the pragmas that need to be transferred over
** to the new database */
static const char *zPragma[] = {
"default_synchronous",
"default_cache_size",
/* "default_temp_store", */
};
(char*)0);
return SQLITE_ERROR;
}
return SQLITE_INTERRUPT;
}
/* Get the full pathname of the database file and create two
** temporary filenames in the same directory as the original file.
*/
if( zFilename==0 ){
/* This only happens with the in-memory database. VACUUM is a no-op
** there, so just return */
return SQLITE_OK;
}
if( zTemp==0 ) return SQLITE_NOMEM;
for(i=0; i<10; i++){
if( !sqliteOsFileExists(zTemp) ) break;
}
if( i>=10 ){
"in the same directory as the original database", (char*)0);
goto end_of_vacuum;
}
if( dbNew==0 ){
goto end_of_vacuum;
}
goto end_of_vacuum;
}
}
"SELECT type, name, sql FROM sqlite_master "
"WHERE sql NOT NULL AND type!='view' "
"UNION ALL "
"SELECT type, name, sql FROM sqlite_master "
"WHERE sql NOT NULL AND type=='view'",
}
}
zErrMsg, (char*)0);
}
}
#endif
}