1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-12 13:01:09 +03:00

Avoid unnecessary affinity transformations when building indices using

data from a table.

FossilOrigin-Name: 10d851353c2abeadbd2852c210a7ff9f7f513e5d
This commit is contained in:
drh
2014-01-02 19:35:30 +00:00
parent 991a198511
commit 762c1c4071
7 changed files with 29 additions and 22 deletions

View File

@@ -784,18 +784,18 @@ int sqlite3GenerateIndexKey(
for(j=0; j<nCol; j++){
sqlite3ExprCodeGetColumnOfTable(v, pTab, iDataCur, pIdx->aiColumn[j],
regBase+j);
/* If the column affinity is REAL but the number is an integer, then it
** might be stored in the table as an integer (using a compact
** representation) then converted to REAL by an OP_RealAffinity opcode.
** But we are getting ready to store this value back into an index, where
** it should be converted by to INTEGER again. So omit the OP_RealAffinity
** opcode if it is present */
if( sqlite3VdbeGetOp(v, -1)->opcode==OP_RealAffinity ){
sqlite3VdbeDeleteLastOpcode(v);
}
}
if( regOut ){
const char *zAff;
if( pTab->pSelect
|| OptimizationDisabled(pParse->db, SQLITE_IdxRealAsInt)
){
zAff = 0;
}else{
zAff = sqlite3IndexAffinityStr(v, pIdx);
}
sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol, regOut);
sqlite3VdbeChangeP4(v, -1, zAff, P4_TRANSIENT);
}
sqlite3ReleaseTempRange(pParse, regBase, nCol);
return regBase;