aboutsummaryrefslogtreecommitdiff
path: root/src/vdbeapi.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2017-07-17 00:40:19 +0000
committerdrh <drh@noemail.net>2017-07-17 00:40:19 +0000
commitae3ec3f920f39802f81d6ef64283e2925d64ec57 (patch)
tree7dedb20e1a8bbb316c91802b7913739d20b0abec /src/vdbeapi.c
parentfe8eadc94dc15a77245b7537b1230385caba9161 (diff)
downloadsqlite-ae3ec3f920f39802f81d6ef64283e2925d64ec57.tar.gz
sqlite-ae3ec3f920f39802f81d6ef64283e2925d64ec57.zip
Add an experimental "pointer type" parameter to sqlite3_bind_pointer(),
sqlite3_result_pointer(), and sqlite3_value_pointer(). The pointer type is a string that must compare equal using strcmp() or else the pointer comes through as a NULL. FossilOrigin-Name: 211cce04e97d2e325a6ea3e99738fc71115d673dc13daeffb03ac3140deb11de
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r--src/vdbeapi.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index b94facead..9de248633 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -199,9 +199,13 @@ unsigned int sqlite3_value_subtype(sqlite3_value *pVal){
Mem *pMem = (Mem*)pVal;
return ((pMem->flags & MEM_Subtype) ? pMem->eSubtype : 0);
}
-void *sqlite3_value_pointer(sqlite3_value *pVal){
+void *sqlite3_value_pointer(sqlite3_value *pVal, const char *zPType){
Mem *p = (Mem*)pVal;
- if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype) && p->eSubtype=='p' ){
+ if( (p->flags & MEM_TypeMask)==(MEM_Null|MEM_Subtype)
+ && p->eSubtype=='p'
+ && zPType!=0
+ && strcmp(p->z, zPType)==0
+ ){
return p->u.pPtr;
}else{
return 0;
@@ -385,11 +389,11 @@ void sqlite3_result_null(sqlite3_context *pCtx){
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
sqlite3VdbeMemSetNull(pCtx->pOut);
}
-void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr){
+void sqlite3_result_pointer(sqlite3_context *pCtx, void *pPtr, const char *zPT){
Mem *pOut = pCtx->pOut;
assert( sqlite3_mutex_held(pOut->db->mutex) );
sqlite3VdbeMemSetNull(pOut);
- sqlite3VdbeMemSetPointer(pOut, pPtr);
+ sqlite3VdbeMemSetPointer(pOut, pPtr, zPT);
}
void sqlite3_result_subtype(sqlite3_context *pCtx, unsigned int eSubtype){
Mem *pOut = pCtx->pOut;
@@ -1394,12 +1398,12 @@ int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
}
return rc;
}
-int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr){
+int sqlite3_bind_pointer(sqlite3_stmt *pStmt, int i, void *pPtr,const char *zT){
int rc;
Vdbe *p = (Vdbe*)pStmt;
rc = vdbeUnbind(p, i);
if( rc==SQLITE_OK ){
- sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr);
+ sqlite3VdbeMemSetPointer(&p->aVar[i-1], pPtr, zT);
sqlite3_mutex_leave(p->db->mutex);
}
return rc;