MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / arWhereClause

Function arWhereClause

modules/dasSQLITE/sqlite/shell.c:22230–22258  ·  view source on GitHub ↗

** Format a WHERE clause that can be used against the "sqlar" table to ** identify all archive members that match the command arguments held ** in (*pAr). Leave this WHERE clause in (*pzWhere) before returning. ** The caller is responsible for eventually calling sqlite3_free() on ** any non-NULL (*pzWhere) value. Here, "match" means strict equality ** when pAr->bGlob is false and GLOB match when p

Source from the content-addressed store, hash-verified

22228** when pAr->bGlob is false and GLOB match when pAr->bGlob is true.
22229*/
22230static void arWhereClause(
22231 int *pRc,
22232 ArCommand *pAr,
22233 char **pzWhere /* OUT: New WHERE clause */
22234){
22235 char *zWhere = 0;
22236 const char *zSameOp = (pAr->bGlob)? "GLOB" : "=";
22237 if( *pRc==SQLITE_OK ){
22238 if( pAr->nArg==0 ){
22239 zWhere = sqlite3_mprintf("1");
22240 }else{
22241 int i;
22242 const char *zSep = "";
22243 for(i=0; i<pAr->nArg; i++){
22244 const char *z = pAr->azArg[i];
22245 zWhere = sqlite3_mprintf(
22246 "%z%s name %s '%q' OR substr(name,1,%d) %s '%q/'",
22247 zWhere, zSep, zSameOp, z, strlen30(z)+1, zSameOp, z
22248 );
22249 if( zWhere==0 ){
22250 *pRc = SQLITE_NOMEM;
22251 break;
22252 }
22253 zSep = " OR ";
22254 }
22255 }
22256 }
22257 *pzWhere = zWhere;
22258}
22259
22260/*
22261** Implementation of .ar "lisT" command.

Callers 3

arListCommandFunction · 0.85
arRemoveCommandFunction · 0.85
arExtractCommandFunction · 0.85

Calls 1

strlen30Function · 0.85

Tested by

no test coverage detected