1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Implement xRename() for fts2 so that it is possible to rename fts2 tables. (CVS 4143)

FossilOrigin-Name: 488474fde753c5a7a14ed8f2fad7f16efd236491
This commit is contained in:
danielk1977
2007-06-27 16:26:07 +00:00
parent 182c4ba979
commit c033b64276
6 changed files with 57 additions and 13 deletions

View File

@@ -5852,6 +5852,30 @@ static int fulltextFindFunction(
return 0;
}
/*
** Rename an fts2 table.
*/
static int fulltextRename(
sqlite3_vtab *pVtab,
const char *zName
){
fulltext_vtab *p = (fulltext_vtab *)pVtab;
int rc = SQLITE_NOMEM;
char *zSql = sqlite3_mprintf(
"ALTER TABLE %Q.'%q_content' RENAME TO '%q_content';"
"ALTER TABLE %Q.'%q_segments' RENAME TO '%q_segments';"
"ALTER TABLE %Q.'%q_segdir' RENAME TO '%q_segdir';"
, p->zDb, p->zName, zName
, p->zDb, p->zName, zName
, p->zDb, p->zName, zName
);
if( zSql ){
rc = sqlite3_exec(p->db, zSql, 0, 0, 0);
sqlite3_free(zSql);
}
return rc;
}
static const sqlite3_module fts2Module = {
/* iVersion */ 0,
/* xCreate */ fulltextCreate,
@@ -5872,6 +5896,7 @@ static const sqlite3_module fts2Module = {
/* xCommit */ fulltextCommit,
/* xRollback */ fulltextRollback,
/* xFindFunction */ fulltextFindFunction,
/* xRename */ fulltextRename,
};
static void hashDestroy(void *p){