/ Check-in [9913996e]
Login

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

Overview
Comment:Enhance the sqlite3_data_count() routine so that it can be used to determine if SQLITE_DONE has been seen on the prepared statement.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9913996e7b0f94ba1c51200b61433193002f3638
User & Date: drh 2011-10-07 12:59:23
References
2011-10-10
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
Context
2011-10-07
16:57
Add the SQLITE_FCNTL_OVERWRITE file-control. Used by SQLite to indicate to the OS layer that the current transaction will overwrite the entire file. check-in: 1da87fcd user: dan tags: trunk
13:33
Begin an effort to enhance the query planner to do a better job with OR terms in the WHERE clause. This change allows ANDs outside of the OR to be factored into the OR terms if that is helpful in finding better indices. check-in: 876bd21a user: drh tags: or-opt
12:59
Enhance the sqlite3_data_count() routine so that it can be used to determine if SQLITE_DONE has been seen on the prepared statement. check-in: 9913996e user: drh tags: trunk
2011-10-05
19:46
Add the --pageinfo and --stats options to the sqlite3_analyzer utility. check-in: baa80c7b user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqlite.h.in.

  3344   3344   **
  3345   3345   ** ^The sqlite3_data_count(P) interface returns the number of columns in the
  3346   3346   ** current row of the result set of [prepared statement] P.
  3347   3347   ** ^If prepared statement P does not have results ready to return
  3348   3348   ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
  3349   3349   ** interfaces) then sqlite3_data_count(P) returns 0.
  3350   3350   ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
         3351  +** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
         3352  +** [sqlite3_step](P) returned [SQLITE_DONE].  ^The sqlite3_data_count(P)
         3353  +** will return non-zero if previous call to [sqlite3_step](P) returned
         3354  +** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]
         3355  +** where it always returns zero since each step of that multi-step
         3356  +** pragma returns 0 columns of data.
  3351   3357   **
  3352   3358   ** See also: [sqlite3_column_count()]
  3353   3359   */
  3354   3360   int sqlite3_data_count(sqlite3_stmt *pStmt);
  3355   3361   
  3356   3362   /*
  3357   3363   ** CAPI3REF: Fundamental Datatypes

Changes to src/vdbeaux.c.

  1149   1149     assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );
  1150   1150   
  1151   1151     /* Even though this opcode does not use dynamic strings for
  1152   1152     ** the result, result columns may become dynamic if the user calls
  1153   1153     ** sqlite3_column_text16(), causing a translation to UTF-16 encoding.
  1154   1154     */
  1155   1155     releaseMemArray(pMem, 8);
         1156  +  p->nResColumn = 0;
  1156   1157   
  1157   1158     if( p->rc==SQLITE_NOMEM ){
  1158   1159       /* This happens if a malloc() inside a call to sqlite3_column_text() or
  1159   1160       ** sqlite3_column_text16() failed.  */
  1160   1161       db->mallocFailed = 1;
  1161   1162       return SQLITE_ERROR;
  1162   1163     }