/ Check-in [6881f921]
Login

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

Overview
Comment:Better handle malloc() failures in the "echo" virtual table test module. (CVS 3855)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6881f9212fea0e0a98045b0acc60151eeaf5839e
User & Date: danielk1977 2007-04-18 17:04:01
Context
2007-04-18
17:07
Fix a && where & was intended. This is a real problem, but it would be very difficult to devise a test case where it might lead to an unexpected result. Ticket #2306. (CVS 3856) check-in: 7f9f0444 user: drh tags: trunk
17:04
Better handle malloc() failures in the "echo" virtual table test module. (CVS 3855) check-in: 6881f921 user: danielk1977 tags: trunk
16:45
The sqlite3_step() routine reports SQLITE_ERROR after a commit failure, not SQLITE_DONE. This fix only effects the legacy sqlite3_prepare() interface. It already worked correctly with sqlite3_prepare_v2(). (CVS 3854) check-in: 165dc72d user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/test8.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
265
266
267
268
269
270
271

272
273
274



275
276
277
278
279
280
281
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.45 2007/03/30 14:56:35 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  if( argc>=4 ){
    sqlite3_stmt *pStmt = 0;
    sqlite3_prepare(db, 
        "SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?",
        -1, &pStmt, 0);
    sqlite3_bind_text(pStmt, 1, argv[3], -1, 0);
    if( sqlite3_step(pStmt)==SQLITE_ROW ){

      const char *zCreateTable = (const char *)sqlite3_column_text(pStmt, 0);
      sqlite3_declare_vtab(db, zCreateTable);
      rc = sqlite3_finalize(pStmt);



    } else {
      rc = sqlite3_finalize(pStmt);
      if( rc==SQLITE_OK ){ 
        rc = SQLITE_ERROR;
      }
    }








|







 







>

|
|
>
>
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the virtual table interfaces.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test8.c,v 1.46 2007/04/18 17:04:01 danielk1977 Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

................................................................................
  if( argc>=4 ){
    sqlite3_stmt *pStmt = 0;
    sqlite3_prepare(db, 
        "SELECT sql FROM sqlite_master WHERE type = 'table' AND name = ?",
        -1, &pStmt, 0);
    sqlite3_bind_text(pStmt, 1, argv[3], -1, 0);
    if( sqlite3_step(pStmt)==SQLITE_ROW ){
      int rc2;
      const char *zCreateTable = (const char *)sqlite3_column_text(pStmt, 0);
      rc = sqlite3_declare_vtab(db, zCreateTable);
      rc2 = sqlite3_finalize(pStmt);
      if( rc==SQLITE_OK ){
        rc = rc2;
      }
    } else {
      rc = sqlite3_finalize(pStmt);
      if( rc==SQLITE_OK ){ 
        rc = SQLITE_ERROR;
      }
    }