diff options
Diffstat (limited to 'ext/pdo_sqlite/sqlite/src/vdbeapi.c')
-rw-r--r-- | ext/pdo_sqlite/sqlite/src/vdbeapi.c | 62 |
1 files changed, 49 insertions, 13 deletions
diff --git a/ext/pdo_sqlite/sqlite/src/vdbeapi.c b/ext/pdo_sqlite/sqlite/src/vdbeapi.c index f6047f6fbe..ca1612875a 100644 --- a/ext/pdo_sqlite/sqlite/src/vdbeapi.c +++ b/ext/pdo_sqlite/sqlite/src/vdbeapi.c @@ -16,6 +16,21 @@ #include "sqliteInt.h" #include "vdbeInt.h" +/* +** Return TRUE (non-zero) of the statement supplied as an argument needs +** to be recompiled. A statement needs to be recompiled whenever the +** execution environment changes in a way that would alter the program +** that sqlite3_prepare() generates. For example, if new functions or +** collating sequences are registered or if an authorizer function is +** added or changed. +** +***** EXPERIMENTAL ****** +*/ +int sqlite3_expired(sqlite3_stmt *pStmt){ + Vdbe *p = (Vdbe*)pStmt; + return p==0 || p->expired; +} + /**************************** sqlite3_value_ ******************************* ** The following routines extract information from a Mem or sqlite3_value ** structure. @@ -46,6 +61,7 @@ sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){ const unsigned char *sqlite3_value_text(sqlite3_value *pVal){ return (const char *)sqlite3ValueText(pVal, SQLITE_UTF8); } +#ifndef SQLITE_OMIT_UTF16 const void *sqlite3_value_text16(sqlite3_value* pVal){ return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE); } @@ -55,6 +71,7 @@ const void *sqlite3_value_text16be(sqlite3_value *pVal){ const void *sqlite3_value_text16le(sqlite3_value *pVal){ return sqlite3ValueText(pVal, SQLITE_UTF16LE); } +#endif /* SQLITE_OMIT_UTF16 */ int sqlite3_value_type(sqlite3_value* pVal){ return pVal->type; } @@ -100,6 +117,7 @@ void sqlite3_result_text( ){ sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, xDel); } +#ifndef SQLITE_OMIT_UTF16 void sqlite3_result_text16( sqlite3_context *pCtx, const void *z, @@ -124,6 +142,7 @@ void sqlite3_result_text16le( ){ sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF16LE, xDel); } +#endif /* SQLITE_OMIT_UTF16 */ void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){ sqlite3VdbeMemCopy(&pCtx->s, pValue); } @@ -144,6 +163,12 @@ int sqlite3_step(sqlite3_stmt *pStmt){ 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; @@ -177,9 +202,12 @@ int sqlite3_step(sqlite3_stmt *pStmt){ db->activeVdbeCnt++; p->pc = 0; } +#ifndef SQLITE_OMIT_EXPLAIN if( p->explain ){ rc = sqlite3VdbeList(p); - }else{ + }else +#endif /* SQLITE_OMIT_EXPLAIN */ + { rc = sqlite3VdbeExec(p); } @@ -343,9 +371,11 @@ sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){ const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){ return sqlite3_value_text( columnMem(pStmt,i) ); } +#ifndef SQLITE_OMIT_UTF16 const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){ return sqlite3_value_text16( columnMem(pStmt,i) ); } +#endif /* SQLITE_OMIT_UTF16 */ int sqlite3_column_type(sqlite3_stmt *pStmt, int i){ return sqlite3_value_type( columnMem(pStmt,i) ); } @@ -384,14 +414,6 @@ const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){ } /* -** Return the name of the 'i'th column of the result set of SQL statement -** pStmt, encoded as UTF-16. -*/ -const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){ - return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, 0); -} - -/* ** Return the column declaration type (if applicable) of the 'i'th column ** of the result set of SQL statement pStmt, encoded as UTF-8. */ @@ -399,6 +421,15 @@ const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){ return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, 1); } +#ifndef SQLITE_OMIT_UTF16 +/* +** Return the name of the 'i'th column of the result set of SQL statement +** pStmt, encoded as UTF-16. +*/ +const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){ + return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, 0); +} + /* ** Return the column declaration type (if applicable) of the 'i'th column ** of the result set of SQL statement pStmt, encoded as UTF-16. @@ -406,6 +437,7 @@ const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){ const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){ return columnName(pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, 1); } +#endif /* SQLITE_OMIT_UTF16 */ /******************************* sqlite3_bind_ *************************** ** @@ -513,6 +545,7 @@ int sqlite3_bind_text( ){ return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8); } +#ifndef SQLITE_OMIT_UTF16 int sqlite3_bind_text16( sqlite3_stmt *pStmt, int i, @@ -522,6 +555,7 @@ int sqlite3_bind_text16( ){ return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE); } +#endif /* SQLITE_OMIT_UTF16 */ /* ** Return the number of wildcards that can be potentially bound to. @@ -578,10 +612,12 @@ int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){ return 0; } createVarMap(p); - for(i=0; i<p->nVar; i++){ - const char *z = p->azVar[i]; - if( z && strcmp(z,zName)==0 ){ - return i+1; + if( zName ){ + for(i=0; i<p->nVar; i++){ + const char *z = p->azVar[i]; + if( z && strcmp(z,zName)==0 ){ + return i+1; + } } } return 0; |