mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
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
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user