Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | allow readonly access when write permission denied (CVS 131) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
897b4bc0e92a2c7534d4fa9453a7f8f8 |
User & Date: | drh 2000-08-17 09:50:00.000 |
Context
2000-08-17
| ||
10:22 | add version numbering (CVS 132) (check-in: 5ec2b09478 user: drh tags: trunk) | |
09:50 | allow readonly access when write permission denied (CVS 131) (check-in: 897b4bc0e9 user: drh tags: trunk) | |
2000-08-09
| ||
17:17 | bug fix (CVS 130) (check-in: e8882dac23 user: drh tags: trunk) | |
Changes
Changes to src/dbbe.c.
︙ | ︙ | |||
26 27 28 29 30 31 32 | ** sqlite and the code that does the actually reading and writing ** of information to the disk. ** ** This file uses GDBM as the database backend. It should be ** relatively simple to convert to a different database such ** as NDBM, SDBM, or BerkeleyDB. ** | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ** sqlite and the code that does the actually reading and writing ** of information to the disk. ** ** This file uses GDBM as the database backend. It should be ** relatively simple to convert to a different database such ** as NDBM, SDBM, or BerkeleyDB. ** ** $Id: dbbe.c,v 1.19 2000/08/17 09:50:00 drh Exp $ */ #include "sqliteInt.h" #include <gdbm.h> #include <sys/stat.h> #include <unistd.h> #include <ctype.h> #include <time.h> |
︙ | ︙ | |||
368 369 370 371 372 373 374 375 376 377 378 379 380 381 | pFile->pNext = pBe->pOpen; pBe->pOpen = pFile; if( pFile->dbf==0 ){ if( !writeable && access(zFile,0) ){ /* Trying to read a non-existant file. This is OK. All the ** reads will return empty, which is what we want. */ rc = SQLITE_OK; }else if( access(zFile,W_OK|R_OK) ){ rc = SQLITE_PERM; }else{ rc = SQLITE_BUSY; } } }else{ | > > | 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | pFile->pNext = pBe->pOpen; pBe->pOpen = pFile; if( pFile->dbf==0 ){ if( !writeable && access(zFile,0) ){ /* Trying to read a non-existant file. This is OK. All the ** reads will return empty, which is what we want. */ rc = SQLITE_OK; }else if( pBe->write==0 ){ rc = SQLITE_READONLY; }else if( access(zFile,W_OK|R_OK) ){ rc = SQLITE_PERM; }else{ rc = SQLITE_BUSY; } } }else{ |
︙ | ︙ | |||
409 410 411 412 413 414 415 | unlink(zFile); sqliteFree(zFile); } /* ** Reorganize a table to reduce search times and disk usage. */ | | > | > | > | 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | unlink(zFile); sqliteFree(zFile); } /* ** Reorganize a table to reduce search times and disk usage. */ int sqliteDbbeReorganizeTable(Dbbe *pBe, const char *zTable){ DbbeCursor *pCrsr; int rc; rc = sqliteDbbeOpenCursor(pBe, zTable, 1, &pCrsr); if( rc!=SQLITE_OK ){ return rc; } if( pCrsr && pCrsr->pFile && pCrsr->pFile->dbf ){ gdbm_reorganize(pCrsr->pFile->dbf); } if( pCrsr ){ sqliteDbbeCloseCursor(pCrsr); } return SQLITE_OK; } /* ** Close a cursor previously opened by sqliteDbbeOpenCursor(). ** ** There can be multiple cursors pointing to the same open file. ** The underlying file is not closed until all cursors have been |
︙ | ︙ |
Changes to src/dbbe.h.
︙ | ︙ | |||
24 25 26 27 28 29 30 | ** This file defines the interface to the database backend (Dbbe). ** ** The database backend is designed to be as general as possible ** so that it can easily be replaced by a different backend. ** This library was originally designed to support the following ** backends: GDBM, NDBM, SDBM, Berkeley DB. ** | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ** This file defines the interface to the database backend (Dbbe). ** ** The database backend is designed to be as general as possible ** so that it can easily be replaced by a different backend. ** This library was originally designed to support the following ** backends: GDBM, NDBM, SDBM, Berkeley DB. ** ** $Id: dbbe.h,v 1.7 2000/08/17 09:50:00 drh Exp $ */ #ifndef _SQLITE_DBBE_H_ #define _SQLITE_DBBE_H_ #include <stdio.h> /* ** The database backend supports two opaque structures. A Dbbe is |
︙ | ︙ | |||
75 76 77 78 79 80 81 | */ int sqliteDbbeOpenCursor(Dbbe*, const char *zName, int writeable, DbbeCursor**); /* Delete a table from the database */ void sqliteDbbeDropTable(Dbbe*, const char *zTableName); /* Reorganize a table to speed access or reduce its disk usage */ | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | */ int sqliteDbbeOpenCursor(Dbbe*, const char *zName, int writeable, DbbeCursor**); /* Delete a table from the database */ void sqliteDbbeDropTable(Dbbe*, const char *zTableName); /* Reorganize a table to speed access or reduce its disk usage */ int sqliteDbbeReorganizeTable(Dbbe*, const char *zTableName); /* Close a cursor */ void sqliteDbbeCloseCursor(DbbeCursor*); /* Fetch an entry from a table with the given key. Return 1 if ** successful and 0 if no such entry exists. */ |
︙ | ︙ |
Changes to src/shell.c.
︙ | ︙ | |||
20 21 22 23 24 25 26 | ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** | | | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ************************************************************************* ** This file contains code to implement the "sqlite" command line ** utility for accessing SQLite databases. ** ** $Id: shell.c,v 1.21 2000/08/17 09:50:00 drh Exp $ */ #include <stdlib.h> #include <string.h> #include <stdio.h> #include "sqlite.h" #include <unistd.h> #include <ctype.h> |
︙ | ︙ | |||
655 656 657 658 659 660 661 | } if( argc!=2 && argc!=3 ){ fprintf(stderr,"Usage: %s ?OPTIONS? FILENAME ?SQL?\n", argv0); exit(1); } data.db = db = sqlite_open(argv[1], 0666, &zErrMsg); if( db==0 ){ | > > | | | | | | > > > | 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | } if( argc!=2 && argc!=3 ){ fprintf(stderr,"Usage: %s ?OPTIONS? FILENAME ?SQL?\n", argv0); exit(1); } data.db = db = sqlite_open(argv[1], 0666, &zErrMsg); if( db==0 ){ data.db = db = sqlite_open(argv[1], 0444, &zErrMsg); if( db==0 ){ if( zErrMsg ){ fprintf(stderr,"Unable to open database \"%s\": %s\n", argv[1],zErrMsg); }else{ fprintf(stderr,"Unable to open database %s\n", argv[1]); } exit(1); }else{ printf("Database \"%s\" opened READ ONLY!\n", argv[1]); } } data.out = stdout; if( argc==3 ){ if( sqlite_exec(db, argv[2], callback, &data, &zErrMsg)!=0 && zErrMsg!=0 ){ fprintf(stderr,"SQL error: %s\n", zErrMsg); exit(1); } |
︙ | ︙ |
Changes to src/tclsqlite.c.
︙ | ︙ | |||
19 20 21 22 23 24 25 | ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ************************************************************************* ** A TCL Interface to SQLite ** | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ************************************************************************* ** A TCL Interface to SQLite ** ** $Id: tclsqlite.c,v 1.8 2000/08/17 09:50:00 drh Exp $ */ #include "sqlite.h" #include <tcl.h> #include <stdlib.h> #include <string.h> /* |
︙ | ︙ | |||
325 326 327 328 329 330 331 332 333 334 335 336 337 338 | ** (Hence there is no namespace. There is no point in using a namespace ** if the extension only supplies one new name!) The "sqlite" command is ** used to open a new SQLite database. See the DbMain() routine above ** for additional information. */ int Sqlite_Init(Tcl_Interp *interp){ Tcl_CreateCommand(interp, "sqlite", DbMain, 0, 0); return TCL_OK; } int Sqlite_SafeInit(Tcl_Interp *interp){ return TCL_OK; } /* | > | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | ** (Hence there is no namespace. There is no point in using a namespace ** if the extension only supplies one new name!) The "sqlite" command is ** used to open a new SQLite database. See the DbMain() routine above ** for additional information. */ int Sqlite_Init(Tcl_Interp *interp){ Tcl_CreateCommand(interp, "sqlite", DbMain, 0, 0); Tcl_PkgProvide(interp, "sqlite", "1.0"); return TCL_OK; } int Sqlite_SafeInit(Tcl_Interp *interp){ return TCL_OK; } /* |
︙ | ︙ |
Changes to test/dbbe.test.
︙ | ︙ | |||
19 20 21 22 23 24 25 | # drh@hwaci.com # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is exercising the code in dbbe.c. # | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # drh@hwaci.com # http://www.hwaci.com/drh/ # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is exercising the code in dbbe.c. # # $Id: dbbe.test,v 1.3 2000/08/17 09:50:00 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Try to open a database that does not exist. # do_test dbbe-1.1 { |
︙ | ︙ | |||
126 127 128 129 130 131 132 | file delete -force testdb sqlite db testdb 0666 execsql {CREATE TABLE t1(x int)} db close sqlite db testdb 0444 set v [catch {execsql {INSERT INTO t1 VALUES(1)}} msg] lappend v $msg | | | 126 127 128 129 130 131 132 133 134 135 136 | file delete -force testdb sqlite db testdb 0666 execsql {CREATE TABLE t1(x int)} db close sqlite db testdb 0444 set v [catch {execsql {INSERT INTO t1 VALUES(1)}} msg] lappend v $msg } {1 {table t1 is readonly}} finish_test |
Changes to www/changes.tcl.
︙ | ︙ | |||
12 13 14 15 16 17 18 19 20 21 22 23 24 25 | } proc chng {date desc} { puts "<DT><B>$date</B></DT>" puts "<DD><P><UL>$desc</UL></P></DD>" } chng {2000 Aug 9} { <li>Treat carriage returns as white space.</li> } chng {2000 Aug 8} { <li>Added pattern matching to the ".table" command in the "sqlite" | > > > > > > | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | } proc chng {date desc} { puts "<DT><B>$date</B></DT>" puts "<DD><P><UL>$desc</UL></P></DD>" } chng {2000 Aug 17} { <li>Change the <b>sqlite</b> program so that it can read databases for which it lacks write permission. (It used to refuse all access if it could not write.)</li> } chng {2000 Aug 9} { <li>Treat carriage returns as white space.</li> } chng {2000 Aug 8} { <li>Added pattern matching to the ".table" command in the "sqlite" |
︙ | ︙ |