Modifications and bugfixes so that the test suite passes with the TCL statement cache turned on. (CVS 2271)

FossilOrigin-Name: d5233e0747789dea04d35a8350b408321d23a64d
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index 348925a..ca16128 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -163,6 +163,12 @@
   if( p->aborted ){
     return SQLITE_ABORT;
   }
+  if( p->pc<=0 && p->expired ){
+    if( p->rc==SQLITE_OK ){
+      p->rc = SQLITE_SCHEMA;
+    }
+    return SQLITE_ERROR;
+  }
   db = p->db;
   if( sqlite3SafetyOn(db) ){
     p->rc = SQLITE_MISUSE;