SQLite

Check-in [a57ecd606c]
Login

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

Overview
Comment::-) (CVS 35)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a57ecd606c8caa67db240d1a4bc46c0a590fde0c
User & Date: drh 2000-06-02 01:36:16.000
Context
2000-06-02
01:51
:-) (CVS 36) (check-in: d3c31defba user: drh tags: trunk)
01:36
:-) (CVS 35) (check-in: a57ecd606c user: drh tags: trunk)
01:17
:-) (CVS 34) (check-in: 52338f4ab5 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/dbbe.c.
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
** sqlite and the code that does the actually reading and writing
** of information to the disk.
**
** This file uses GDBM as the database backend.  It should be
** relatively simple to convert to a different database such
** as NDBM, SDBM, or BerkeleyDB.
**
** $Id: dbbe.c,v 1.7 2000/06/02 01:17:37 drh Exp $
*/
#include "sqliteInt.h"
#include <gdbm.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>







|







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
** sqlite and the code that does the actually reading and writing
** of information to the disk.
**
** This file uses GDBM as the database backend.  It should be
** relatively simple to convert to a different database such
** as NDBM, SDBM, or BerkeleyDB.
**
** $Id: dbbe.c,v 1.8 2000/06/02 01:36:16 drh Exp $
*/
#include "sqliteInt.h"
#include <gdbm.h>
#include <sys/stat.h>
#include <unistd.h>
#include <ctype.h>
#include <time.h>
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
      mode = 0640;
    }
    pFile = sqliteMalloc( sizeof(*pFile) );
    if( pFile==0 ){
      sqliteFree(zFile);
      return SQLITE_NOMEM;
    }
    if( pFile->zName ){
      pFile->dbf = gdbm_open(pFile->zName, 0, rw_mask, mode, 0);
    }else{
      int limit;
      struct rc4 *pRc4;
      char zRandom[50];
      pRc4 = &pBe->rc4;
      zFile = 0;
      limit = 5;







|
|







266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
      mode = 0640;
    }
    pFile = sqliteMalloc( sizeof(*pFile) );
    if( pFile==0 ){
      sqliteFree(zFile);
      return SQLITE_NOMEM;
    }
    if( zFile ){
      pFile->dbf = gdbm_open(zFile, 0, rw_mask, mode, 0);
    }else{
      int limit;
      struct rc4 *pRc4;
      char zRandom[50];
      pRc4 = &pBe->rc4;
      zFile = 0;
      limit = 5;
Changes to src/main.c.
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.3 2000/06/02 01:17:37 drh Exp $
*/
#include "sqliteInt.h"

/*
** This is the callback routine for the code that initializes the
** database.  Each callback contains text of a CREATE TABLE or
** CREATE INDEX statement that must be parsed to yield the internal







|







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
**
*************************************************************************
** Main file for the SQLite library.  The routines in this file
** implement the programmer interface to the library.  Routines in
** other files are for internal use by SQLite and should not be
** accessed by users of the library.
**
** $Id: main.c,v 1.4 2000/06/02 01:36:16 drh Exp $
*/
#include "sqliteInt.h"

/*
** This is the callback routine for the code that initializes the
** database.  Each callback contains text of a CREATE TABLE or
** CREATE INDEX statement that must be parsed to yield the internal
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  ** The following program invokes its callback on the SQL for each
  ** table then goes back and invokes the callback on the
  ** SQL for each index.  The callback will invoke the
  ** parser to build the internal representation of the
  ** database scheme.
  */
  static VdbeOp initProg[] = {
    { OP_Open,     0, 0,  MASTER_NAME},
    { OP_Next,     0, 8,  0},           /* 1 */
    { OP_Field,    0, 0,  0},
    { OP_String,   0, 0,  "table"},
    { OP_Ne,       0, 1,  0},
    { OP_Field,    0, 3,  0},
    { OP_Callback, 1, 0,  0},
    { OP_Goto,     0, 1,  0},







|







96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
  ** The following program invokes its callback on the SQL for each
  ** table then goes back and invokes the callback on the
  ** SQL for each index.  The callback will invoke the
  ** parser to build the internal representation of the
  ** database scheme.
  */
  static VdbeOp initProg[] = {
    { OP_Open,     0, 1,  MASTER_NAME},
    { OP_Next,     0, 8,  0},           /* 1 */
    { OP_Field,    0, 0,  0},
    { OP_String,   0, 0,  "table"},
    { OP_Ne,       0, 1,  0},
    { OP_Field,    0, 3,  0},
    { OP_Callback, 1, 0,  0},
    { OP_Goto,     0, 1,  0},
Changes to src/vdbe.c.
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
** inplicit conversion from one type to the other occurs as necessary.
** 
** Most of the code in this file is taken up by the sqliteVdbeExec()
** function which does the work of interpreting a VDBE program.
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
** $Id: vdbe.c,v 1.7 2000/06/02 01:17:38 drh Exp $
*/
#include "sqliteInt.h"

/*
** SQL is translated into a sequence of instructions to be
** executed by a virtual machine.  Each instruction is an instance
** of the following structure.







|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
** inplicit conversion from one type to the other occurs as necessary.
** 
** Most of the code in this file is taken up by the sqliteVdbeExec()
** function which does the work of interpreting a VDBE program.
** But other routines are also provided to help in building up
** a program instruction by instruction.
**
** $Id: vdbe.c,v 1.8 2000/06/02 01:36:16 drh Exp $
*/
#include "sqliteInt.h"

/*
** SQL is translated into a sequence of instructions to be
** executed by a virtual machine.  Each instruction is an instance
** of the following structure.
1319
1320
1321
1322
1323
1324
1325














1326
1327
1328
1329
1330
1331
1332
          if( p->aTab==0 ){ p->nTable = 0; goto no_mem; }
          for(j=p->nTable; j<=i; j++) p->aTab[j].pTable = 0;
          p->nTable = i+1;
        }else if( p->aTab[i].pTable ){
          sqliteDbbeCloseTable(p->aTab[i].pTable);
        }
        rc = sqliteDbbeOpenTable(p->pBe, pOp->p3, pOp->p2, &p->aTab[i].pTable);














        p->aTab[i].index = 0;
        break;
      }

      /* Opcode: Close P1 * *
      **
      ** Close a database table previously opened as P1.  If P1 is not







>
>
>
>
>
>
>
>
>
>
>
>
>
>







1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
          if( p->aTab==0 ){ p->nTable = 0; goto no_mem; }
          for(j=p->nTable; j<=i; j++) p->aTab[j].pTable = 0;
          p->nTable = i+1;
        }else if( p->aTab[i].pTable ){
          sqliteDbbeCloseTable(p->aTab[i].pTable);
        }
        rc = sqliteDbbeOpenTable(p->pBe, pOp->p3, pOp->p2, &p->aTab[i].pTable);
        switch( rc ){
          case SQLITE_BUSY: {
            sqliteSetString(pzErrMsg,"table ", pOp->p3, " is locked", 0);
            break;
          }
          case SQLITE_READONLY: {
            sqliteSetString(pzErrMsg,"table ", pOp->p3, 
               " is already opened for reading", 0);
            break;
          }
          case SQLITE_NOMEM: {
            goto no_mem;
          }
        }
        p->aTab[i].index = 0;
        break;
      }

      /* Opcode: Close P1 * *
      **
      ** Close a database table previously opened as P1.  If P1 is not
1710
1711
1712
1713
1714
1715
1716



1717
1718
1719
1720
1721
1722
1723
          if( p->apList==0 ){ p->nList = 0; goto no_mem; }
          for(j=p->nList; j<=i; j++) p->apList[j] = 0;
          p->nList = i+1;
        }else if( p->apList[i] ){
          sqliteDbbeCloseTempFile(p->pBe, p->apList[i]);
        }
        rc = sqliteDbbeOpenTempFile(p->pBe, &p->apList[i]);



        break;
      }

      /* Opcode: ListWrite P1 * *
      **
      ** Write the integer on the top of the stack
      ** into the temporary storage file P1.







>
>
>







1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
          if( p->apList==0 ){ p->nList = 0; goto no_mem; }
          for(j=p->nList; j<=i; j++) p->apList[j] = 0;
          p->nList = i+1;
        }else if( p->apList[i] ){
          sqliteDbbeCloseTempFile(p->pBe, p->apList[i]);
        }
        rc = sqliteDbbeOpenTempFile(p->pBe, &p->apList[i]);
        if( rc!=SQLITE_OK ){
          sqliteSetString(pzErrMsg, "unable to open a temporary file", 0);
        }
        break;
      }

      /* Opcode: ListWrite P1 * *
      **
      ** Write the integer on the top of the stack
      ** into the temporary storage file P1.
2220
2221
2222
2223
2224
2225
2226
2227
2228
  /* Jump here if an illegal or illformed instruction is executed.
  */
bad_instruction:
  sprintf(zBuf,"%d",pc);
  sqliteSetString(pzErrMsg, "illegal operation at ", zBuf, 0);
  rc = SQLITE_INTERNAL;
  goto cleanup;

}







|
<
2237
2238
2239
2240
2241
2242
2243
2244

  /* Jump here if an illegal or illformed instruction is executed.
  */
bad_instruction:
  sprintf(zBuf,"%d",pc);
  sqliteSetString(pzErrMsg, "illegal operation at ", zBuf, 0);
  rc = SQLITE_INTERNAL;
  goto cleanup;
}