Lines Matching defs:pAr
20978 static int arErrorMsg(ArCommand *pAr, const char *zFmt, ...){
20985 if( pAr->fromCmdLine ){
21015 static int arProcessSwitch(ArCommand *pAr, int eSwitch, const char *zArg){
21024 if( pAr->eCmd ){
21025 return arErrorMsg(pAr, "multiple command options");
21027 pAr->eCmd = eSwitch;
21031 pAr->bDryRun = 1;
21034 pAr->bGlob = 1;
21037 pAr->bVerbose = 1;
21040 pAr->bAppend = 1;
21043 pAr->zFile = zArg;
21046 pAr->zDir = zArg;
21055 ** structure (*pAr). SQLITE_OK is returned if the command line is parsed
21062 ArCommand *pAr /* Populate this object */
21103 return arErrorMsg(pAr, "unrecognized option: %c", z[i]);
21107 return arErrorMsg(pAr, "option requires an argument: %c",z[i]);
21111 if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR;
21113 pAr->nArg = nArg-iArg;
21114 if( pAr->nArg>0 ){
21115 pAr->azArg = &azArg[iArg];
21125 pAr->azArg = &azArg[iArg];
21126 pAr->nArg = nArg-iArg;
21141 return arErrorMsg(pAr, "unrecognized option: %c", z[i]);
21149 return arErrorMsg(pAr, "option requires an argument: %c",
21155 if( arProcessSwitch(pAr, pOpt->eSwitch, zArg) ) return SQLITE_ERROR;
21160 pAr->azArg = &azArg[iArg+1];
21161 pAr->nArg = nArg-iArg-1;
21172 return arErrorMsg(pAr, "ambiguous option: %s",z);
21180 return arErrorMsg(pAr, "unrecognized option: %s", z);
21184 return arErrorMsg(pAr, "option requires an argument: %s", z);
21188 if( arProcessSwitch(pAr, pMatch->eSwitch, zArg) ) return SQLITE_ERROR;
21204 ** exact equality when pAr->bGlob is false or a "name GLOB pattern" match
21205 ** when pAr->bGlob is true.
21211 static int arCheckEntries(ArCommand *pAr){
21213 if( pAr->nArg ){
21216 const char *zSel = (pAr->bGlob)
21220 shellPreparePrintf(pAr->db, &rc, &pTest, zSel, pAr->zSrcTable);
21222 for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
21223 char *z = pAr->azArg[i];
21246 ** in (*pAr). Leave this WHERE clause in (*pzWhere) before returning.
21249 ** when pAr->bGlob is false and GLOB match when pAr->bGlob is true.
21253 ArCommand *pAr,
21257 const char *zSameOp = (pAr->bGlob)? "GLOB" : "=";
21259 if( pAr->nArg==0 ){
21264 for(i=0; i<pAr->nArg; i++){
21265 const char *z = pAr->azArg[i];
21284 static int arListCommand(ArCommand *pAr){
21295 rc = arCheckEntries(pAr);
21296 arWhereClause(&rc, pAr, &zWhere);
21298 shellPreparePrintf(pAr->db, &rc, &pSql, zSql, azCols[pAr->bVerbose],
21299 pAr->zSrcTable, zWhere);
21300 if( pAr->bDryRun ){
21301 utf8_printf(pAr->p->out, "%s\n", sqlite3_sql(pSql));
21304 if( pAr->bVerbose ){
21305 utf8_printf(pAr->p->out, "%s % 10d %s %s\n",
21312 utf8_printf(pAr->p->out, "%s\n", sqlite3_column_text(pSql, 0));
21325 static int arRemoveCommand(ArCommand *pAr){
21330 if( pAr->nArg ){
21333 rc = arCheckEntries(pAr);
21334 arWhereClause(&rc, pAr, &zWhere);
21338 pAr->zSrcTable, zWhere);
21339 if( pAr->bDryRun ){
21340 utf8_printf(pAr->p->out, "%s\n", zSql);
21343 rc = sqlite3_exec(pAr->db, "SAVEPOINT ar;", 0, 0, 0);
21345 rc = sqlite3_exec(pAr->db, zSql, 0, 0, &zErr);
21347 sqlite3_exec(pAr->db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0);
21349 rc = sqlite3_exec(pAr->db, "RELEASE ar;", 0, 0, 0);
21366 static int arExtractCommand(ArCommand *pAr){
21388 rc = arCheckEntries(pAr);
21389 arWhereClause(&rc, pAr, &zWhere);
21392 if( pAr->zDir ){
21393 zDir = sqlite3_mprintf("%s/", pAr->zDir);
21400 shellPreparePrintf(pAr->db, &rc, &pSql, zSql1,
21401 azExtraArg[pAr->bZip], pAr->zSrcTable, zWhere
21416 if( pAr->bDryRun ){
21417 utf8_printf(pAr->p->out, "%s\n", sqlite3_sql(pSql));
21420 if( i==0 && pAr->bVerbose ){
21421 utf8_printf(pAr->p->out, "%s\n", sqlite3_column_text(pSql, 0));
21438 static int arExecSql(ArCommand *pAr, const char *zSql){
21440 if( pAr->bDryRun ){
21441 utf8_printf(pAr->p->out, "%s\n", zSql);
21445 rc = sqlite3_exec(pAr->db, zSql, 0, 0, &zErr);
21474 ArCommand *pAr, /* Command arguments and options */
21517 arExecSql(pAr, "PRAGMA page_size=512");
21518 rc = arExecSql(pAr, "SAVEPOINT ar;");
21521 if( pAr->bZip ){
21523 if( pAr->zFile ){
21530 zTab, pAr->zFile
21532 rc = arExecSql(pAr, zSql);
21541 rc = arExecSql(pAr, zDrop);
21544 rc = arExecSql(pAr, zCreate);
21557 for(i=0; i<pAr->nArg && rc==SQLITE_OK; i++){
21558 char *zSql2 = sqlite3_mprintf(zInsertFmt[pAr->bZip], zTab,
21559 pAr->bVerbose ? "shell_putsnl(name)" : "name",
21560 pAr->azArg[i], pAr->zDir, zExists);
21561 rc = arExecSql(pAr, zSql2);
21566 sqlite3_exec(pAr->db, "ROLLBACK TO ar; RELEASE ar;", 0, 0, 0);
21568 rc = arExecSql(pAr, "RELEASE ar;");
21569 if( pAr->bZip && pAr->zFile ){
21571 arExecSql(pAr, zSql);