** This function is called after the output database has been populated. It ** adds all recovered schema elements that were not created in the output ** database by recoverWriteSchema1() - everything except for tables and ** UNIQUE indexes. Specifically: ** ** * views, ** * triggers, ** * non-UNIQUE indexes. ** ** If the recover handle is in SQL callback mode, then equivalent callbacks
| 14684 | ** are issued to create the schema elements. |
| 14685 | */ |
| 14686 | static int recoverWriteSchema2(sqlite3_recover *p){ |
| 14687 | sqlite3_stmt *pSelect = 0; |
| 14688 | |
| 14689 | pSelect = recoverPrepare(p, p->dbOut, |
| 14690 | p->bSlowIndexes ? |
| 14691 | "SELECT rootpage, sql FROM recovery.schema " |
| 14692 | " WHERE type!='table' AND type!='index'" |
| 14693 | : |
| 14694 | "SELECT rootpage, sql FROM recovery.schema " |
| 14695 | " WHERE type!='table' AND (type!='index' OR sql NOT LIKE '%unique%')" |
| 14696 | ); |
| 14697 | |
| 14698 | if( pSelect ){ |
| 14699 | while( sqlite3_step(pSelect)==SQLITE_ROW ){ |
| 14700 | const char *zSql = (const char*)sqlite3_column_text(pSelect, 1); |
| 14701 | int rc = sqlite3_exec(p->dbOut, zSql, 0, 0, 0); |
| 14702 | if( rc==SQLITE_OK ){ |
| 14703 | recoverSqlCallback(p, zSql); |
| 14704 | }else if( rc!=SQLITE_ERROR ){ |
| 14705 | recoverDbError(p, p->dbOut); |
| 14706 | } |
| 14707 | } |
| 14708 | } |
| 14709 | recoverFinalize(p, pSelect); |
| 14710 | |
| 14711 | return p->errCode; |
| 14712 | } |
| 14713 | |
| 14714 | /* |
| 14715 | ** This function is a no-op if recover handle p already contains an error |
no test coverage detected