aboutsummaryrefslogtreecommitdiff
path: root/src/vdbeapi.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2011-06-01 18:15:55 +0000
committerdrh <drh@noemail.net>2011-06-01 18:15:55 +0000
commit124c0b49a19ce24302c6594e60c80c7ba4df6c98 (patch)
tree5066d410d5c3c2a95b66023abfcd1af829c4d160 /src/vdbeapi.c
parented9624187d89a96e591353a7bdee53b292e6f849 (diff)
downloadsqlite-124c0b49a19ce24302c6594e60c80c7ba4df6c98.tar.gz
sqlite-124c0b49a19ce24302c6594e60c80c7ba4df6c98.zip
Refactor the SQL parameter processing so that parameter names for values
that are optimized out of the prepare statement are not forgotten. FossilOrigin-Name: b3aaf715b60b8a338cc6c92dad1ead4a3f7146a3
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r--src/vdbeapi.c34
1 files changed, 3 insertions, 31 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c
index 90baaccc6..5923a4c01 100644
--- a/src/vdbeapi.c
+++ b/src/vdbeapi.c
@@ -102,7 +102,7 @@ int sqlite3_reset(sqlite3_stmt *pStmt){
Vdbe *v = (Vdbe*)pStmt;
sqlite3_mutex_enter(v->db->mutex);
rc = sqlite3VdbeReset(v);
- sqlite3VdbeMakeReady(v, -1, 0, 0, 0, 0, 0);
+ sqlite3VdbeRewind(v);
assert( (rc & (v->db->errMask))==rc );
rc = sqlite3ApiExit(v->db, rc);
sqlite3_mutex_leave(v->db->mutex);
@@ -1168,32 +1168,6 @@ int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
}
/*
-** Create a mapping from variable numbers to variable names
-** in the Vdbe.azVar[] array, if such a mapping does not already
-** exist.
-*/
-static void createVarMap(Vdbe *p){
- if( !p->okVar ){
- int j;
- Op *pOp;
- sqlite3_mutex_enter(p->db->mutex);
- /* The race condition here is harmless. If two threads call this
- ** routine on the same Vdbe at the same time, they both might end
- ** up initializing the Vdbe.azVar[] array. That is a little extra
- ** work but it results in the same answer.
- */
- for(j=0, pOp=p->aOp; j<p->nOp; j++, pOp++){
- if( pOp->opcode==OP_Variable ){
- assert( pOp->p1>0 && pOp->p1<=p->nVar );
- p->azVar[pOp->p1-1] = pOp->p4.z;
- }
- }
- p->okVar = 1;
- sqlite3_mutex_leave(p->db->mutex);
- }
-}
-
-/*
** Return the name of a wildcard parameter. Return NULL if the index
** is out of range or if the wildcard is unnamed.
**
@@ -1201,10 +1175,9 @@ static void createVarMap(Vdbe *p){
*/
const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
Vdbe *p = (Vdbe*)pStmt;
- if( p==0 || i<1 || i>p->nVar ){
+ if( p==0 || i<1 || i>p->nzVar ){
return 0;
}
- createVarMap(p);
return p->azVar[i-1];
}
@@ -1218,9 +1191,8 @@ int sqlite3VdbeParameterIndex(Vdbe *p, const char *zName, int nName){
if( p==0 ){
return 0;
}
- createVarMap(p);
if( zName ){
- for(i=0; i<p->nVar; i++){
+ for(i=0; i<p->nzVar; i++){
const char *z = p->azVar[i];
if( z && memcmp(z,zName,nName)==0 && z[nName]==0 ){
return i+1;