/ Check-in [3db0c798]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Reimplement the sqlite3_bind_value() interface so that it works when the value being bound comes from a different database connection. (CVS 6504)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3db0c7980668cf38165add13f833863cd00a0cfe
User & Date: drh 2009-04-14 12:43:34
Context
2009-04-14
12:58
Change the sqlite3_bind_value() implementation to use a default branch on the type switch so that there are no untested jumps in the switch. (CVS 6505) check-in: d0a8bd6a user: drh tags: trunk
12:43
Reimplement the sqlite3_bind_value() interface so that it works when the value being bound comes from a different database connection. (CVS 6504) check-in: 3db0c798 user: drh tags: trunk
2009-04-13
14:43
Enhancements to virtual table documentation. Comment changes only. No changes to code. (CVS 6503) check-in: b0b2b283 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbeapi.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   **
    13     13   ** This file contains code use to implement APIs that are part of the
    14     14   ** VDBE.
    15     15   **
    16         -** $Id: vdbeapi.c,v 1.161 2009/04/10 23:11:31 drh Exp $
           16  +** $Id: vdbeapi.c,v 1.162 2009/04/14 12:43:34 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "vdbeInt.h"
    20     20   
    21     21   #if 0 && defined(SQLITE_ENABLE_MEMORY_MANAGEMENT)
    22     22   /*
    23     23   ** The following structure contains pointers to the end points of a
................................................................................
  1148   1148     void (*xDel)(void*)
  1149   1149   ){
  1150   1150     return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
  1151   1151   }
  1152   1152   #endif /* SQLITE_OMIT_UTF16 */
  1153   1153   int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
  1154   1154     int rc;
  1155         -  Vdbe *p = (Vdbe *)pStmt;
  1156         -  rc = vdbeUnbind(p, i);
  1157         -  if( rc==SQLITE_OK ){
  1158         -    rc = sqlite3VdbeMemCopy(&p->aVar[i-1], pValue);
  1159         -    if( rc==SQLITE_OK ){
  1160         -      rc = sqlite3VdbeChangeEncoding(&p->aVar[i-1], ENC(p->db));
         1155  +  switch( pValue->type ){
         1156  +    case SQLITE_NULL: {
         1157  +      rc = sqlite3_bind_null(pStmt, i);
         1158  +      break;
         1159  +    }
         1160  +    case SQLITE_INTEGER: {
         1161  +      rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);
         1162  +      break;
         1163  +    }
         1164  +    case SQLITE_FLOAT: {
         1165  +      rc = sqlite3_bind_double(pStmt, i, pValue->r);
         1166  +      break;
         1167  +    }
         1168  +    case SQLITE_BLOB: {
         1169  +      if( pValue->flags & MEM_Zero ){
         1170  +        rc = sqlite3_bind_zeroblob(pStmt, i, pValue->u.nZero);
         1171  +      }else{
         1172  +        rc = sqlite3_bind_blob(pStmt, i, pValue->z, pValue->n,SQLITE_TRANSIENT);
         1173  +      }
         1174  +      break;
  1161   1175       }
  1162         -    sqlite3_mutex_leave(p->db->mutex);
  1163         -    rc = sqlite3ApiExit(p->db, rc);
         1176  +    case SQLITE_TEXT: {
         1177  +      rc = bindText(pStmt,i,  pValue->z, pValue->n, SQLITE_TRANSIENT, pValue->enc);
         1178  +      break;
         1179  +    }
  1164   1180     }
  1165   1181     return rc;
  1166   1182   }
  1167   1183   int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
  1168   1184     int rc;
  1169   1185     Vdbe *p = (Vdbe *)pStmt;
  1170   1186     rc = vdbeUnbind(p, i);