/ Check-in [aef7945c]
Login

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

Overview
Comment:Cherrypick the sqlite_data_count() changes from [d4f95b3b6e] and [9913996e7b] into the apple-osx branch for version 3.7.7.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | apple-osx-377
Files: files | file ages | folders
SHA1: aef7945c423a8338374572eeda9444866c64569b
User & Date: drh 2011-10-10 18:59:05
Original Comment: Cherrypick the sqlite_data_count() changes from [d4f95b3b6e] and [9913996e7b] into the apple-osx branch for version 3.7.7.
Context
2011-10-10
22:11
Merging in cherry picked diffs for persist wal, alloc padding, wal-safe vacuum and sqlite3_file_control based lockstate checking check-in: db5b7b77 user: adam tags: apple-osx-377
18:59
Cherrypick the sqlite_data_count() changes from [d4f95b3b6e] and [9913996e7b] into the apple-osx branch for version 3.7.7. check-in: aef7945c user: drh tags: apple-osx-377
2011-06-25
21:43
Changes to make pragma synchronous sticky when SQLITE_DEFAULT_WAL_SAFETYLEVEL is used check-in: c6158b25 user: adam tags: apple-osx
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqlite.h.in.

  3319   3319   **
  3320   3320   ** ^The sqlite3_data_count(P) interface returns the number of columns in the
  3321   3321   ** current row of the result set of [prepared statement] P.
  3322   3322   ** ^If prepared statement P does not have results ready to return
  3323   3323   ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
  3324   3324   ** interfaces) then sqlite3_data_count(P) returns 0.
  3325   3325   ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
         3326  +** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
         3327  +** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)
         3328  +** will return non-zero if previous call to [sqlite3_step](P) returned
         3329  +** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]
         3330  +** where it always returns zero since each step of that multi-step
         3331  +** pragma returns 0 columns of data.
  3326   3332   **
  3327   3333   ** See also: [sqlite3_column_count()]
  3328   3334   */
  3329   3335   int sqlite3_data_count(sqlite3_stmt *pStmt);
  3330   3336   
  3331   3337   /*
  3332   3338   ** CAPI3REF: Fundamental Datatypes

Changes to src/vdbeaux.c.

  1134   1134     int nRow;                            /* Stop when row count reaches this */
  1135   1135     int nSub = 0;                        /* Number of sub-vdbes seen so far */
  1136   1136     SubProgram **apSub = 0;              /* Array of sub-vdbes */
  1137   1137     Mem *pSub = 0;                       /* Memory cell hold array of subprogs */
  1138   1138     sqlite3 *db = p->db;                 /* The database connection */
  1139   1139     int i;                               /* Loop counter */
  1140   1140     int rc = SQLITE_OK;                  /* Return code */
  1141         -  Mem *pMem = p->pResultSet = &p->aMem[1];  /* First Mem of result set */
         1141  +  Mem *pMem = &p->aMem[1];             /* First Mem of result set */
  1142   1142   
  1143   1143     assert( p->explain );
  1144   1144     assert( p->magic==VDBE_MAGIC_RUN );
  1145   1145     assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );
  1146   1146   
  1147   1147     /* Even though this opcode does not use dynamic strings for
  1148   1148     ** the result, result columns may become dynamic if the user calls
  1149   1149     ** sqlite3_column_text16(), causing a translation to UTF-16 encoding.
  1150   1150     */
  1151   1151     releaseMemArray(pMem, 8);
         1152  +  p->pResultSet = 0;
  1152   1153   
  1153   1154     if( p->rc==SQLITE_NOMEM ){
  1154   1155       /* This happens if a malloc() inside a call to sqlite3_column_text() or
  1155   1156       ** sqlite3_column_text16() failed.  */
  1156   1157       db->mallocFailed = 1;
  1157   1158       return SQLITE_ERROR;
  1158   1159     }
................................................................................
  1299   1300         {
  1300   1301           pMem->flags = MEM_Null;                       /* Comment */
  1301   1302           pMem->type = SQLITE_NULL;
  1302   1303         }
  1303   1304       }
  1304   1305   
  1305   1306       p->nResColumn = 8 - 4*(p->explain-1);
         1307  +    p->pResultSet = &p->aMem[1];
  1306   1308       p->rc = SQLITE_OK;
  1307   1309       rc = SQLITE_ROW;
  1308   1310     }
  1309   1311     return rc;
  1310   1312   }
  1311   1313   #endif /* SQLITE_OMIT_EXPLAIN */
  1312   1314