diff options
author | drh <drh@noemail.net> | 2004-08-20 16:02:39 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2004-08-20 16:02:39 +0000 |
commit | 895d7472264d0f406779449f71b12ef2e9aea2fe (patch) | |
tree | 47bada3c002f0359d19d89a3f6ceb1952e837ed1 /src/vdbeapi.c | |
parent | e8cf2cacb1f553f8245a5dd08349be2c02373dc2 (diff) | |
download | sqlite-895d7472264d0f406779449f71b12ef2e9aea2fe.tar.gz sqlite-895d7472264d0f406779449f71b12ef2e9aea2fe.zip |
Add support for named wildcards in SQL statements. (CVS 1897)
FossilOrigin-Name: d3be0b7c5a39c02b9b2d6d85f1595d591984a569
Diffstat (limited to 'src/vdbeapi.c')
-rw-r--r-- | src/vdbeapi.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 8c8c27816..09a1006b3 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -518,9 +518,32 @@ int sqlite3_bind_text16( /* ** Return the number of wildcards that can be potentially bound to. ** This routine is added to support DBD::SQLite. -** -******** EXPERIMENTAL ******* */ int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){ return ((Vdbe*)pStmt)->nVar; } + +/* +** Return the name of a wildcard parameter. Return NULL if the index +** is out of range or if the wildcard is unnamed. +** +** The result is always UTF-8. +*/ +const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){ + Vdbe *p = (Vdbe*)pStmt; + if( i<1 || i>p->nVar ){ + return 0; + } + if( !p->okVar ){ + int j; + Op *pOp; + 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->p3; + } + } + p->okVar = 1; + } + return p->azVar[i-1]; +} |