From: dan Date: Wed, 13 Dec 2017 20:17:18 +0000 (+0000) Subject: Add the shell tool ".ar --update" command. X-Git-Tag: version-3.22.0~108^2~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=06741a3c9b7bfb10c6d22ae74706b40af46ecd4a;p=thirdparty%2Fsqlite.git Add the shell tool ".ar --update" command. FossilOrigin-Name: 825e3c037b03fc09d581aeda0193ff1d4062404414c7354cb649f99aa9022d25 --- diff --git a/manifest b/manifest index 8be2f2242c..c7890a8a98 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sthe\s"--list"\scommand.\sAnd\sfor\sarguments\sto\sthe\s"--extract"\ncommand. -D 2017-12-13T20:04:53.034 +C Add\sthe\sshell\stool\s".ar\s--update"\scommand. +D 2017-12-13T20:17:18.759 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 6a879cbf01e37f9eac131414955f71774b566502d9a57ded1b8585b507503cb8 @@ -474,7 +474,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c bbee7e31d369a18a2f4836644769882e9c5d40ef4a3af911db06410b65cb3730 F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c 17e220191860a64a18c084141e1a8b7309e166a6f2d42c02021af27ea080d157 -F src/shell.c.in b53eddcb293a9d35c0673c1d3bf2cf120b55e6660b436f65d689776a56391562 +F src/shell.c.in 12313c0500b9b1958507d3a432c192f73f86da112f0f37467636530696d13152 F src/sqlite.h.in 8fd97993d48b50b9bade38c52f12d175942c9497c960905610c7b03a3e4b5818 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h c02d628cca67f3889c689d82d25c3eb45e2c155db08e4c6089b5840d64687d34 @@ -1682,7 +1682,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 1a9867973c9d6675fa5254fdd74f36004707a98a91593a188033cf5a49cc7a0b -R c505f9c0d154ac54b6761fcc5d07e027 +P 32c4fa2552bb0fa7d7d143108457efae7a756d6cb14b1d59312e56efac3b2656 +R 656e4fd0036ab859f27379daf7289767 U dan -Z dcb23b384070f4f2014f2150f41e157a +Z 57a0e73a5198163aa720919c6750aab2 diff --git a/manifest.uuid b/manifest.uuid index 71ba76fdc3..937d78b439 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -32c4fa2552bb0fa7d7d143108457efae7a756d6cb14b1d59312e56efac3b2656 \ No newline at end of file +825e3c037b03fc09d581aeda0193ff1d4062404414c7354cb649f99aa9022d25 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 0230e5f4d7..e9a01ed779 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -4328,14 +4328,6 @@ static int arParseCommand( return SQLITE_OK; } -/* -** Implementation of .ar "Update" command. -*/ -static int arUpdateCmd(ShellState *p, sqlite3 *db, ArCommand *pAr){ - raw_printf(stderr, "todo...\n"); - return SQLITE_OK; -} - /* ** This function assumes that all arguments within the ArCommand.azArg[] ** array refer to archive members, as for the --extract or --list commands. @@ -4500,17 +4492,21 @@ static int arExtractCommand(ShellState *p, sqlite3 *db, ArCommand *pAr){ /* -** Implementation of .ar "Create" command. +** Implementation of .ar "create" and "update" commands. ** ** Create the "sqlar" table in the database if it does not already exist. ** Then add each file in the azFile[] array to the archive. Directories ** are added recursively. If argument bVerbose is non-zero, a message is ** printed on stdout for each file archived. +** +** The create command is the same as update, except that it drops +** any existing "sqlar" table before beginning. */ -static int arCreateCommand( +static int arCreateUpdate( ShellState *p, /* Shell state pointer */ sqlite3 *db, - ArCommand *pAr /* Command arguments and options */ + ArCommand *pAr, /* Command arguments and options */ + int bUpdate ){ const char *zSql = "SELECT name, mode, mtime, data FROM fsdir(?, ?)"; const char *zCreate = @@ -4535,8 +4531,10 @@ static int arCreateCommand( rc = sqlite3_exec(db, "SAVEPOINT ar;", 0, 0, 0); if( rc!=SQLITE_OK ) return rc; - rc = sqlite3_exec(db, zDrop, 0, 0, 0); - if( rc!=SQLITE_OK ) return rc; + if( bUpdate==0 ){ + rc = sqlite3_exec(db, zDrop, 0, 0, 0); + if( rc!=SQLITE_OK ) return rc; + } rc = sqlite3_exec(db, zCreate, 0, 0, 0); shellPrepare(db, &rc, zInsert, &pInsert); @@ -4610,6 +4608,30 @@ static int arCreateCommand( return rc; } +/* +** Implementation of .ar "Create" command. +** +** Create the "sqlar" table in the database if it does not already exist. +** Then add each file in the azFile[] array to the archive. Directories +** are added recursively. If argument bVerbose is non-zero, a message is +** printed on stdout for each file archived. +*/ +static int arCreateCommand( + ShellState *p, /* Shell state pointer */ + sqlite3 *db, + ArCommand *pAr /* Command arguments and options */ +){ + return arCreateUpdate(p, db, pAr, 0); +} + +/* +** Implementation of .ar "Update" command. +*/ +static int arUpdateCmd(ShellState *p, sqlite3 *db, ArCommand *pAr){ + return arCreateUpdate(p, db, pAr, 1); +} + + /* ** Implementation of ".ar" dot command. */