Remove global variables when compiled with SQLITE_OMIT_WSD
FossilOrigin-Name: dd10a547f10364058025c48b28d8fd240bf46aff
diff --git a/src/global.c b/src/global.c
index 673a274..d2dbe4a 100644
--- a/src/global.c
+++ b/src/global.c
@@ -194,7 +194,9 @@
** Changing the pending byte during operating results in undefined
** and dileterious behavior.
*/
+#ifndef SQLITE_OMIT_WSD
int sqlite3PendingByte = 0x40000000;
+#endif
#include "opcodes.h"
/*
diff --git a/src/main.c b/src/main.c
index 7261401..5b715a1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2381,9 +2381,13 @@
** dileterious behavior.
*/
case SQLITE_TESTCTRL_PENDING_BYTE: {
- unsigned int newVal = va_arg(ap, unsigned int);
- rc = sqlite3PendingByte;
- if( newVal ) sqlite3PendingByte = newVal;
+ rc = PENDING_BYTE;
+#ifndef SQLITE_OMIT_WSD
+ {
+ unsigned int newVal = va_arg(ap, unsigned int);
+ if( newVal ) sqlite3PendingByte = newVal;
+ }
+#endif
break;
}
diff --git a/src/memjournal.c b/src/memjournal.c
index f042475..048304b 100644
--- a/src/memjournal.c
+++ b/src/memjournal.c
@@ -213,7 +213,7 @@
/*
** Table of methods for MemJournal sqlite3_file object.
*/
-static struct sqlite3_io_methods MemJournalMethods = {
+static const struct sqlite3_io_methods MemJournalMethods = {
1, /* iVersion */
memjrnlClose, /* xClose */
memjrnlRead, /* xRead */
@@ -236,7 +236,7 @@
MemJournal *p = (MemJournal *)pJfd;
assert( EIGHT_BYTE_ALIGNMENT(p) );
memset(p, 0, sqlite3MemJournalSize());
- p->pMethod = &MemJournalMethods;
+ p->pMethod = (sqlite3_io_methods*)&MemJournalMethods;
}
/*
diff --git a/src/os.h b/src/os.h
index 670ee43..0017327 100644
--- a/src/os.h
+++ b/src/os.h
@@ -217,7 +217,11 @@
** 1GB boundary.
**
*/
-#define PENDING_BYTE sqlite3PendingByte
+#ifdef SQLITE_OMIT_WSD
+# define PENDING_BYTE (0x40000000)
+#else
+# define PENDING_BYTE sqlite3PendingByte
+#endif
#define RESERVED_BYTE (PENDING_BYTE+1)
#define SHARED_FIRST (PENDING_BYTE+2)
#define SHARED_SIZE 510
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index eed2b10..851cb27 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -2886,8 +2886,10 @@
extern const unsigned char sqlite3CtypeMap[];
extern SQLITE_WSD struct Sqlite3Config sqlite3Config;
extern SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
+#ifndef SQLITE_OMIT_WSD
extern int sqlite3PendingByte;
#endif
+#endif
void sqlite3RootPageMoved(Db*, int, int);
void sqlite3Reindex(Parse*, Token*, Token*);
void sqlite3AlterFunctions(void);
diff --git a/src/test2.c b/src/test2.c
index 994bc1a..520ad73 100644
--- a/src/test2.c
+++ b/src/test2.c
@@ -675,7 +675,9 @@
(char*)&sqlite3_diskfull_pending, TCL_LINK_INT);
Tcl_LinkVar(interp, "sqlite_diskfull",
(char*)&sqlite3_diskfull, TCL_LINK_INT);
+#ifndef SQLITE_OMIT_WSD
Tcl_LinkVar(interp, "sqlite_pending_byte",
(char*)&sqlite3PendingByte, TCL_LINK_INT | TCL_LINK_READ_ONLY);
+#endif
return TCL_OK;
}
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index 01d4241..45320af 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -814,9 +814,12 @@
**
** If a memory allocation error has occurred prior to the calling of this
** routine, then a pointer to a dummy VdbeOp will be returned. That opcode
-** is readable and writable, but it has no effect. The return of a dummy
-** opcode allows the call to continue functioning after a OOM fault without
-** having to check to see if the return from this routine is a valid pointer.
+** is readable but not writable, though it is cast to a writable value.
+** The return of a dummy opcode allows the call to continue functioning
+** after a OOM fault without having to check to see if the return from
+** this routine is a valid pointer. But because the dummy.opcode is 0,
+** dummy will never be written to. This is verified by code inspection and
+** by running with Valgrind.
**
** About the #ifdef SQLITE_OMIT_TRACE: Normally, this routine is never called
** unless p->nOp>0. This is because in the absense of SQLITE_OMIT_TRACE,
@@ -827,17 +830,17 @@
** check the value of p->nOp-1 before continuing.
*/
VdbeOp *sqlite3VdbeGetOp(Vdbe *p, int addr){
- static VdbeOp dummy;
+ static const VdbeOp dummy;
assert( p->magic==VDBE_MAGIC_INIT );
if( addr<0 ){
#ifdef SQLITE_OMIT_TRACE
- if( p->nOp==0 ) return &dummy;
+ if( p->nOp==0 ) return (VdbeOp*)&dummy;
#endif
addr = p->nOp - 1;
}
assert( (addr>=0 && addr<p->nOp) || p->db->mallocFailed );
if( p->db->mallocFailed ){
- return &dummy;
+ return (VdbeOp*)&dummy;
}else{
return &p->aOp[addr];
}