aboutsummaryrefslogtreecommitdiff
path: root/src/vdbeaux.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vdbeaux.c')
-rw-r--r--src/vdbeaux.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/vdbeaux.c b/src/vdbeaux.c
index 3db26b29e..d25b633dd 100644
--- a/src/vdbeaux.c
+++ b/src/vdbeaux.c
@@ -3022,3 +3022,44 @@ void sqlite3ExpirePreparedStatements(sqlite3 *db){
sqlite3 *sqlite3VdbeDb(Vdbe *v){
return v->db;
}
+
+/*
+** Return a pointer to an sqlite3_value structure containing the value bound
+** parameter iVar of VM v. Except, if the value is an SQL NULL, return
+** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
+** constants) to the value before returning it.
+**
+** The returned value must be freed by the caller using sqlite3ValueFree().
+*/
+sqlite3_value *sqlite3VdbeGetValue(Vdbe *v, int iVar, u8 aff){
+ assert( iVar>0 );
+ if( v ){
+ Mem *pMem = &v->aVar[iVar-1];
+ if( 0==(pMem->flags & MEM_Null) ){
+ sqlite3_value *pRet = sqlite3ValueNew(v->db);
+ if( pRet ){
+ sqlite3VdbeMemCopy((Mem *)pRet, pMem);
+ sqlite3ValueApplyAffinity(pRet, aff, SQLITE_UTF8);
+ sqlite3VdbeMemStoreType((Mem *)pRet);
+ }
+ return pRet;
+ }
+ }
+ return 0;
+}
+
+/*
+** Configure SQL variable iVar so that binding a new value to it signals
+** to sqlite3_reoptimize() that re-preparing the statement may result
+** in a better query plan.
+*/
+void sqlite3VdbeSetVarmask(Vdbe *v, int iVar, int isExpire){
+ u32 *mask = (isExpire ? &v->expmask : &v->optmask);
+ assert( iVar>0 );
+ if( iVar>32 ){
+ *mask = 0xffffffff;
+ }else{
+ *mask |= ((u32)1 << (iVar-1));
+ }
+}
+