Defer size checking on row-value assignments for when the RHS is a SELECT
until after the "*" wildcards have been expanded. FossilOrigin-Name: 36944be6be5c42096f5da84187ff203af26b08ae
This commit is contained in:
commit
2710b14c45
13
manifest
13
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\stypo\son\sa\scomment.\s\sNo\scode\schanges.
|
||||
D 2017-01-03T11:59:54.675
|
||||
C Defer\ssize\schecking\son\srow-value\sassignments\sfor\swhen\sthe\sRHS\sis\sa\sSELECT\nuntil\safter\sthe\s"*"\swildcards\shave\sbeen\sexpanded.
|
||||
D 2017-01-03T13:45:22.450
|
||||
F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da
|
||||
@ -341,7 +341,7 @@ F src/ctime.c 9f2296a4e5d26ebf0e0d95a0af4628f1ea694e7a
|
||||
F src/date.c dc3f1391d9297f8c748132813aaffcb117090d6e
|
||||
F src/dbstat.c 19ee7a4e89979d4df8e44cfac7a8f905ec89b77d
|
||||
F src/delete.c c8bc10d145c9666a34ae906250326fdaa8d58fa5
|
||||
F src/expr.c b5f55c29553c762b5d3ae3768b95b5d4e8c0303f
|
||||
F src/expr.c 59418cecc99adfb5cdd6c088ff38c1dde827e077
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c 2e9aabe1aee76273aff8a84ee92c464e095400ae
|
||||
F src/func.c d8582ee91975975645f206db332c38f534b783ad
|
||||
@ -1541,7 +1541,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P 548532fdcf84d565c17aed79a6b595e8b62a3ab4
|
||||
R d91f1b1dc02838ee4304e6741bf506fa
|
||||
P abc27b6023e28a717bfa15648ddc152bda9c7b96 696219b11049930cdbc38f574820f4bbaf8621bb
|
||||
R 8e229780f94246cbc66f37b63195235a
|
||||
T +closed 696219b11049930cdbc38f574820f4bbaf8621bb
|
||||
U drh
|
||||
Z a4929362969af97c45531df857286989
|
||||
Z c02d09c2f2bfe5e823a2e301838383db
|
||||
|
@ -1 +1 @@
|
||||
abc27b6023e28a717bfa15648ddc152bda9c7b96
|
||||
36944be6be5c42096f5da84187ff203af26b08ae
|
36
src/expr.c
36
src/expr.c
@ -414,9 +414,10 @@ Expr *sqlite3ExprForVectorField(
|
||||
assert( pVector->flags & EP_xIsSelect );
|
||||
/* The TK_SELECT_COLUMN Expr node:
|
||||
**
|
||||
** pLeft: pVector containing TK_SELECT
|
||||
** pLeft: pVector containing TK_SELECT. Not deleted.
|
||||
** pRight: not used. But recursively deleted.
|
||||
** iColumn: Index of a column in pVector
|
||||
** iTable: 0 or the number of columns on the LHS of an assignment
|
||||
** pLeft->iTable: First in an array of register holding result, or 0
|
||||
** if the result is not yet computed.
|
||||
**
|
||||
@ -1519,13 +1520,19 @@ ExprList *sqlite3ExprListAppendVector(
|
||||
** exit prior to this routine being invoked */
|
||||
if( NEVER(pColumns==0) ) goto vector_append_error;
|
||||
if( pExpr==0 ) goto vector_append_error;
|
||||
n = sqlite3ExprVectorSize(pExpr);
|
||||
if( pColumns->nId!=n ){
|
||||
|
||||
/* If the RHS is a vector, then we can immediately check to see that
|
||||
** the size of the RHS and LHS match. But if the RHS is a SELECT,
|
||||
** wildcards ("*") in the result set of the SELECT must be expanded before
|
||||
** we can do the size check, so defer the size check until code generation.
|
||||
*/
|
||||
if( pExpr->op!=TK_SELECT && pColumns->nId!=(n=sqlite3ExprVectorSize(pExpr)) ){
|
||||
sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
|
||||
pColumns->nId, n);
|
||||
goto vector_append_error;
|
||||
}
|
||||
for(i=0; i<n; i++){
|
||||
|
||||
for(i=0; i<pColumns->nId; i++){
|
||||
Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
|
||||
pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
|
||||
if( pList ){
|
||||
@ -1534,11 +1541,20 @@ ExprList *sqlite3ExprListAppendVector(
|
||||
pColumns->a[i].zName = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if( pExpr->op==TK_SELECT ){
|
||||
if( pList && pList->a[iFirst].pExpr ){
|
||||
assert( pList->a[iFirst].pExpr->op==TK_SELECT_COLUMN );
|
||||
pList->a[iFirst].pExpr->pRight = pExpr;
|
||||
Expr *pFirst = pList->a[iFirst].pExpr;
|
||||
assert( pFirst->op==TK_SELECT_COLUMN );
|
||||
|
||||
/* Store the SELECT statement in pRight so it will be deleted when
|
||||
** sqlite3ExprListDelete() is called */
|
||||
pFirst->pRight = pExpr;
|
||||
pExpr = 0;
|
||||
|
||||
/* Remember the size of the LHS in iTable so that we can check that
|
||||
** the RHS and LHS sizes match during code generation. */
|
||||
pFirst->iTable = pColumns->nId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3732,9 +3748,17 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
||||
break;
|
||||
}
|
||||
case TK_SELECT_COLUMN: {
|
||||
int n;
|
||||
if( pExpr->pLeft->iTable==0 ){
|
||||
pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft, 0, 0);
|
||||
}
|
||||
assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT );
|
||||
if( pExpr->iTable
|
||||
&& pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
|
||||
){
|
||||
sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
|
||||
pExpr->iTable, n);
|
||||
}
|
||||
return pExpr->pLeft->iTable + pExpr->iColumn;
|
||||
}
|
||||
case TK_IN: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user