diff options
author | drh <drh@noemail.net> | 2019-10-16 12:18:59 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-10-16 12:18:59 +0000 |
commit | 81f7b372700d7595f486d364a26304b052eda55a (patch) | |
tree | 9662aac9b19cccaba23c8dce443eb4962b59363a /src/expr.c | |
parent | 4ec3e820a00c5372972a0f1b143b2797b21ffb9f (diff) | |
download | sqlite-81f7b372700d7595f486d364a26304b052eda55a.tar.gz sqlite-81f7b372700d7595f486d364a26304b052eda55a.zip |
Initial experimental code for generated column support. Non-functional.
FossilOrigin-Name: 11d472c1df707b8d03ec57d8fc582a34f5eb89a9d02a154a9871650c65065b45
Diffstat (limited to 'src/expr.c')
-rw-r--r-- | src/expr.c | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/expr.c b/src/expr.c index 0e827482b..fea7b0a18 100644 --- a/src/expr.c +++ b/src/expr.c @@ -3365,7 +3365,7 @@ void sqlite3ExprCodeLoadIndexColumn( sqlite3ExprCodeCopy(pParse, pIdx->aColExpr->a[iIdxCol].pExpr, regOut); pParse->iSelfTab = 0; }else{ - sqlite3ExprCodeGetColumnOfTable(pParse->pVdbe, pIdx->pTable, iTabCur, + sqlite3ExprCodeGetColumnOfTable(pParse, pIdx->pTable, iTabCur, iTabCol, regOut); } } @@ -3374,12 +3374,14 @@ void sqlite3ExprCodeLoadIndexColumn( ** Generate code to extract the value of the iCol-th column of a table. */ void sqlite3ExprCodeGetColumnOfTable( - Vdbe *v, /* The VDBE under construction */ + Parse *pParse, /* Parsing context */ Table *pTab, /* The table containing the value */ int iTabCur, /* The table cursor. Or the PK cursor for WITHOUT ROWID */ int iCol, /* Index of the column to extract */ int regOut /* Extract the value into this register */ ){ + Vdbe *v = pParse->pVdbe; + assert( v!=0 ); if( pTab==0 ){ sqlite3VdbeAddOp3(v, OP_Column, iTabCur, iCol, regOut); return; @@ -3387,10 +3389,25 @@ void sqlite3ExprCodeGetColumnOfTable( if( iCol<0 || iCol==pTab->iPKey ){ sqlite3VdbeAddOp2(v, OP_Rowid, iTabCur, regOut); }else{ - int op = IsVirtual(pTab) ? OP_VColumn : OP_Column; - int x = iCol; - if( !HasRowid(pTab) && !IsVirtual(pTab) ){ + int op; + int x; + if( IsVirtual(pTab) ){ + op = OP_VColumn; + x = iCol; +#ifndef SQLITE_OMIT_GENERATED_COLUMNS + }else if( pTab->aCol[iCol].colFlags & COLFLAG_VIRTUAL ){ + int savedSelfTab = pParse->iSelfTab; + pParse->iSelfTab = iTabCur+1; + sqlite3ExprCode(pParse, pTab->aCol[iCol].pDflt, iCol); + pParse->iSelfTab = savedSelfTab; + return; +#endif + }else if( !HasRowid(pTab) ){ x = sqlite3ColumnOfIndex(sqlite3PrimaryKeyIndex(pTab), iCol); + op = OP_Column; + }else{ + x = sqlite3ColumnOfTable(pTab,iCol); + op = OP_Column; } sqlite3VdbeAddOp3(v, op, iTabCur, x, regOut); } @@ -3414,11 +3431,10 @@ int sqlite3ExprCodeGetColumn( int iReg, /* Store results here */ u8 p5 /* P5 value for OP_Column + FLAGS */ ){ - Vdbe *v = pParse->pVdbe; - assert( v!=0 ); - sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg); + assert( pParse->pVdbe!=0 ); + sqlite3ExprCodeGetColumnOfTable(pParse, pTab, iTable, iColumn, iReg); if( p5 ){ - sqlite3VdbeChangeP5(v, p5); + sqlite3VdbeChangeP5(pParse->pVdbe, p5); } return iReg; } |