SQLite

Check-in [b8f2ba7880]
Login

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

Overview
Comment:Begin the process over converting sqlite_exec() over to use sqlite_compile() and sqlite_step(). The new sqlite_exec() is still commented out. (CVS 1237)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b8f2ba7880b761e380b95ae63d8ab721f018443e
User & Date: drh 2004-02-13 16:30:10.000
Context
2004-02-13
20:09
Fix an uninitialized variable in shell.c that would cause a crash if you specified SQL on the command-line. (CVS 1238) (check-in: 5a56090dde user: drh tags: trunk)
16:30
Begin the process over converting sqlite_exec() over to use sqlite_compile() and sqlite_step(). The new sqlite_exec() is still commented out. (CVS 1237) (check-in: b8f2ba7880 user: drh tags: trunk)
16:22
Fix a bug in the query flattener when trying to find the datatype of the rowid of a view. Also fix a problem with sqlite_compile() and authorization failures. (CVS 1236) (check-in: aa0490ccd4 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/main.c.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** 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.150 2004/02/12 19:01:05 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** A pointer to this structure is used to communicate information







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
**
*************************************************************************
** 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.151 2004/02/13 16:30:10 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** A pointer to this structure is used to communicate information
677
678
679
680
681
682
683

684




685















































686
687
688
689
690
691
692
int sqlite_exec(
  sqlite *db,                 /* The database on which the SQL executes */
  const char *zSql,           /* The SQL to be executed */
  sqlite_callback xCallback,  /* Invoke this callback routine */
  void *pArg,                 /* First argument to xCallback() */
  char **pzErrMsg             /* Write error messages here */
){

  return sqliteMain(db, zSql, xCallback, pArg, 0, 0, pzErrMsg);




}
















































/*
** Compile a single statement of SQL into a virtual machine.  Return one
** of the SQLITE_ success/failure codes.  Also write an error message into
** memory obtained from malloc() and make *pzErrMsg point to that message.
*/
int sqlite_compile(







>

>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
int sqlite_exec(
  sqlite *db,                 /* The database on which the SQL executes */
  const char *zSql,           /* The SQL to be executed */
  sqlite_callback xCallback,  /* Invoke this callback routine */
  void *pArg,                 /* First argument to xCallback() */
  char **pzErrMsg             /* Write error messages here */
){
#if 1
  return sqliteMain(db, zSql, xCallback, pArg, 0, 0, pzErrMsg);
#else
  int rc;
  const char *zLeftover;
  sqlite_vm *pVm;

  if( zSql==0 ) return SQLITE_OK;
  while( zSql[0] ){
    int nBusy = 0;
    rc = sqlite_compile(db, zSql, &zLeftover, &pVm, pzErrMsg);
    if( rc!=SQLITE_OK ){
      /* sqlite_finalize(pVm, 0); */
      return rc;
    }
    while(1){
      int nArg;
      char **azArg, **azCol;
      rc = sqlite_step(pVm, &nArg, &azArg, &azCol);
      if( rc==SQLITE_ROW ){
        if( xCallback(pArg, nArg, azArg, azCol) ){
          sqlite_finalize(pVm, 0);
          return SQLITE_ABORT;
        }
#if 0
      }else if( rc==SQLITE_BUSY ){
        if( db->xBusyCallback==0
              || db->xBusyCallback(db->pBusyArg, "", nBusy++)==0 ){
          sqlite_finalize(pVm, 0);
          return SQLITE_BUSY;
        }
#endif
      }else if( rc==SQLITE_SCHEMA ){
        sqlite_finalize(pVm, 0);
        break;
      }else{
        rc = sqlite_finalize(pVm, pzErrMsg);
        if( rc==SQLITE_SCHEMA ){
          sqliteResetInternalSchema(db, 0);
          /* break; */
        }
        if( rc!=SQLITE_OK ){
          return rc;
        }
        zSql = zLeftover;
        while( isspace(zSql[0]) ) zSql++;
        break;
      }
    }
  }
  return SQLITE_OK;
#endif
}


/*
** Compile a single statement of SQL into a virtual machine.  Return one
** of the SQLITE_ success/failure codes.  Also write an error message into
** memory obtained from malloc() and make *pzErrMsg point to that message.
*/
int sqlite_compile(