aboutsummaryrefslogtreecommitdiff
path: root/src/insert.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-01-10 20:46:55 +0000
committerdrh <drh@noemail.net>2014-01-10 20:46:55 +0000
commit75593d96be4062a3fd6cf86135b945e95367b10b (patch)
treeebf32c3c53072f8fee20f451a1664006a17b43d4 /src/insert.c
parentc740752470a0557b03299c5fd5036e5e096b78e3 (diff)
downloadsqlite-75593d96be4062a3fd6cf86135b945e95367b10b.tar.gz
sqlite-75593d96be4062a3fd6cf86135b945e95367b10b.zip
Allow a VALUES clause to be used any place that a SELECT statement can be
used. FossilOrigin-Name: c9ea7d199f06a7801ab639e7ac98ebeb98706f24
Diffstat (limited to 'src/insert.c')
-rw-r--r--src/insert.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/insert.c b/src/insert.c
index abc34c03c..038d08a40 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -540,7 +540,6 @@ static int xferOptimization(
void sqlite3Insert(
Parse *pParse, /* Parser context */
SrcList *pTabList, /* Name of table into which we are inserting */
- ExprList *pList, /* List of values to be inserted */
Select *pSelect, /* A SELECT statement to use as the data source */
IdList *pColumn, /* Column names corresponding to IDLIST. */
int onError /* How to handle constraint errors */
@@ -568,6 +567,7 @@ void sqlite3Insert(
Db *pDb; /* The database containing table being inserted into */
int appendFlag = 0; /* True if the insert is likely to be an append */
int withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
+ ExprList *pList = 0; /* List of VALUES() to be inserted */
/* Register allocations */
int regFromSelect = 0;/* Base register for data coming from SELECT */
@@ -591,6 +591,17 @@ void sqlite3Insert(
goto insert_cleanup;
}
+ /* If the Select object is really just a simple VALUES() list with a
+ ** single row values (the common case) then keep that one row of values
+ ** and go ahead and discard the Select object
+ */
+ if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){
+ pList = pSelect->pEList;
+ pSelect->pEList = 0;
+ sqlite3SelectDelete(db, pSelect);
+ pSelect = 0;
+ }
+
/* Locate the table into which we will be inserting new information.
*/
assert( pTabList->nSrc==1 );