aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <>2024-03-18 12:49:30 +0000
committerdrh <>2024-03-18 12:49:30 +0000
commit27a5ee855d6428246ea7fc9511a2a10a85c3199c (patch)
tree6553c78a8855c593e257bde89219fdab882bdf6b /src
parent75924d3ae22587cac6c68caad9212a7621e47135 (diff)
downloadsqlite-27a5ee855d6428246ea7fc9511a2a10a85c3199c.tar.gz
sqlite-27a5ee855d6428246ea7fc9511a2a10a85c3199c.zip
Improvements to EXPLAIN QUERY PLAN output for multi-row VALUES claues.
FossilOrigin-Name: ac6f095e13e43d66c06552c8b01f6bec3407c9d41a34c4cdb0be57b0b828ad0d
Diffstat (limited to 'src')
-rw-r--r--src/insert.c4
-rw-r--r--src/printf.c3
-rw-r--r--src/sqliteInt.h1
-rw-r--r--src/where.c6
4 files changed, 13 insertions, 1 deletions
diff --git a/src/insert.c b/src/insert.c
index 7d386f5d2..7256281fd 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -721,6 +721,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){
p->addrFillSub = sqlite3VdbeCurrentAddr(v) + 1;
p->regReturn = ++pParse->nMem;
p->iCursor = -1;
+ p->u1.nRow = 2;
sqlite3VdbeAddOp3(v,OP_InitCoroutine,p->regReturn,0,p->addrFillSub);
sqlite3SelectDestInit(&dest, SRT_Coroutine, p->regReturn);
@@ -733,6 +734,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){
dest.nSdst = pLeft->pEList->nExpr;
pParse->nMem += 2 + dest.nSdst;
+ pLeft->selFlags |= SF_MultiValue;
sqlite3Select(pParse, pLeft, &dest);
p->regResult = dest.iSdst;
assert( pParse->nErr || dest.iSdst>0 );
@@ -740,6 +742,7 @@ Select *sqlite3MultiValues(Parse *pParse, Select *pLeft, ExprList *pRow){
}
}else{
p = &pLeft->pSrc->a[0];
+ p->u1.nRow++;
}
if( pParse->nErr==0 ){
@@ -1102,6 +1105,7 @@ void sqlite3Insert(
dest.iSDParm = regYield = pItem->regReturn;
regFromSelect = pItem->regResult;
nColumn = pItem->pSelect->pEList->nExpr;
+ ExplainQueryPlan((pParse, 0, "SCAN %S", pItem));
if( bIdListInOrder && nColumn==pTab->nCol ){
regData = regFromSelect;
regRowid = regData - 1;
diff --git a/src/printf.c b/src/printf.c
index 186e95bb8..0aea74e89 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -860,6 +860,9 @@ void sqlite3_str_vappendf(
assert( pSel!=0 );
if( pSel->selFlags & SF_NestedFrom ){
sqlite3_str_appendf(pAccum, "(join-%u)", pSel->selId);
+ }else if( pSel->selFlags & SF_MultiValue ){
+ sqlite3_str_appendf(pAccum, "%u-ROW VALUES CLAUSE",
+ pItem->u1.nRow);
}else{
sqlite3_str_appendf(pAccum, "(subquery-%u)", pSel->selId);
}
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index 54fe9458f..01a512649 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -3311,6 +3311,7 @@ struct SrcItem {
union {
char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */
ExprList *pFuncArg; /* Arguments to table-valued-function */
+ u32 nRow; /* Number of rows in a VALUES clause */
} u1;
union {
Index *pIBIndex; /* Index structure corresponding to u1.zIndexedBy */
diff --git a/src/where.c b/src/where.c
index 2a99c7398..2463e823c 100644
--- a/src/where.c
+++ b/src/where.c
@@ -6144,7 +6144,11 @@ WhereInfo *sqlite3WhereBegin(
){
pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
}
- ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
+ if( ALWAYS(pWInfo->pSelect)
+ && (pWInfo->pSelect->selFlags & SF_MultiValue)==0
+ ){
+ ExplainQueryPlan((pParse, 0, "SCAN CONSTANT ROW"));
+ }
}else{
/* Assign a bit from the bitmask to every term in the FROM clause.
**