]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Partial fix for ticket #96: Return SQLITE_MISUSE from sqlite_exec() if called
authordrh <drh@noemail.net>
Sat, 13 Jul 2002 17:23:21 +0000 (17:23 +0000)
committerdrh <drh@noemail.net>
Sat, 13 Jul 2002 17:23:21 +0000 (17:23 +0000)
from a child process with an active transaction that was started in the parent. (CVS 675)

FossilOrigin-Name: 72a609ec6492e7d740b6e6184fa14a5e6b04a5dc

manifest
manifest.uuid
src/build.c
src/main.c
src/os.c
src/os.h
src/sqliteInt.h

index f698d130b3ad6f7a8b063b38c55aecac00e11dfa..a5690a59203ea1b6adc4d863965a031141493eff 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sfor\sticket\s#99:\s\sAdded\sdocumentation\son\sthe\ssqlite_mprintf()\sAPI.\s(CVS\s674)
-D 2002-07-13T17:18:37
+C Partial\sfix\sfor\sticket\s#96:\sReturn\sSQLITE_MISUSE\sfrom\ssqlite_exec()\sif\scalled\nfrom\sa\schild\sprocess\swith\san\sactive\stransaction\sthat\swas\sstarted\sin\sthe\sparent.\s(CVS\s675)
+D 2002-07-13T17:23:21
 F Makefile.in 6291a33b87d2a395aafd7646ee1ed562c6f2c28c
 F Makefile.template 4e11752e0b5c7a043ca50af4296ec562857ba495
 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@@ -20,7 +20,7 @@ F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
 F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
 F src/btree.c db8cd1bd46cd30a1763c3cc80602571d1b30a329
 F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
-F src/build.c 58ce73da93699bbbe676908678e1e44bad1853cb
+F src/build.c 81d0f42ae58af35d6331402e71a4fb2d2898586c
 F src/delete.c 215492ffcea4262a993e55f3c4a67dc9fea4da9c
 F src/encode.c 346b12b46148506c32038524b95c4631ab46d760
 F src/expr.c 4b25ee5e65f351d40dea8575b998605762556d76
@@ -28,10 +28,10 @@ F src/func.c e45cd908b9b723d9b91473d09e12c23f786b3fc2
 F src/hash.c 6a6236b89c8c060c65dabd300a1c8ce7c10edb72
 F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
 F src/insert.c 4511e06abce1688664ce90cbf09fa13433b82c43
-F src/main.c 6ac32ca71ab4728212c5b44aed25e26dc6cfe73c
+F src/main.c d9ff20d7412b20cb97c21a65e13c1c174653b50d
 F src/md5.c 0ae1f3e2cac92d06fc6246d1b4b8f61a2fe66d3b
-F src/os.c 6902568313e39f7c942b7ba8e316887a5b1aa40e
-F src/os.h 4a361fccfbc4e7609b3e1557f604f94c1e96ad10
+F src/os.c edb22daad525f49681f41c76683a16c1d39755c7
+F src/os.h 5b9a69875c880d1665ae040cbca1f7b9c82198ab
 F src/pager.c b8415b02a2a5c4e9d8bfd45311a5f15e785c7f1f
 F src/pager.h 6fddfddd3b73aa8abc081b973886320e3c614f0e
 F src/parse.y 9267b7681882205f904f6564fff733d8fbcd58a3
@@ -41,7 +41,7 @@ F src/select.c f4e7221a319da25f549a434a6c664eedcbce4dec
 F src/shell.c 16cb2db27f2d3045f78e74e83bac965a8249357b
 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
 F src/sqlite.h.in 75c5bbb066d0faf34424b7d1babf8b44d5b31af2
-F src/sqliteInt.h 943209263393dcbaf1e753b83a0f33258f090a5f
+F src/sqliteInt.h d18d098aa9121d2415a9c0d1d3e09a10dde39385
 F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
 F src/tclsqlite.c ba454c5166252a55cb4db8af4d29d2a18b6e6f3d
 F src/test1.c 456cb080db85056be723e770435d9509afc3a83a
@@ -141,7 +141,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P cff271837796d84471b09147c59cb7601d16b358
-R 63bf2a6bac15f02f44e75d7ed5641521
+P d918de5f06d187c76aab0879b728c89a7d4ae55a
+R 214fd6b9786115aa42764d5ad4da2283
 U drh
-Z a0fd29b0bbea80b4f97bf6c9c9b3443e
+Z c95a49a092cf8f04fa10039151e0a18e
index fd81c923fab9b0d011f79c3df07a744b6a72d33b..7bc5b82d20ab08060ceb7745a9905d86999b8221 100644 (file)
@@ -1 +1 @@
-d918de5f06d187c76aab0879b728c89a7d4ae55a
\ No newline at end of file
+72a609ec6492e7d740b6e6184fa14a5e6b04a5dc
\ No newline at end of file
index 71e6fd525104a135ff2254898288c591da515bf2..999acf33bfe340e0ae96659764022803115c77ba 100644 (file)
@@ -25,7 +25,7 @@
 **     ROLLBACK
 **     PRAGMA
 **
-** $Id: build.c,v 1.104 2002/07/13 03:11:53 drh Exp $
+** $Id: build.c,v 1.105 2002/07/13 17:23:21 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -1730,6 +1730,7 @@ void sqliteBeginTransaction(Parse *pParse, int onError){
   if( db->flags & SQLITE_InTrans ) return;
   sqliteBeginWriteOperation(pParse, 0);
   db->flags |= SQLITE_InTrans;
+  db->pid = sqliteOsProcessId();
   db->onError = onError;
 }
 
index ee79bfdb9b22319ace6aba884180194373123420..28b98d9cc430362bf834201df1d5b9174bc61db9 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.85 2002/06/25 19:31:18 drh Exp $
+** $Id: main.c,v 1.86 2002/07/13 17:23:21 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -491,6 +491,9 @@ int sqlite_exec(
 
   if( pzErrMsg ) *pzErrMsg = 0;
   if( sqliteSafetyOn(db) ) goto exec_misuse;
+  if( (db->flags & SQLITE_InTrans)!=0 && db->pid!=sqliteOsProcessId() ){
+    goto exec_misuse;
+  }
   if( (db->flags & SQLITE_Initialized)==0 ){
     int rc = sqliteInit(db, pzErrMsg);
     if( rc!=SQLITE_OK ){
index 76d0894a194f44f1f9db078a72b8739619a33478..2d157f91e75ed2fb24f78f973f5ed9c8a35af49f 100644 (file)
--- a/src/os.c
+++ b/src/os.c
@@ -579,6 +579,19 @@ int sqliteOsFileSize(OsFile *id, int *pSize){
 #endif
 }
 
+/*
+** Return the process ID for the current process.  This
+** only works under Unix.  Under windows, a constant is returned.
+*/
+int sqliteOsProcessId(void){
+#if OS_UNIX
+  return getpid();
+#endif
+#if OS_WIN
+  return 1;
+#endif
+}
+
 
 /*
 ** Change the status of the lock on the file "id" to be a readlock.
index e1d0d865145f83250e5a796c0191043fd58ba5e4..68b9b6b25746d89a2a58e4674726bc360045348c 100644 (file)
--- a/src/os.h
+++ b/src/os.h
@@ -82,6 +82,7 @@ int sqliteOsWriteLock(OsFile*);
 int sqliteOsUnlock(OsFile*);
 int sqliteOsRandomSeed(char*);
 int sqliteOsSleep(int ms);
+int sqliteOsProcessId(void);
 void sqliteOsEnterMutex(void);
 void sqliteOsLeaveMutex(void);
 
index 0a84378db4782492c5446a1714ffa3960579a481..16b271ef38633fed7f6895802d592a18bf65793d 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.137 2002/07/13 03:11:54 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.138 2002/07/13 17:23:21 drh Exp $
 */
 #include "sqlite.h"
 #include "hash.h"
@@ -199,6 +199,7 @@ struct sqlite {
   int next_cookie;              /* Value of schema_cookie after commit */
   int cache_size;               /* Number of pages to use in the cache */
   int nTable;                   /* Number of tables in the database */
+  int pid;                      /* Process ID that started the transaction */
   void *pBusyArg;               /* 1st Argument to the busy callback */
   int (*xBusyCallback)(void *,const char*,int);  /* The busy callback */
   Hash tblHash;                 /* All tables indexed by name */