SQLite Archiver

Check-in [50d50f29fd]
Login

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

Overview
Comment:Change the name of the table in the database to "sqlar".
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 50d50f29fd2983c7a07dc5a2396019288aa29950
User & Date: drh 2014-06-13 17:16:02
Context
2014-06-13
17:57
First attempt at code for a FuseFS on an SQLite archive. Compiles, but does not work quite right. Added -Wall and -Werror to the makefile. check-in: a394ea2f57 user: drh tags: trunk
17:16
Change the name of the table in the database to "sqlar". check-in: 50d50f29fd user: drh tags: trunk
2014-06-02
15:50
Update the built-in SQLite to the latest 3.8.5 beta from upstream. check-in: ff0460752a user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to sqlar.c.

    36     36     exit(1);
    37     37   }
    38     38   
    39     39   /*
    40     40   ** The database schema:
    41     41   */
    42     42   static const char zSchema[] = 
    43         -  "CREATE TABLE IF NOT EXISTS sfa(\n"
           43  +  "CREATE TABLE IF NOT EXISTS sqlar(\n"
    44     44     "  name TEXT PRIMARY KEY,\n"
    45     45     "  mode INT,\n"
    46     46     "  mtime INT,\n"
    47     47     "  sz INT,\n"
    48     48     "  data BLOB\n"
    49     49     ");"
    50     50   ;
................................................................................
   277    277     check_filename(zFilename);
   278    278     rc = stat(zFilename, &x);
   279    279     if( rc ) errorMsg("no such file or directory: %s\n", zFilename);
   280    280     if( x.st_size>1000000000 ){
   281    281       errorMsg("file too big: %s\n", zFilename);
   282    282     }
   283    283     if( pStmt==0 ){
   284         -    db_prepare("REPLACE INTO sfa(name,mode,mtime,sz,data)"
          284  +    db_prepare("REPLACE INTO sqlar(name,mode,mtime,sz,data)"
   285    285                  " VALUES(?1,?2,?3,?4,?5)");
   286    286     }
   287    287     zName = zFilename;
   288    288     while( zName[0]=='/' ) zName++;
   289    289     sqlite3_bind_text(pStmt, 1, zName, -1, SQLITE_STATIC);
   290    290     sqlite3_bind_int(pStmt, 2, x.st_mode);
   291    291     sqlite3_bind_int64(pStmt, 3, x.st_mtime);
................................................................................
   368    368     int nFiles = 0;
   369    369     int listFlag = 0;
   370    370     int extractFlag = 0;
   371    371     int verboseFlag = 0;
   372    372     int noCompress = 0;
   373    373     int i, j;
   374    374   
   375         -  if( sqlite3_strglob("*/unsfa", argv[0])==0 ){
          375  +  if( sqlite3_strglob("*/unsqlar", argv[0])==0 ){
   376    376       extractFlag = 1;
   377    377     }
   378    378     for(i=1; i<argc; i++){
   379    379       if( argv[i][0]=='-' ){
   380    380         for(j=1; argv[i][j]; j++){
   381    381           switch( argv[i][j] ){
   382    382             case 'l':   listFlag = 1;    break;
................................................................................
   398    398     if( zArchive==0 ) showHelp(argv[0]);
   399    399     if( listFlag ){
   400    400       int rc;
   401    401       db_open(zArchive, 0);
   402    402       if( verboseFlag ){
   403    403         db_prepare(
   404    404             "SELECT name, sz, length(data), mode, datetime(mtime,'unixepoch')"
   405         -          " FROM sfa ORDER BY name"
          405  +          " FROM sqlar ORDER BY name"
   406    406         );
   407    407         while( sqlite3_step(pStmt)==SQLITE_ROW ){
   408    408           printf("%10d %10d %03o %s %s\n", 
   409    409                  sqlite3_column_int(pStmt, 1),
   410    410                  sqlite3_column_int(pStmt, 2),
   411    411                  sqlite3_column_int(pStmt, 3)&0777,
   412    412                  sqlite3_column_text(pStmt, 4),
   413    413                  sqlite3_column_text(pStmt, 0));
   414    414         }
   415    415       }else{
   416    416         db_prepare(
   417         -          "SELECT name FROM sfa ORDER BY name"
          417  +          "SELECT name FROM sqlar ORDER BY name"
   418    418         );
   419    419         while( sqlite3_step(pStmt)==SQLITE_ROW ){
   420    420           printf("%s\n", sqlite3_column_text(pStmt,0));
   421    421         }
   422    422       }
   423    423       db_close(1);
   424    424     }else if( extractFlag ){
................................................................................
   427    427       db_open(zArchive, 0);
   428    428       if( nFiles ){
   429    429         NameList x;
   430    430         x.azName = azFiles;
   431    431         x.nName = nFiles;
   432    432         sqlite3_create_function(db, "name_on_list", 1, SQLITE_UTF8,
   433    433                                 (char*)&x, name_on_list, 0, 0);
   434         -      zSql = "SELECT name, mode, mtime, sz, data FROM sfa"
          434  +      zSql = "SELECT name, mode, mtime, sz, data FROM sqlar"
   435    435                " WHERE name_on_list(filename)";
   436    436       }else{
   437         -      zSql = "SELECT name, mode, mtime, sz, data FROM sfa";
          437  +      zSql = "SELECT name, mode, mtime, sz, data FROM sqlar";
   438    438       }
   439    439       db_prepare(zSql);
   440    440       while( sqlite3_step(pStmt)==SQLITE_ROW ){
   441    441         const char *zFN = (const char*)sqlite3_column_text(pStmt, 0);
   442    442         check_filename(zFN);
   443    443         if( zFN[0]=='/' ){
   444    444           errorMsg("absolute pathname: %s\n", zFN);