aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordrh <>2021-02-18 00:26:11 +0000
committerdrh <>2021-02-18 00:26:11 +0000
commitc7e93f58d500971f531215ea96ed99a92144acdf (patch)
tree5d3e084c88b476bbefc3b6218abac41765e809ad /src/insert.c
parentc54246ffdf51ae0af4d9e39c653571e6e6586cc6 (diff)
downloadsqlite-c7e93f58d500971f531215ea96ed99a92144acdf.tar.gz
sqlite-c7e93f58d500971f531215ea96ed99a92144acdf.zip
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
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/insert.c b/src/insert.c
index 7522a7269..3469ee1ea 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -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);