]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add file legacy.c with old APIs. (CVS 1456)
authordanielk1977 <danielk1977@noemail.net>
Wed, 26 May 2004 00:01:35 +0000 (00:01 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Wed, 26 May 2004 00:01:35 +0000 (00:01 +0000)
FossilOrigin-Name: ae18fcb7ad91096f8029605b54d71ec225f31f32

manifest
manifest.uuid
src/legacy.c [new file with mode: 0644]

index 487c0722365a6464b7f95f9d39f5ddf811c27bbf..203ca8b54b743207510495f245e3e75fa84cb839 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Move\sthe\ssqlite3_exec()\sfunction\sto\slegacy.c.\s(CVS\s1455)
-D 2004-05-25T23:35:18
+C Add\sfile\slegacy.c\swith\sold\sAPIs.\s(CVS\s1456)
+D 2004-05-26T00:01:35
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -36,6 +36,7 @@ F src/func.c e67a36ae28ee3495d02261f74989a7bb192658fd
 F src/hash.c 440c2f8cb373ee1b4e13a0988489c7cd95d55b6f
 F src/hash.h 762d95f1e567664d1eafc1687de755626be962fb
 F src/insert.c 48bb15bff280767684a0f9ee4ae5973c9504f880
+F src/legacy.c 706484c32e86b95d65aeb31f661c0e4a3649b862
 F src/main.c 843361d68f275bc9dd3494897a105b34ad80e019
 F src/md5.c 32ec4d879e9b34d6a597ae8bda684d8e395003f4
 F src/os.h ab42f4a7c4c716f26b988e759b6e12085a3bfc67
@@ -202,7 +203,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 8f6b20c2938ded7ab9e400494c02370ecf7e9311
-R d7e2aba31e181ad39960b2f1be066f14
+P 9385ad5ca82c82d9ef699102ca0b53661d02a052
+R c7261e32f74427f74b17e0e0b0e6d6f2
 U danielk1977
-Z 651dbe0e74604e5a9ec8c254d6d50b80
+Z db7575fd9fa9fef8fcd2c82fe508a21b
index 3d04ac80cc89141831abfaf1c7a2796785572103..dc1558935e53cb07a6997551fdb48a0d5b748b38 100644 (file)
@@ -1 +1 @@
-9385ad5ca82c82d9ef699102ca0b53661d02a052
\ No newline at end of file
+ae18fcb7ad91096f8029605b54d71ec225f31f32
\ No newline at end of file
diff --git a/src/legacy.c b/src/legacy.c
new file mode 100644 (file)
index 0000000..58ab6e8
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+** 2001 September 15
+**
+** 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.
+**
+*************************************************************************
+** 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: legacy.c,v 1.1 2004/05/26 00:01:35 danielk1977 Exp $
+*/
+
+#include "sqliteInt.h"
+#include "os.h"
+#include <ctype.h>
+
+/*
+** Execute SQL code.  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.
+**
+** If the SQL is a query, then for each row in the query result
+** the xCallback() function is called.  pArg becomes the first
+** argument to xCallback().  If xCallback=NULL then no callback
+** is invoked, even for queries.
+*/
+int sqlite3_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 */
+){
+  int rc = SQLITE_OK;
+  const char *zLeftover;
+  sqlite3_stmt *pStmt = 0;
+  char **azCols = 0;
+
+  int nRetry = 0;
+  int nChange = 0;
+  int nCallback;
+
+  if( zSql==0 ) return SQLITE_OK;
+  while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && zSql[0] ){
+    int nCol;
+    char **azVals = 0;
+
+    pStmt = 0;
+    rc = sqlite3_prepare(db, zSql, -1, &pStmt, &zLeftover);
+    if( rc!=SQLITE_OK ){
+      if( pStmt ) sqlite3_finalize_new(pStmt);
+      continue;
+    }
+    if( !pStmt ){
+      /* this happens for a comment or white-space */
+      zSql = zLeftover;
+      continue;
+    }
+
+    db->nChange += nChange;
+    nCallback = 0;
+
+    nCol = sqlite3_column_count(pStmt);
+    azCols = sqliteMalloc(2*nCol*sizeof(const char *));
+    if( nCol && !azCols ){
+      rc = SQLITE_NOMEM;
+      goto exec_out;
+    }
+
+    while( 1 ){
+      int i;
+      rc = sqlite3_step(pStmt);
+
+      /* Invoke the callback function if required */
+      if( xCallback && (SQLITE_ROW==rc || 
+          (SQLITE_DONE==rc && !nCallback && db->flags&SQLITE_NullCallback)) ){
+        if( 0==nCallback ){
+          for(i=0; i<nCol; i++){
+            azCols[i] = (char *)sqlite3_column_name(pStmt, i);
+          }
+          nCallback++;
+        }
+        if( rc==SQLITE_ROW ){
+          azVals = &azCols[nCol];
+          for(i=0; i<nCol; i++){
+            azVals[i] = (char *)sqlite3_column_data(pStmt, i);
+          }
+        }
+        if( xCallback(pArg, nCol, azVals, azCols) ){
+          rc = SQLITE_ABORT;
+          goto exec_out;
+        }
+      }
+
+      if( rc!=SQLITE_ROW ){
+        rc = sqlite3_finalize_new(pStmt);
+        pStmt = 0;
+        if( db->pVdbe==0 ){
+          nChange = db->nChange;
+        }
+        if( rc!=SQLITE_SCHEMA ){
+          nRetry = 0;
+          zSql = zLeftover;
+          while( isspace(zSql[0]) ) zSql++;
+        }
+        break;
+      }
+    }
+
+    sqliteFree(azCols);
+    azCols = 0;
+  }
+
+exec_out:
+  if( pStmt ) sqlite3_finalize_new(pStmt);
+  if( azCols ) sqliteFree(azCols);
+
+  if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){
+    *pzErrMsg = malloc(1+strlen(sqlite3_errmsg(db)));
+    if( *pzErrMsg ){
+      strcpy(*pzErrMsg, sqlite3_errmsg(db));
+    }
+  }else if( pzErrMsg ){
+    *pzErrMsg = 0;
+  }
+
+  return rc;
+}
+
+