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

Performance optimization in the code generator for INSERT for the common

case where the target table has neither generated nor hidden columns.
Also fix a redundant (and thus unreachable) branch in the resolver.

FossilOrigin-Name: 16ac213c57196361a9d14df4c0d1ccc6f67ac522365b345ea364d1aec61fa3f2
This commit is contained in:
drh
2021-02-18 00:26:11 +00:00
parent c54246ffdf
commit c7e93f58d5
4 changed files with 23 additions and 21 deletions

View File

@@ -930,19 +930,21 @@ void sqlite3Insert(
}
}
#endif
}
/* Make sure the number of columns in the source data matches the number
** of columns to be inserted into the table.
*/
for(i=0; i<pTab->nCol; i++){
if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ) nHidden++;
}
if( pColumn==0 && nColumn && nColumn!=(pTab->nCol-nHidden) ){
sqlite3ErrorMsg(pParse,
"table %S has %d columns but %d values were supplied",
pTabList, 0, pTab->nCol-nHidden, nColumn);
goto insert_cleanup;
/* Make sure the number of columns in the source data matches the number
** of columns to be inserted into the table.
*/
if( IsVirtual(pTab) || (pTab->tabFlags & TF_HasGenerated)!=0 ){
for(i=0; i<pTab->nCol; i++){
if( pTab->aCol[i].colFlags & COLFLAG_NOINSERT ) nHidden++;
}
}
if( nColumn!=(pTab->nCol-nHidden) ){
sqlite3ErrorMsg(pParse,
"table %S has %d columns but %d values were supplied",
pTabList, 0, pTab->nCol-nHidden, nColumn);
goto insert_cleanup;
}
}
if( pColumn!=0 && nColumn!=pColumn->nId ){
sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId);