SQLite

Check-in [a1f29fa653]
Login

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

Overview
Comment:Make benign any malloc failures inside the sqlite3_file_control() call within PRAGMA parsing. Add a couple simple tests for SQLITE_FCNTL_PRAGMA.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | file-control-pragma
Files: files | file ages | folders
SHA1: a1f29fa653b788f563967f55c3d20e64cbe3f549
User & Date: drh 2012-02-22 18:21:20.823
Context
2012-02-22
19:03
Disable the "filename" pragma implemented by os_unix.c except when compiled with SQLITE_TEST. (check-in: 9a1da91850 user: drh tags: file-control-pragma)
18:21
Make benign any malloc failures inside the sqlite3_file_control() call within PRAGMA parsing. Add a couple simple tests for SQLITE_FCNTL_PRAGMA. (check-in: a1f29fa653 user: drh tags: file-control-pragma)
16:58
Change the SQLITE_FCNTL_PRAGMA file-control so that it can return a string value. (check-in: fd8d744027 user: drh tags: file-control-pragma)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/pragma.c.
353
354
355
356
357
358
359

360

361
362
363
364
365
366
367
  ** connection.  If it returns SQLITE_OK, then assume that the VFS
  ** handled the pragma and generate a no-op prepared statement.
  */
  aFcntl[0] = 0;
  aFcntl[1] = zLeft;
  aFcntl[2] = zRight;
  aFcntl[3] = 0;

  rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);

  if( rc==SQLITE_OK ){
    if( aFcntl[0] ){
      int mem = ++pParse->nMem;
      sqlite3VdbeAddOp4(v, OP_String8, 0, mem, 0, aFcntl[0], 0);
      sqlite3VdbeSetNumCols(v, 1);
      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC);
      sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);







>

>







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
  ** connection.  If it returns SQLITE_OK, then assume that the VFS
  ** handled the pragma and generate a no-op prepared statement.
  */
  aFcntl[0] = 0;
  aFcntl[1] = zLeft;
  aFcntl[2] = zRight;
  aFcntl[3] = 0;
  sqlite3BeginBenignMalloc();
  rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
  sqlite3EndBenignMalloc();
  if( rc==SQLITE_OK ){
    if( aFcntl[0] ){
      int mem = ++pParse->nMem;
      sqlite3VdbeAddOp4(v, OP_String8, 0, mem, 0, aFcntl[0], 0);
      sqlite3VdbeSetNumCols(v, 1);
      sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC);
      sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
Changes to test/attach.test.
269
270
271
272
273
274
275

276
277
278
279
280
281

282
283
284
285
286
287
288
      db_list db
    } {0 main}
  }
} ;# ifcapable schema_pragmas


if {[regexp unix [file_control_vfsname db]]} {

  do_test attach-1.30.1 {
    file tail [db eval {PRAGMA main.filename}]
  } {test.db}
  do_test attach-1.30.2 {
    db eval {PRAGMA temp.filename}
  } {}

}

ifcapable {trigger} {  # Only do the following tests if triggers are enabled
do_test attach-2.1 {
  execsql {
    CREATE TABLE tx(x1,x2,y1,y2);
    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN







>
|
|
|
|
|
|
>







269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
      db_list db
    } {0 main}
  }
} ;# ifcapable schema_pragmas


if {[regexp unix [file_control_vfsname db]]} {
  ifcapable debug {
    do_test attach-1.30.1 {
      file tail [db eval {PRAGMA main.filename}]
    } {test.db}
    do_test attach-1.30.2 {
      db eval {PRAGMA temp.filename}
    } {}
  }
}

ifcapable {trigger} {  # Only do the following tests if triggers are enabled
do_test attach-2.1 {
  execsql {
    CREATE TABLE tx(x1,x2,y1,y2);
    CREATE TRIGGER r1 AFTER UPDATE ON t2 FOR EACH ROW BEGIN