1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Change the fts5 content= option so that it matches fts5 columns with the underlying table columns by name, not by their position within the CREATE TABLE statement.

FossilOrigin-Name: e38e2bb637844dae8ae5d5f3e23d8369e1b91e45
This commit is contained in:
dan
2015-04-27 16:21:49 +00:00
parent c1cea8f731
commit a3bdec7ee4
9 changed files with 146 additions and 22 deletions

View File

@ -370,7 +370,7 @@ static int fts5ConfigParseSpecial(
*pzErr = sqlite3_mprintf("multiple content_rowid=... directives");
rc = SQLITE_ERROR;
}else{
pConfig->zContentRowid = fts5EscapeName(&rc, zArg);
pConfig->zContentRowid = fts5Strdup(&rc, zArg);
}
return rc;
}
@ -469,6 +469,31 @@ static int fts5ConfigParseColumn(
return rc;
}
/*
** Populate the Fts5Config.zContentExprlist string.
*/
static int fts5ConfigMakeExprlist(Fts5Config *p){
int i;
int rc = SQLITE_OK;
Fts5Buffer buf = {0, 0, 0};
const char *zSep = "";
sqlite3Fts5BufferAppendPrintf(&rc, &buf, "T.%Q", p->zContentRowid);
if( p->eContent!=FTS5_CONTENT_NONE ){
for(i=0; i<p->nCol; i++){
if( p->eContent==FTS5_CONTENT_EXTERNAL ){
sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.%Q", p->azCol[i]);
}else{
sqlite3Fts5BufferAppendPrintf(&rc, &buf, ", T.c%d", i);
}
}
}
assert( p->zContentExprlist==0 );
p->zContentExprlist = (char*)buf.p;
return rc;
}
/*
** Arguments nArg/azArg contain the string arguments passed to the xCreate
** or xConnect method of the virtual table. This function attempts to
@ -571,6 +596,11 @@ int sqlite3Fts5ConfigParse(
pRet->zContentRowid = fts5Strdup(&rc, "rowid");
}
/* Formulate the zContentExprlist text */
if( rc==SQLITE_OK ){
rc = fts5ConfigMakeExprlist(pRet);
}
if( rc!=SQLITE_OK ){
sqlite3Fts5ConfigFree(pRet);
*ppOut = 0;
@ -598,6 +628,7 @@ void sqlite3Fts5ConfigFree(Fts5Config *pConfig){
sqlite3_free(pConfig->zRankArgs);
sqlite3_free(pConfig->zContent);
sqlite3_free(pConfig->zContentRowid);
sqlite3_free(pConfig->zContentExprlist);
sqlite3_free(pConfig);
}
}