@@ -7337,6 +7337,14 @@ static int arRemoveCommand(ArCommand *pAr){
73377337** Implementation of .ar "eXtract" command.
73387338*/
73397339static int arExtractCommand(ArCommand *pAr){
7340+ /* The zSql1[] string is a template for the query that does the
7341+ ** extraction. Notes:
7342+ **
7343+ ** * $dir is the directory into which the archive is to be extracted
7344+ ** * $pass is the integer pass number: 0, 1, or 2
7345+ ** * The dest CTE is created so that realpath($dir) only needs
7346+ ** to be called once.
7347+ */
73407348 const char *zSql1 =
73417349 "WITH dest(dpath,dlen) AS (\n"
73427350#ifdef _WIN32
@@ -7348,14 +7356,15 @@ static int arExtractCommand(ArCommand *pAr){
73487356 ")\n"
73497357 "SELECT\n"
73507358 " ($dir || name),\n"
7351- " CASE $dryrun\n"
7359+ " CASE $dryrun\n" /* vv--- azExtraArg */
73527360 " WHEN 0 THEN writefile($dir||name, %s, mode, mtime)\n"
73537361 " WHEN 1 THEN 0\n"
73547362 " ELSE shell_putsnl(format('writefile(%%Q,%%s,%%0o,%%d)',"
73557363 "$dir||name,quote(%s),mode,mtime)) IS NULL\n"
7356- " END\n"
7364+ " END\n" /* ^^--- azExtraArg */
73577365 " FROM dest CROSS JOIN %s\n"
7358- " WHERE (%s)\n"
7366+ " WHERE (%s)\n" /* ^^-- pAr->zSrcTable */
7367+ /* ^^--- zWhere */
73597368 " AND (CASE $pass WHEN 0 THEN (mode&0xf000)<>0xa000\n"
73607369 " WHEN 1 THEN (mode&0xf000)=0xa000\n"
73617370 " ELSE data IS NULL END)\n"
@@ -7389,7 +7398,10 @@ static int arExtractCommand(ArCommand *pAr){
73897398 }
73907399
73917400 shellPreparePrintf(pAr->db, &rc, &pSql, zSql1,
7392- azExtraArg[pAr->bZip], azExtraArg[pAr->bZip], pAr->zSrcTable, zWhere
7401+ azExtraArg[pAr->bZip],
7402+ azExtraArg[pAr->bZip],
7403+ pAr->zSrcTable,
7404+ zWhere
73937405 );
73947406
73957407 if( rc==SQLITE_OK ){
0 commit comments