diff options
author | drh <drh@noemail.net> | 2019-10-26 18:47:47 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-10-26 18:47:47 +0000 |
commit | a88c8c1ae4f6e44f52096f0f17203dc20f8bb900 (patch) | |
tree | a9d8a1451df471d0397345db416b702368450e1a /src/fkey.c | |
parent | cbda9c7ac79f8751e18fba943e30fd67f8c68b02 (diff) | |
parent | 1b22c1b8168ce18d5582fc0004369ecef8f7d939 (diff) | |
download | sqlite-a88c8c1ae4f6e44f52096f0f17203dc20f8bb900.tar.gz sqlite-a88c8c1ae4f6e44f52096f0f17203dc20f8bb900.zip |
Add support for generated columns.
FossilOrigin-Name: b855acf1831943b3914491ed0bc333131321930cab480a5281012a3aebbba492
Diffstat (limited to 'src/fkey.c')
-rw-r--r-- | src/fkey.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/fkey.c b/src/fkey.c index 1b86692da..c57fb1465 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -349,7 +349,7 @@ static void fkLookupParent( VdbeCoverage(v); } for(i=0; i<pFKey->nCol; i++){ - int iReg = aiCol[i] + regData + 1; + int iReg = sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[i]) + regData + 1; sqlite3VdbeAddOp2(v, OP_IsNull, iReg, iOk); VdbeCoverage(v); } @@ -365,7 +365,8 @@ static void fkLookupParent( ** is no matching parent key. Before using MustBeInt, make a copy of ** the value. Otherwise, the value inserted into the child key column ** will have INTEGER affinity applied to it, which may not be correct. */ - sqlite3VdbeAddOp2(v, OP_SCopy, aiCol[0]+1+regData, regTemp); + sqlite3VdbeAddOp2(v, OP_SCopy, + sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[0])+1+regData, regTemp); iMustBeInt = sqlite3VdbeAddOp2(v, OP_MustBeInt, regTemp, 0); VdbeCoverage(v); @@ -392,7 +393,9 @@ static void fkLookupParent( sqlite3VdbeAddOp3(v, OP_OpenRead, iCur, pIdx->tnum, iDb); sqlite3VdbeSetP4KeyInfo(pParse, pIdx); for(i=0; i<nCol; i++){ - sqlite3VdbeAddOp2(v, OP_Copy, aiCol[i]+1+regData, regTemp+i); + sqlite3VdbeAddOp2(v, OP_Copy, + sqlite3TableColumnToStorage(pFKey->pFrom, aiCol[i])+1+regData, + regTemp+i); } /* If the parent table is the same as the child table, and we are about @@ -408,8 +411,11 @@ static void fkLookupParent( if( pTab==pFKey->pFrom && nIncr==1 ){ int iJump = sqlite3VdbeCurrentAddr(v) + nCol + 1; for(i=0; i<nCol; i++){ - int iChild = aiCol[i]+1+regData; - int iParent = pIdx->aiColumn[i]+1+regData; + int iChild = sqlite3TableColumnToStorage(pFKey->pFrom,aiCol[i]) + +1+regData; + int iParent = 1+regData; + iParent += sqlite3TableColumnToStorage(pIdx->pTable, + pIdx->aiColumn[i]); assert( pIdx->aiColumn[i]>=0 ); assert( aiCol[i]!=pTab->iPKey ); if( pIdx->aiColumn[i]==pTab->iPKey ){ |