mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-18 10:21:03 +03:00
Merge the sqlite3WhereMalloc() routine from trunk into the right-join branch.
FossilOrigin-Name: b1b3845aa38f469a27f07c8f6e8a98334f7967b19661ee4cf155d6997afd9d4c
This commit is contained in:
21
manifest
21
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Preliminary\scode\sto\ssupport\sRIGHT\sJOIN.\sEverything\sseems\sto\swork,\sexcept\sthat\nthe\scode\sto\scompute\sthe\sunmatched\srows\sfor\sthe\sRIGHT\sJOIN\shas\snot\syet\sbeen\nadded,\sso\sthe\sresult\sof\sa\sRIGHT\sJOIN\sis\scurrently\sthe\ssame\sas\san\sINNER\sJOIN.
|
C Merge\sthe\ssqlite3WhereMalloc()\sroutine\sfrom\strunk\sinto\sthe\sright-join\sbranch.
|
||||||
D 2022-04-08T19:20:12.051
|
D 2022-04-09T03:12:52.801
|
||||||
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 LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
@@ -639,10 +639,10 @@ F src/vxworks.h d2988f4e5a61a4dfe82c6524dd3d6e4f2ce3cdb9
|
|||||||
F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d
|
F src/wal.c b9df133a705093da8977da5eb202eaadb844839f1c7297c08d33471f5491843d
|
||||||
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
F src/wal.h c3aa7825bfa2fe0d85bef2db94655f99870a285778baa36307c0a16da32b226a
|
||||||
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
|
F src/walker.c f890a3298418d7cba3b69b8803594fdc484ea241206a8dfa99db6dd36f8cbb3b
|
||||||
F src/where.c c752850f0d4b21656ef2901484fb7c799a6d20efe1d13fa5e77a3554b7568625
|
F src/where.c 20b6907d66577c02bc2be434c3c8fd5f00f0112d467cb8ae5d97ced3af14f484
|
||||||
F src/whereInt.h 15d2975c3b4c193c78c26674400a840da8647fe1777ae3b026e2d15937b38a03
|
F src/whereInt.h 41ce0a8c0368372d8422e420e05a1e037624ce52fae139c3c19538ee491fb4c0
|
||||||
F src/wherecode.c 7025f2a5b8b160af7ec4837e5d3c5befc2e61f0aafeea3f5f0403e46674f284f
|
F src/wherecode.c 79813939e009cbd8a042d57e6c0cad1a437d8e2e19b8be61c70760089f055c89
|
||||||
F src/whereexpr.c a4542ee72e05e4ab9dfadb5ddc0116007dc2420763992a79dbe83aaf73212311
|
F src/whereexpr.c ac8985bbd983f34273b1e0d05cd738ff436331674c1b22f4caf6537e1eca4691
|
||||||
F src/window.c 42a71595263dbd8ef8248218e4fc7d4b5ddccece52146ad48e079342d93f6f8f
|
F src/window.c 42a71595263dbd8ef8248218e4fc7d4b5ddccece52146ad48e079342d93f6f8f
|
||||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||||
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
|
F test/affinity2.test ce1aafc86e110685b324e9a763eab4f2a73f737842ec3b687bd965867de90627
|
||||||
@@ -1945,11 +1945,8 @@ 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 8efd61e8518594e3e9c84681fc35796a78fe8885a97ad4dd19f1573ee8065b18
|
P 415abd6731b8e8a605adabfa6066c8a852a8531c300df41325d5f7e75cae5a70 f237e1d8cc41b937f34288daebfacf5f7b0990a807a805e0cb6b45bc730192d6
|
||||||
R 322c8c2f976fdab57b24f3e90a096129
|
R 14570ffbcb3ed6fd5a47242c31653712
|
||||||
T *branch * right-join
|
|
||||||
T *sym-right-join *
|
|
||||||
T -sym-trunk *
|
|
||||||
U drh
|
U drh
|
||||||
Z 04b77679382a7e72969224c19421c972
|
Z 80db52d601f5cc05776abad4ced7d9c5
|
||||||
# Remove this line to create a well-formed Fossil manifest.
|
# Remove this line to create a well-formed Fossil manifest.
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
415abd6731b8e8a605adabfa6066c8a852a8531c300df41325d5f7e75cae5a70
|
b1b3845aa38f469a27f07c8f6e8a98334f7967b19661ee4cf155d6997afd9d4c
|
||||||
37
src/where.c
37
src/where.c
@@ -253,6 +253,30 @@ Bitmask sqlite3WhereGetMask(WhereMaskSet *pMaskSet, int iCursor){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Allocate memory that is automatically freed when pWInfo is freed.
|
||||||
|
*/
|
||||||
|
void *sqlite3WhereMalloc(WhereInfo *pWInfo, u64 nByte){
|
||||||
|
WhereMemBlock *pBlock;
|
||||||
|
pBlock = sqlite3DbMallocRawNN(pWInfo->pParse->db, nByte+sizeof(*pBlock));
|
||||||
|
if( pBlock ){
|
||||||
|
pBlock->pNext = pWInfo->pMemToFree;
|
||||||
|
pBlock->sz = nByte;
|
||||||
|
pWInfo->pMemToFree = pBlock;
|
||||||
|
pBlock++;
|
||||||
|
}
|
||||||
|
return (void*)pBlock;
|
||||||
|
}
|
||||||
|
void *sqlite3WhereRealloc(WhereInfo *pWInfo, void *pOld, u64 nByte){
|
||||||
|
void *pNew = sqlite3WhereMalloc(pWInfo, nByte);
|
||||||
|
if( pNew && pOld ){
|
||||||
|
WhereMemBlock *pOldBlk = (WhereMemBlock*)pOld;
|
||||||
|
pOldBlk--;
|
||||||
|
assert( pOldBlk->sz<nByte );
|
||||||
|
memcpy(pNew, pOld, pOldBlk->sz);
|
||||||
|
}
|
||||||
|
return pNew;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Create a new mask for cursor iCursor.
|
** Create a new mask for cursor iCursor.
|
||||||
**
|
**
|
||||||
@@ -2218,15 +2242,7 @@ static void whereLoopDelete(sqlite3 *db, WhereLoop *p){
|
|||||||
** Free a WhereInfo structure
|
** Free a WhereInfo structure
|
||||||
*/
|
*/
|
||||||
static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
|
static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
|
||||||
int i;
|
|
||||||
assert( pWInfo!=0 );
|
assert( pWInfo!=0 );
|
||||||
for(i=0; i<pWInfo->nLevel; i++){
|
|
||||||
WhereLevel *pLevel = &pWInfo->a[i];
|
|
||||||
if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE)!=0 ){
|
|
||||||
assert( (pLevel->pWLoop->wsFlags & WHERE_MULTI_OR)==0 );
|
|
||||||
sqlite3DbFree(db, pLevel->u.in.aInLoop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sqlite3WhereClauseClear(&pWInfo->sWC);
|
sqlite3WhereClauseClear(&pWInfo->sWC);
|
||||||
while( pWInfo->pLoops ){
|
while( pWInfo->pLoops ){
|
||||||
WhereLoop *p = pWInfo->pLoops;
|
WhereLoop *p = pWInfo->pLoops;
|
||||||
@@ -2234,6 +2250,11 @@ static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
|
|||||||
whereLoopDelete(db, p);
|
whereLoopDelete(db, p);
|
||||||
}
|
}
|
||||||
assert( pWInfo->pExprMods==0 );
|
assert( pWInfo->pExprMods==0 );
|
||||||
|
while( pWInfo->pMemToFree ){
|
||||||
|
WhereMemBlock *pNext = pWInfo->pMemToFree->pNext;
|
||||||
|
sqlite3DbFreeNN(db, pWInfo->pMemToFree);
|
||||||
|
pWInfo->pMemToFree = pNext;
|
||||||
|
}
|
||||||
sqlite3DbFreeNN(db, pWInfo);
|
sqlite3DbFreeNN(db, pWInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,16 @@ typedef struct WhereLoopBuilder WhereLoopBuilder;
|
|||||||
typedef struct WhereScan WhereScan;
|
typedef struct WhereScan WhereScan;
|
||||||
typedef struct WhereOrCost WhereOrCost;
|
typedef struct WhereOrCost WhereOrCost;
|
||||||
typedef struct WhereOrSet WhereOrSet;
|
typedef struct WhereOrSet WhereOrSet;
|
||||||
|
typedef struct WhereMemBlock WhereMemBlock;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** This object is a header on a block of allocated memory that will be
|
||||||
|
** automatically freed when its WInfo oject is destructed.
|
||||||
|
*/
|
||||||
|
struct WhereMemBlock {
|
||||||
|
WhereMemBlock *pNext; /* Next block in the chain */
|
||||||
|
u8 sz; /* Bytes of space */
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** This object contains information needed to implement a single nested
|
** This object contains information needed to implement a single nested
|
||||||
@@ -478,6 +488,7 @@ struct WhereInfo {
|
|||||||
int iEndWhere; /* End of the WHERE clause itself */
|
int iEndWhere; /* End of the WHERE clause itself */
|
||||||
WhereLoop *pLoops; /* List of all WhereLoop objects */
|
WhereLoop *pLoops; /* List of all WhereLoop objects */
|
||||||
WhereExprMod *pExprMods; /* Expression modifications */
|
WhereExprMod *pExprMods; /* Expression modifications */
|
||||||
|
WhereMemBlock *pMemToFree;/* Memory to free when this object destroyed */
|
||||||
Bitmask revMask; /* Mask of ORDER BY terms that need reversing */
|
Bitmask revMask; /* Mask of ORDER BY terms that need reversing */
|
||||||
WhereClause sWC; /* Decomposition of the WHERE clause */
|
WhereClause sWC; /* Decomposition of the WHERE clause */
|
||||||
WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */
|
WhereMaskSet sMaskSet; /* Map cursor numbers to bitmasks */
|
||||||
@@ -503,6 +514,8 @@ WhereTerm *sqlite3WhereFindTerm(
|
|||||||
u32 op, /* Mask of WO_xx values describing operator */
|
u32 op, /* Mask of WO_xx values describing operator */
|
||||||
Index *pIdx /* Must be compatible with this index, if not NULL */
|
Index *pIdx /* Must be compatible with this index, if not NULL */
|
||||||
);
|
);
|
||||||
|
void *sqlite3WhereMalloc(WhereInfo *pWInfo, u64 nByte);
|
||||||
|
void *sqlite3WhereRealloc(WhereInfo *pWInfo, void *pOld, u64 nByte);
|
||||||
|
|
||||||
/* wherecode.c: */
|
/* wherecode.c: */
|
||||||
#ifndef SQLITE_OMIT_EXPLAIN
|
#ifndef SQLITE_OMIT_EXPLAIN
|
||||||
|
|||||||
@@ -640,7 +640,8 @@ static int codeEqualityTerm(
|
|||||||
i = pLevel->u.in.nIn;
|
i = pLevel->u.in.nIn;
|
||||||
pLevel->u.in.nIn += nEq;
|
pLevel->u.in.nIn += nEq;
|
||||||
pLevel->u.in.aInLoop =
|
pLevel->u.in.aInLoop =
|
||||||
sqlite3DbReallocOrFree(pParse->db, pLevel->u.in.aInLoop,
|
sqlite3WhereRealloc(pTerm->pWC->pWInfo,
|
||||||
|
pLevel->u.in.aInLoop,
|
||||||
sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);
|
sizeof(pLevel->u.in.aInLoop[0])*pLevel->u.in.nIn);
|
||||||
pIn = pLevel->u.in.aInLoop;
|
pIn = pLevel->u.in.aInLoop;
|
||||||
if( pIn ){
|
if( pIn ){
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
|
|||||||
if( pWC->nTerm>=pWC->nSlot ){
|
if( pWC->nTerm>=pWC->nSlot ){
|
||||||
WhereTerm *pOld = pWC->a;
|
WhereTerm *pOld = pWC->a;
|
||||||
sqlite3 *db = pWC->pWInfo->pParse->db;
|
sqlite3 *db = pWC->pWInfo->pParse->db;
|
||||||
pWC->a = sqlite3DbMallocRawNN(db, sizeof(pWC->a[0])*pWC->nSlot*2 );
|
pWC->a = sqlite3WhereMalloc(pWC->pWInfo, sizeof(pWC->a[0])*pWC->nSlot*2 );
|
||||||
if( pWC->a==0 ){
|
if( pWC->a==0 ){
|
||||||
if( wtFlags & TERM_DYNAMIC ){
|
if( wtFlags & TERM_DYNAMIC ){
|
||||||
sqlite3ExprDelete(db, p);
|
sqlite3ExprDelete(db, p);
|
||||||
@@ -73,10 +73,7 @@ static int whereClauseInsert(WhereClause *pWC, Expr *p, u16 wtFlags){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);
|
memcpy(pWC->a, pOld, sizeof(pWC->a[0])*pWC->nTerm);
|
||||||
if( pOld!=pWC->aStatic ){
|
pWC->nSlot = pWC->nSlot*2;
|
||||||
sqlite3DbFree(db, pOld);
|
|
||||||
}
|
|
||||||
pWC->nSlot = sqlite3DbMallocSize(db, pWC->a)/sizeof(pWC->a[0]);
|
|
||||||
}
|
}
|
||||||
pTerm = &pWC->a[idx = pWC->nTerm++];
|
pTerm = &pWC->a[idx = pWC->nTerm++];
|
||||||
if( (wtFlags & TERM_VIRTUAL)==0 ) pWC->nBase = pWC->nTerm;
|
if( (wtFlags & TERM_VIRTUAL)==0 ) pWC->nBase = pWC->nTerm;
|
||||||
@@ -1686,9 +1683,6 @@ void sqlite3WhereClauseClear(WhereClause *pWC){
|
|||||||
a++;
|
a++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( pWC->a!=pWC->aStatic ){
|
|
||||||
sqlite3DbFree(db, pWC->a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user