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

Simple INSERT and SELECT operations working with VIRTUAL columns.

FossilOrigin-Name: 7f9f90b1b885fa9905b296f2e0fcc9b2341019b42fc839722a93cf60e49a9252
This commit is contained in:
drh
2019-10-16 19:31:46 +00:00
parent 81f7b37270
commit 7e508f1ee2
7 changed files with 33 additions and 24 deletions

View File

@@ -37,7 +37,8 @@ void sqlite3OpenTable(
sqlite3TableLock(pParse, iDb, pTab->tnum,
(opcode==OP_OpenWrite)?1:0, pTab->zName);
if( HasRowid(pTab) ){
sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nCol);
sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb,
pTab->nCol - pTab->nVCol);
VdbeComment((v, "%s", pTab->zName));
}else{
Index *pPk = sqlite3PrimaryKeyIndex(pTab);
@@ -673,6 +674,14 @@ void sqlite3Insert(
if( j==pTab->iPKey ){
ipkColumn = i; assert( !withoutRowid );
}
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
sqlite3ErrorMsg(pParse,
"cannot INSERT into generated column \"%s\"",
pTab->aCol[j].zName);
goto insert_cleanup;
}
#endif
break;
}
}
@@ -788,7 +797,7 @@ void sqlite3Insert(
** of columns to be inserted into the table.
*/
for(i=0; i<pTab->nCol; i++){
nHidden += (IsHiddenColumn(&pTab->aCol[i]) ? 1 : 0);
if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ) nHidden++;
}
if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){
sqlite3ErrorMsg(pParse,
@@ -1006,9 +1015,12 @@ void sqlite3Insert(
continue;
}
if( pColumn==0 ){
if( IsHiddenColumn(&pTab->aCol[i]) ){
if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ){
j = -1;
nHidden++;
if( pTab->aCol[i].colFlags & COLFLAG_VIRTUAL ){
continue;
}
}else{
j = i - nHidden;
}
@@ -1862,7 +1874,8 @@ void sqlite3GenerateConstraintChecks(
/* Generate the table record */
if( HasRowid(pTab) ){
int regRec = aRegIdx[ix];
sqlite3VdbeAddOp3(v, OP_MakeRecord, regNewData+1, pTab->nCol, regRec);
sqlite3VdbeAddOp3(v, OP_MakeRecord, regNewData+1,
pTab->nCol-pTab->nVCol, regRec);
sqlite3SetMakeRecordP5(v, pTab);
if( !bAffinityDone ){
sqlite3TableAffinity(v, pTab, 0);