MCPcopy Create free account
hub / github.com/audacity/audacity / idxPopulateOneStat1

Function idxPopulateOneStat1

lib-src/sqlite/shell.c:9893–9991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9891}
9892
9893static int idxPopulateOneStat1(
9894 sqlite3expert *p,
9895 sqlite3_stmt *pIndexXInfo,
9896 sqlite3_stmt *pWriteStat,
9897 const char *zTab,
9898 const char *zIdx,
9899 char **pzErr
9900){
9901 char *zCols = 0;
9902 char *zOrder = 0;
9903 char *zQuery = 0;
9904 int nCol = 0;
9905 int i;
9906 sqlite3_stmt *pQuery = 0;
9907 int *aStat = 0;
9908 int rc = SQLITE_OK;
9909
9910 assert( p->iSample>0 );
9911
9912 /* Formulate the query text */
9913 sqlite3_bind_text(pIndexXInfo, 1, zIdx, -1, SQLITE_STATIC);
9914 while( SQLITE_OK==rc && SQLITE_ROW==sqlite3_step(pIndexXInfo) ){
9915 const char *zComma = zCols==0 ? "" : ", ";
9916 const char *zName = (const char*)sqlite3_column_text(pIndexXInfo, 0);
9917 const char *zColl = (const char*)sqlite3_column_text(pIndexXInfo, 1);
9918 zCols = idxAppendText(&rc, zCols,
9919 "%sx.%Q IS rem(%d, x.%Q) COLLATE %s", zComma, zName, nCol, zName, zColl
9920 );
9921 zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol);
9922 }
9923 sqlite3_reset(pIndexXInfo);
9924 if( rc==SQLITE_OK ){
9925 if( p->iSample==100 ){
9926 zQuery = sqlite3_mprintf(
9927 "SELECT %s FROM %Q x ORDER BY %s", zCols, zTab, zOrder
9928 );
9929 }else{
9930 zQuery = sqlite3_mprintf(
9931 "SELECT %s FROM temp."UNIQUE_TABLE_NAME" x ORDER BY %s", zCols, zOrder
9932 );
9933 }
9934 }
9935 sqlite3_free(zCols);
9936 sqlite3_free(zOrder);
9937
9938 /* Formulate the query text */
9939 if( rc==SQLITE_OK ){
9940 sqlite3 *dbrem = (p->iSample==100 ? p->db : p->dbv);
9941 rc = idxPrepareStmt(dbrem, &pQuery, pzErr, zQuery);
9942 }
9943 sqlite3_free(zQuery);
9944
9945 if( rc==SQLITE_OK ){
9946 aStat = (int*)idxMalloc(&rc, sizeof(int)*(nCol+1));
9947 }
9948 if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pQuery) ){
9949 IdxHashEntry *pEntry;
9950 char *zStat = 0;

Callers 1

idxPopulateStat1Function · 0.85

Calls 5

idxAppendTextFunction · 0.85
idxPrepareStmtFunction · 0.85
idxMallocFunction · 0.85
idxHashFindFunction · 0.85
idxFinalizeFunction · 0.85

Tested by

no test coverage detected