mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Add support for the "excluded.*" names in the UPDATE clause of an upsert.
FossilOrigin-Name: 0203f34faae07fbea0bff2d23b81fb37df8854cded4cdadac5a034132a096b6d
This commit is contained in:
24
manifest
24
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Merge\schanges\sfrom\strunk.
|
C Add\ssupport\sfor\sthe\s"excluded.*"\snames\sin\sthe\sUPDATE\sclause\sof\san\supsert.
|
||||||
D 2018-04-16T10:47:38.084
|
D 2018-04-16T13:00:50.958
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
|
F Makefile.in 5ce9343cba9c189046f1afe6d2bcc1f68079439febc05267b98aec6ecc752439
|
||||||
@@ -452,7 +452,7 @@ F src/hash.c a12580e143f10301ed5166ea4964ae2853d3905a511d4e0c44497245c7ce1f7a
|
|||||||
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
|
F src/hash.h ab34c5c54a9e9de2e790b24349ba5aab3dbb4fd4
|
||||||
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
|
F src/hwtime.h 747c1bbe9df21a92e9c50f3bbec1de841dc5e5da
|
||||||
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
|
||||||
F src/insert.c be6ece1650d14f4aa850786f7e08376fc16841423b273759167584c4cd0fda0a
|
F src/insert.c 33f002c748fcb3be71d23641200c96b0c5c08e04d056f4fb874897ea9473e7e0
|
||||||
F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e
|
F src/legacy.c 134ab3e3fae00a0f67a5187981d6935b24b337bcf0f4b3e5c9fa5763da95bf4e
|
||||||
F src/loadext.c f6e4e416a736369f9e80eba609f0acda97148a8b0453784d670c78d3eed2f302
|
F src/loadext.c f6e4e416a736369f9e80eba609f0acda97148a8b0453784d670c78d3eed2f302
|
||||||
F src/main.c 1648fc7a9bcfdbfd9a9a04af96ff2796c3164b3f3c7e56ed63a3c51cd11d198d
|
F src/main.c 1648fc7a9bcfdbfd9a9a04af96ff2796c3164b3f3c7e56ed63a3c51cd11d198d
|
||||||
@@ -480,7 +480,7 @@ F src/os_win.c eb03c6d52f893bcd7fdd4c6006674c13c1b5e49543fec98d605201af2997171c
|
|||||||
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
|
||||||
F src/pager.c 1bb6a57fa0465296a4d6109a1a64610a0e7adde1f3acf3ef539a9d972908ce8f
|
F src/pager.c 1bb6a57fa0465296a4d6109a1a64610a0e7adde1f3acf3ef539a9d972908ce8f
|
||||||
F src/pager.h c571b064df842ec8f2e90855dead9acf4cbe0d1b2c05afe0ef0d0145f7fd0388
|
F src/pager.h c571b064df842ec8f2e90855dead9acf4cbe0d1b2c05afe0ef0d0145f7fd0388
|
||||||
F src/parse.y 5fde091c63a99b6f0867b03a4b1941b862c8866aa91478b78dca84ff24b535ac
|
F src/parse.y 22da8d033498cb10f1a74e7a9e48359fd1f0fb5d34298f8232d972df68dbe797
|
||||||
F src/pcache.c 135ef0bc6fb2e3b7178d49ab5c9176254c8a691832c1bceb1156b2fbdd0869bd
|
F src/pcache.c 135ef0bc6fb2e3b7178d49ab5c9176254c8a691832c1bceb1156b2fbdd0869bd
|
||||||
F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170
|
F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170
|
||||||
F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880
|
F src/pcache1.c 716975564c15eb6679e97f734cec1bfd6c16ac3d4010f05f1f8e509fc7d19880
|
||||||
@@ -489,14 +489,14 @@ F src/pragma.h bb83728944b42f6d409c77f5838a8edbdb0fe83046c5496ffc9602b40340a324
|
|||||||
F src/prepare.c b086fea6a1952db88beca31fdd621201ee5e4ce3f02905248cc3035a8174aa89
|
F src/prepare.c b086fea6a1952db88beca31fdd621201ee5e4ce3f02905248cc3035a8174aa89
|
||||||
F src/printf.c d3b7844ddeb11fbbdd38dd84d09c9c1ac171d21fb038473c3aa97981201cc660
|
F src/printf.c d3b7844ddeb11fbbdd38dd84d09c9c1ac171d21fb038473c3aa97981201cc660
|
||||||
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
|
||||||
F src/resolve.c 515ffc6678e47185a77f4fb724d934a29b991c84bf261980001e254e5e6e61ad
|
F src/resolve.c 16715d4fe35694a6992335fc2896a90c3bc2f8328cefc25592cdfec824218678
|
||||||
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac
|
||||||
F src/select.c 3e84cb869930aa8fcacd3acbb1a0ec2d82736c8479d6a4367a5f1a926fb8a763
|
F src/select.c 3e84cb869930aa8fcacd3acbb1a0ec2d82736c8479d6a4367a5f1a926fb8a763
|
||||||
F src/shell.c.in cc960721e56ebc1a78773bb5d2f5608b54275f945cbe49e4afe919d6888062a7
|
F src/shell.c.in cc960721e56ebc1a78773bb5d2f5608b54275f945cbe49e4afe919d6888062a7
|
||||||
F src/sqlite.h.in e0be726ea6e4e6571724d39d242472ecd8bd1ba6f84ade88e1641bde98a6d02b
|
F src/sqlite.h.in e0be726ea6e4e6571724d39d242472ecd8bd1ba6f84ade88e1641bde98a6d02b
|
||||||
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
|
||||||
F src/sqlite3ext.h 83a3c4ce93d650bedfd1aa558cb85a516bd6d094445ee989740827d0d944368d
|
F src/sqlite3ext.h 83a3c4ce93d650bedfd1aa558cb85a516bd6d094445ee989740827d0d944368d
|
||||||
F src/sqliteInt.h 1e32dd08eac0f988f775fa33015d12666f443a0e4eabf3b490cf41aad0b611de
|
F src/sqliteInt.h 39ba44080f8cd5c6d46a6bf5b636d44cecbbd9b23a166c5dbf40d7b96c8c0763
|
||||||
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
|
F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b
|
||||||
F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
|
F src/status.c 46e7aec11f79dad50965a5ca5fa9de009f7d6bde08be2156f1538a0a296d4d0e
|
||||||
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34
|
||||||
@@ -555,9 +555,9 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9
|
|||||||
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
|
F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c
|
||||||
F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2
|
F src/tokenize.c 5b0c661a85f783d35b9883830736eeb63be4aefc4f6b7d9cd081d48782c041e2
|
||||||
F src/treeview.c 14d5d1254702ec96876aa52642cb31548612384134970409fae333b25b39d6bb
|
F src/treeview.c 14d5d1254702ec96876aa52642cb31548612384134970409fae333b25b39d6bb
|
||||||
F src/trigger.c 00ef0b16ab3f0063439e6582086f57f3beb93cd7e7ba46569a8bdc490c16283d
|
F src/trigger.c fcb566b0df7bdefed4bff7e31aa7efa1c77cc0549e4ac79879d69490208ff966
|
||||||
F src/update.c f5210fb55d26e20d14d0106c9479a83c63a005b70b1b5291481c48d6dac6fb9f
|
F src/update.c 5787acf0a12a20cf31c0c50db644a667590f720e404b3616bc2efeb9bd5bbc06
|
||||||
F src/upsert.c 3baeab51df965e8442ff0c338be89d1b940f0e56cfe2b0a59ef90b4bb5f55da2
|
F src/upsert.c 5d9491412105e06a69e98e51c88835eed74411192a0c1557cb8a986f9db7fb69
|
||||||
F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
|
F src/utf.c 810fbfebe12359f10bc2a011520a6e10879ab2a163bcb26c74768eab82ea62a5
|
||||||
F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157
|
F src/util.c d9eb0a6c4aae1b00a7369eadd7ca0bbe946cb4c953b6751aa20d357c2f482157
|
||||||
F src/vacuum.c 762ee9bbf8733d87d8cd06f58d950e881982e416f8c767334a40ffd341b6bff5
|
F src/vacuum.c 762ee9bbf8733d87d8cd06f58d950e881982e416f8c767334a40ffd341b6bff5
|
||||||
@@ -1719,7 +1719,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P d3c53fd3177946f50137d48da871de43d78d10ef9990cc4ea6750f7020f89b6a f94528e1c70765c8649750b2d9c17f23e81f191554ff56d905a9abe3fb6037b7
|
P 54d96772e78b7f57d5b590aebe34a139ade73629aebe16677372650b33513b1d
|
||||||
R bf422b59ff7f1c6f6ea70f77a810e010
|
R bdaf4436c6e5d9601bf3da500ee61f0e
|
||||||
U drh
|
U drh
|
||||||
Z 82a412abb60d38c0dadc6c5d2ed63354
|
Z 75b8643425669c47908a06e24f421b91
|
||||||
|
@@ -1 +1 @@
|
|||||||
54d96772e78b7f57d5b590aebe34a139ade73629aebe16677372650b33513b1d
|
0203f34faae07fbea0bff2d23b81fb37df8854cded4cdadac5a034132a096b6d
|
@@ -808,6 +808,7 @@ void sqlite3Insert(
|
|||||||
if( pUpsert ){
|
if( pUpsert ){
|
||||||
pTabList->a[0].iCursor = iDataCur;
|
pTabList->a[0].iCursor = iDataCur;
|
||||||
pUpsert->pUpsertSrc = pTabList;
|
pUpsert->pUpsertSrc = pTabList;
|
||||||
|
pUpsert->regData = regData;
|
||||||
if( pUpsert->pUpsertTarget ){
|
if( pUpsert->pUpsertTarget ){
|
||||||
sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert);
|
sqlite3UpsertAnalyzeTarget(pParse, pTabList, pUpsert);
|
||||||
}
|
}
|
||||||
|
@@ -826,7 +826,7 @@ cmd ::= with UPDATE orconf(R) fullname(X) indexed_opt(I) SET setlist(Y)
|
|||||||
where_opt(W) orderby_opt(O) limit_opt(L). {
|
where_opt(W) orderby_opt(O) limit_opt(L). {
|
||||||
sqlite3SrcListIndexedBy(pParse, X, &I);
|
sqlite3SrcListIndexedBy(pParse, X, &I);
|
||||||
sqlite3ExprListCheckLength(pParse,Y,"set list");
|
sqlite3ExprListCheckLength(pParse,Y,"set list");
|
||||||
sqlite3Update(pParse,X,Y,W,R,O,L);
|
sqlite3Update(pParse,X,Y,W,R,O,L,0);
|
||||||
}
|
}
|
||||||
%endif
|
%endif
|
||||||
%ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
|
%ifndef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
|
||||||
@@ -834,7 +834,7 @@ cmd ::= with UPDATE orconf(R) fullname(X) indexed_opt(I) SET setlist(Y)
|
|||||||
where_opt(W). {
|
where_opt(W). {
|
||||||
sqlite3SrcListIndexedBy(pParse, X, &I);
|
sqlite3SrcListIndexedBy(pParse, X, &I);
|
||||||
sqlite3ExprListCheckLength(pParse,Y,"set list");
|
sqlite3ExprListCheckLength(pParse,Y,"set list");
|
||||||
sqlite3Update(pParse,X,Y,W,R,0,0);
|
sqlite3Update(pParse,X,Y,W,R,0,0,0);
|
||||||
}
|
}
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
@@ -191,7 +191,7 @@ static int lookupName(
|
|||||||
struct SrcList_item *pMatch = 0; /* The matching pSrcList item */
|
struct SrcList_item *pMatch = 0; /* The matching pSrcList item */
|
||||||
NameContext *pTopNC = pNC; /* First namecontext in the list */
|
NameContext *pTopNC = pNC; /* First namecontext in the list */
|
||||||
Schema *pSchema = 0; /* Schema of the expression */
|
Schema *pSchema = 0; /* Schema of the expression */
|
||||||
int isTrigger = 0; /* True if resolved to a trigger column */
|
int eNewExprOp = TK_COLUMN; /* New value for pExpr->op on success */
|
||||||
Table *pTab = 0; /* Table hold the row */
|
Table *pTab = 0; /* Table hold the row */
|
||||||
Column *pCol; /* A column of pTab */
|
Column *pCol; /* A column of pTab */
|
||||||
|
|
||||||
@@ -296,22 +296,35 @@ static int lookupName(
|
|||||||
}
|
}
|
||||||
} /* if( pSrcList ) */
|
} /* if( pSrcList ) */
|
||||||
|
|
||||||
#ifndef SQLITE_OMIT_TRIGGER
|
#if !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT)
|
||||||
/* If we have not already resolved the name, then maybe
|
/* If we have not already resolved the name, then maybe
|
||||||
** it is a new.* or old.* trigger argument reference
|
** it is a new.* or old.* trigger argument reference. Or
|
||||||
|
** maybe it is an excluded.* from an upsert.
|
||||||
*/
|
*/
|
||||||
if( zDb==0 && zTab!=0 && cntTab==0 && pParse->pTriggerTab!=0 ){
|
if( zDb==0 && zTab!=0 && cntTab==0 ){
|
||||||
int op = pParse->eTriggerOp;
|
pTab = 0;
|
||||||
assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
|
#ifndef SQLITE_OMIT_TRIGGER
|
||||||
if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
|
if( pParse->pTriggerTab!=0 ){
|
||||||
pExpr->iTable = 1;
|
int op = pParse->eTriggerOp;
|
||||||
pTab = pParse->pTriggerTab;
|
assert( op==TK_DELETE || op==TK_UPDATE || op==TK_INSERT );
|
||||||
}else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){
|
if( op!=TK_DELETE && sqlite3StrICmp("new",zTab) == 0 ){
|
||||||
pExpr->iTable = 0;
|
pExpr->iTable = 1;
|
||||||
pTab = pParse->pTriggerTab;
|
pTab = pParse->pTriggerTab;
|
||||||
}else{
|
}else if( op!=TK_INSERT && sqlite3StrICmp("old",zTab)==0 ){
|
||||||
pTab = 0;
|
pExpr->iTable = 0;
|
||||||
|
pTab = pParse->pTriggerTab;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* SQLITE_OMIT_TRIGGER */
|
||||||
|
#ifndef SQLITE_OMIT_UPSERT
|
||||||
|
if( (pNC->ncFlags & NC_UUpsert)!=0 ){
|
||||||
|
Upsert *pUpsert = pNC->uNC.pUpsert;
|
||||||
|
if( pUpsert && sqlite3StrICmp("excluded",zTab)==0 ){
|
||||||
|
pTab = pUpsert->pUpsertSrc->a[0].pTab;
|
||||||
|
pExpr->iTable = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* SQLITE_OMIT_UPSERT */
|
||||||
|
|
||||||
if( pTab ){
|
if( pTab ){
|
||||||
int iCol;
|
int iCol;
|
||||||
@@ -331,24 +344,34 @@ static int lookupName(
|
|||||||
}
|
}
|
||||||
if( iCol<pTab->nCol ){
|
if( iCol<pTab->nCol ){
|
||||||
cnt++;
|
cnt++;
|
||||||
if( iCol<0 ){
|
#ifndef SQLITE_OMIT_UPSERT
|
||||||
pExpr->affinity = SQLITE_AFF_INTEGER;
|
if( pExpr->iTable==2 ){
|
||||||
}else if( pExpr->iTable==0 ){
|
pExpr->iTable = pNC->uNC.pUpsert->regData + iCol;
|
||||||
testcase( iCol==31 );
|
eNewExprOp = TK_REGISTER;
|
||||||
testcase( iCol==32 );
|
}else
|
||||||
pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
|
#endif
|
||||||
}else{
|
{
|
||||||
testcase( iCol==31 );
|
#ifndef SQLITE_OMIT_TRIGGER
|
||||||
testcase( iCol==32 );
|
if( iCol<0 ){
|
||||||
pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
|
pExpr->affinity = SQLITE_AFF_INTEGER;
|
||||||
|
}else if( pExpr->iTable==0 ){
|
||||||
|
testcase( iCol==31 );
|
||||||
|
testcase( iCol==32 );
|
||||||
|
pParse->oldmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
|
||||||
|
}else{
|
||||||
|
testcase( iCol==31 );
|
||||||
|
testcase( iCol==32 );
|
||||||
|
pParse->newmask |= (iCol>=32 ? 0xffffffff : (((u32)1)<<iCol));
|
||||||
|
}
|
||||||
|
pExpr->pTab = pTab;
|
||||||
|
pExpr->iColumn = (i16)iCol;
|
||||||
|
eNewExprOp = TK_TRIGGER;
|
||||||
|
#endif /* SQLITE_OMIT_TRIGGER
|
||||||
}
|
}
|
||||||
pExpr->iColumn = (i16)iCol;
|
|
||||||
pExpr->pTab = pTab;
|
|
||||||
isTrigger = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* !defined(SQLITE_OMIT_TRIGGER) */
|
#endif /* !defined(SQLITE_OMIT_TRIGGER) || !defined(SQLITE_OMIT_UPSERT) */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Perhaps the name is a reference to the ROWID
|
** Perhaps the name is a reference to the ROWID
|
||||||
@@ -485,7 +508,7 @@ static int lookupName(
|
|||||||
pExpr->pLeft = 0;
|
pExpr->pLeft = 0;
|
||||||
sqlite3ExprDelete(db, pExpr->pRight);
|
sqlite3ExprDelete(db, pExpr->pRight);
|
||||||
pExpr->pRight = 0;
|
pExpr->pRight = 0;
|
||||||
pExpr->op = (isTrigger ? TK_TRIGGER : TK_COLUMN);
|
pExpr->op = eNewExprOp;
|
||||||
ExprSetProperty(pExpr, EP_Leaf);
|
ExprSetProperty(pExpr, EP_Leaf);
|
||||||
lookupname_end:
|
lookupname_end:
|
||||||
if( cnt==1 ){
|
if( cnt==1 ){
|
||||||
@@ -1301,7 +1324,7 @@ static int resolveSelectStep(Walker *pWalker, Select *p){
|
|||||||
** Minor point: If this is the case, then the expression will be
|
** Minor point: If this is the case, then the expression will be
|
||||||
** re-evaluated for each reference to it.
|
** re-evaluated for each reference to it.
|
||||||
*/
|
*/
|
||||||
assert( (sNC.ncFlags & (NC_UAggInfo))==0 );
|
assert( (sNC.ncFlags & (NC_UAggInfo|NC_UUpsert))==0 );
|
||||||
sNC.uNC.pEList = p->pEList;
|
sNC.uNC.pEList = p->pEList;
|
||||||
sNC.ncFlags |= NC_UEList;
|
sNC.ncFlags |= NC_UEList;
|
||||||
if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
|
if( sqlite3ResolveExprNames(&sNC, p->pHaving) ) return WRC_Abort;
|
||||||
|
@@ -2685,6 +2685,7 @@ struct NameContext {
|
|||||||
union {
|
union {
|
||||||
ExprList *pEList; /* Optional list of result-set columns */
|
ExprList *pEList; /* Optional list of result-set columns */
|
||||||
AggInfo *pAggInfo; /* Information about aggregates at this level */
|
AggInfo *pAggInfo; /* Information about aggregates at this level */
|
||||||
|
Upsert *pUpsert; /* ON CONFLICT clause information from an upsert */
|
||||||
} uNC;
|
} uNC;
|
||||||
NameContext *pNext; /* Next outer name context. NULL for outermost */
|
NameContext *pNext; /* Next outer name context. NULL for outermost */
|
||||||
int nRef; /* Number of names resolved by this context */
|
int nRef; /* Number of names resolved by this context */
|
||||||
@@ -2709,6 +2710,7 @@ struct NameContext {
|
|||||||
#define NC_VarSelect 0x0040 /* A correlated subquery has been seen */
|
#define NC_VarSelect 0x0040 /* A correlated subquery has been seen */
|
||||||
#define NC_UEList 0x0080 /* True if uNC.pEList is used */
|
#define NC_UEList 0x0080 /* True if uNC.pEList is used */
|
||||||
#define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
|
#define NC_UAggInfo 0x0100 /* True if uNC.pAggInfo is used */
|
||||||
|
#define NC_UUpsert 0x0200 /* True if uNC.pUpsert is used */
|
||||||
#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
|
#define NC_MinMaxAgg 0x1000 /* min/max aggregates seen. See note above */
|
||||||
#define NC_Complex 0x2000 /* True if a function or subquery seen */
|
#define NC_Complex 0x2000 /* True if a function or subquery seen */
|
||||||
|
|
||||||
@@ -2733,6 +2735,7 @@ struct Upsert {
|
|||||||
ExprList *pUpsertSet; /* The SET clause from an ON CONFLICT UPDATE */
|
ExprList *pUpsertSet; /* The SET clause from an ON CONFLICT UPDATE */
|
||||||
Expr *pUpsertWhere; /* WHERE clause for the ON CONFLICT UPDATE */
|
Expr *pUpsertWhere; /* WHERE clause for the ON CONFLICT UPDATE */
|
||||||
SrcList *pUpsertSrc; /* Table to be updated */
|
SrcList *pUpsertSrc; /* Table to be updated */
|
||||||
|
int regData; /* First register holding array of VALUES */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -3798,7 +3801,8 @@ void sqlite3OpenTable(Parse*, int iCur, int iDb, Table*, int);
|
|||||||
Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
|
Expr *sqlite3LimitWhere(Parse*,SrcList*,Expr*,ExprList*,Expr*,char*);
|
||||||
#endif
|
#endif
|
||||||
void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
|
void sqlite3DeleteFrom(Parse*, SrcList*, Expr*, ExprList*, Expr*);
|
||||||
void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*);
|
void sqlite3Update(Parse*, SrcList*, ExprList*,Expr*,int,ExprList*,Expr*,
|
||||||
|
Upsert*);
|
||||||
WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
|
WhereInfo *sqlite3WhereBegin(Parse*,SrcList*,Expr*,ExprList*,ExprList*,u16,int);
|
||||||
void sqlite3WhereEnd(WhereInfo*);
|
void sqlite3WhereEnd(WhereInfo*);
|
||||||
LogEst sqlite3WhereOutputRowCount(WhereInfo*);
|
LogEst sqlite3WhereOutputRowCount(WhereInfo*);
|
||||||
|
@@ -750,7 +750,7 @@ static int codeTriggerProgram(
|
|||||||
targetSrcList(pParse, pStep),
|
targetSrcList(pParse, pStep),
|
||||||
sqlite3ExprListDup(db, pStep->pExprList, 0),
|
sqlite3ExprListDup(db, pStep->pExprList, 0),
|
||||||
sqlite3ExprDup(db, pStep->pWhere, 0),
|
sqlite3ExprDup(db, pStep->pWhere, 0),
|
||||||
pParse->eOrconf, 0, 0
|
pParse->eOrconf, 0, 0, 0
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -93,7 +93,8 @@ void sqlite3Update(
|
|||||||
Expr *pWhere, /* The WHERE clause. May be null */
|
Expr *pWhere, /* The WHERE clause. May be null */
|
||||||
int onError, /* How to handle constraint errors */
|
int onError, /* How to handle constraint errors */
|
||||||
ExprList *pOrderBy, /* ORDER BY clause. May be null */
|
ExprList *pOrderBy, /* ORDER BY clause. May be null */
|
||||||
Expr *pLimit /* LIMIT clause. May be null */
|
Expr *pLimit, /* LIMIT clause. May be null */
|
||||||
|
Upsert *pUpsert /* ON CONFLICT clause, or null */
|
||||||
){
|
){
|
||||||
int i, j; /* Loop counters */
|
int i, j; /* Loop counters */
|
||||||
Table *pTab; /* The table to be updated */
|
Table *pTab; /* The table to be updated */
|
||||||
@@ -226,6 +227,8 @@ void sqlite3Update(
|
|||||||
memset(&sNC, 0, sizeof(sNC));
|
memset(&sNC, 0, sizeof(sNC));
|
||||||
sNC.pParse = pParse;
|
sNC.pParse = pParse;
|
||||||
sNC.pSrcList = pTabList;
|
sNC.pSrcList = pTabList;
|
||||||
|
sNC.uNC.pUpsert = pUpsert;
|
||||||
|
sNC.ncFlags = NC_UUpsert;
|
||||||
|
|
||||||
/* Resolve the column names in all the expressions of the
|
/* Resolve the column names in all the expressions of the
|
||||||
** of the UPDATE statement. Also find the column index
|
** of the UPDATE statement. Also find the column index
|
||||||
|
@@ -251,7 +251,7 @@ void sqlite3UpsertDoUpdate(
|
|||||||
pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
|
pSrc = sqlite3SrcListDup(db, pUpsert->pUpsertSrc, 0);
|
||||||
sqlite3Update(pParse, pSrc,
|
sqlite3Update(pParse, pSrc,
|
||||||
sqlite3ExprListDup(db, pUpsert->pUpsertSet, 0),
|
sqlite3ExprListDup(db, pUpsert->pUpsertSet, 0),
|
||||||
pWhere, OE_Abort, 0, 0);
|
pWhere, OE_Abort, 0, 0, pUpsert);
|
||||||
VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
|
VdbeNoopComment((v, "End DO UPDATE of UPSERT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user