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:
@@ -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){
|
||||
|
Reference in New Issue
Block a user