@@ -626,7 +626,7 @@ static int expertFilter(
626626 pCsr -> pData = 0 ;
627627 if ( rc == SQLITE_OK ){
628628 rc = idxPrintfPrepareStmt (pExpert -> db , & pCsr -> pData , & pVtab -> base .zErrMsg ,
629- "SELECT * FROM main.%Q WHERE sample ()" , pVtab -> pTab -> zName
629+ "SELECT * FROM main.%Q WHERE sqlite_expert_sample ()" , pVtab -> pTab -> zName
630630 );
631631 }
632632
@@ -1500,7 +1500,7 @@ struct IdxRemCtx {
15001500};
15011501
15021502/*
1503- ** Implementation of scalar function rem ().
1503+ ** Implementation of scalar function sqlite_expert_rem ().
15041504*/
15051505static void idxRemFunc (
15061506 sqlite3_context * pCtx ,
@@ -1513,7 +1513,7 @@ static void idxRemFunc(
15131513 assert ( argc == 2 );
15141514
15151515 iSlot = sqlite3_value_int (argv [0 ]);
1516- assert ( iSlot <= p -> nSlot );
1516+ assert ( iSlot < p -> nSlot );
15171517 pSlot = & p -> aSlot [iSlot ];
15181518
15191519 switch ( pSlot -> eType ){
@@ -1624,7 +1624,8 @@ static int idxPopulateOneStat1(
16241624 const char * zName = (const char * )sqlite3_column_text (pIndexXInfo , 0 );
16251625 const char * zColl = (const char * )sqlite3_column_text (pIndexXInfo , 1 );
16261626 zCols = idxAppendText (& rc , zCols ,
1627- "%sx.%Q IS rem(%d, x.%Q) COLLATE %s" , zComma , zName , nCol , zName , zColl
1627+ "%sx.%Q IS sqlite_expert_rem(%d, x.%Q) COLLATE %s" ,
1628+ zComma , zName , nCol , zName , zColl
16281629 );
16291630 zOrder = idxAppendText (& rc , zOrder , "%s%d" , zComma , ++ nCol );
16301631 }
@@ -1757,13 +1758,13 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
17571758
17581759 if ( rc == SQLITE_OK ){
17591760 sqlite3 * dbrem = (p -> iSample == 100 ? p -> db : p -> dbv );
1760- rc = sqlite3_create_function (
1761- dbrem , "rem" , 2 , SQLITE_UTF8 , (void * )pCtx , idxRemFunc , 0 , 0
1761+ rc = sqlite3_create_function (dbrem , "sqlite_expert_rem" ,
1762+ 2 , SQLITE_UTF8 , (void * )pCtx , idxRemFunc , 0 , 0
17621763 );
17631764 }
17641765 if ( rc == SQLITE_OK ){
1765- rc = sqlite3_create_function (
1766- p -> db , "sample" , 0 , SQLITE_UTF8 , (void * )& samplectx , idxSampleFunc , 0 , 0
1766+ rc = sqlite3_create_function (p -> db , "sqlite_expert_sample" ,
1767+ 0 , SQLITE_UTF8 , (void * )& samplectx , idxSampleFunc , 0 , 0
17671768 );
17681769 }
17691770
@@ -1815,6 +1816,9 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
18151816 rc = sqlite3_exec (p -> dbm , "ANALYZE sqlite_schema" , 0 , 0 , 0 );
18161817 }
18171818
1819+ sqlite3_create_function (p -> db , "sqlite_expert_rem" , 2 , SQLITE_UTF8 , 0 ,0 ,0 ,0 );
1820+ sqlite3_create_function (p -> db , "sqlite_expert_sample" , 0 ,SQLITE_UTF8 ,0 ,0 ,0 ,0 );
1821+
18181822 sqlite3_exec (p -> db , "DROP TABLE IF EXISTS temp." UNIQUE_TABLE_NAME ,0 ,0 ,0 );
18191823 return rc ;
18201824}
0 commit comments