diff options
author | drh <> | 2024-08-20 23:11:28 +0000 |
---|---|---|
committer | drh <> | 2024-08-20 23:11:28 +0000 |
commit | 5648d717b15c1722ff19e7af1e55d68d1d172f1d (patch) | |
tree | 971f2c19f00ab2073124d4ecedaa7df3f0b42509 /src/trigger.c | |
parent | 781163aa9dce91608ba33af479564f83dda1bd40 (diff) | |
parent | a0651b370706e58f9014453c5f36124ca8a738c9 (diff) | |
download | sqlite-5648d717b15c1722ff19e7af1e55d68d1d172f1d.tar.gz sqlite-5648d717b15c1722ff19e7af1e55d68d1d172f1d.zip |
Refactor the SrcItem object to move fields associated with subqueries out
into a separate object named Subquery. This reduces the size of the SrcItem
object by about 1/3rd and provides improved performance.
FossilOrigin-Name: 484bcd75bc95491d8540c791c1c4d40d996cb465839564662e14f98739699bf1
Diffstat (limited to 'src/trigger.c')
-rw-r--r-- | src/trigger.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/trigger.c b/src/trigger.c index 98e8da58c..ff2df82cb 100644 --- a/src/trigger.c +++ b/src/trigger.c @@ -152,8 +152,10 @@ void sqlite3BeginTrigger( ** name on pTableName if we are reparsing out of the schema table */ if( db->init.busy && iDb!=1 ){ - sqlite3DbFree(db, pTableName->a[0].zDatabase); - pTableName->a[0].zDatabase = 0; + assert( pTableName->a[0].fg.fixedSchema==0 ); + assert( pTableName->a[0].fg.isSubquery==0 ); + sqlite3DbFree(db, pTableName->a[0].u4.zDatabase); + pTableName->a[0].u4.zDatabase = 0; } /* If the trigger name was unqualified, and the table is a temp table, @@ -631,7 +633,8 @@ void sqlite3DropTrigger(Parse *pParse, SrcList *pName, int noErr){ } assert( pName->nSrc==1 ); - zDb = pName->a[0].zDatabase; + assert( pName->a[0].fg.fixedSchema==0 && pName->a[0].fg.isSubquery==0 ); + zDb = pName->a[0].u4.zDatabase; zName = pName->a[0].zName; assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) ); for(i=OMIT_TEMPDB; i<db->nDb; i++){ @@ -868,7 +871,9 @@ SrcList *sqlite3TriggerStepSrc( Schema *pSchema = pStep->pTrig->pSchema; pSrc->a[0].zName = zName; if( pSchema!=db->aDb[1].pSchema ){ - pSrc->a[0].pSchema = pSchema; + assert( pSrc->a[0].fg.fixedSchema || pSrc->a[0].u4.zDatabase==0 ); + pSrc->a[0].u4.pSchema = pSchema; + pSrc->a[0].fg.fixedSchema = 1; } if( pStep->pFrom ){ SrcList *pDup = sqlite3SrcListDup(db, pStep->pFrom, 0); @@ -981,7 +986,7 @@ static int sqlite3ReturningSubqueryCorrelated(Walker *pWalker, Select *pSelect){ pSrc = pSelect->pSrc; assert( pSrc!=0 ); for(i=0; i<pSrc->nSrc; i++){ - if( pSrc->a[i].pTab==pWalker->u.pTab ){ + if( pSrc->a[i].pSTab==pWalker->u.pTab ){ testcase( pSelect->selFlags & SF_Correlated ); pSelect->selFlags |= SF_Correlated; pWalker->eCode = 1; @@ -1052,7 +1057,7 @@ static void codeReturningTrigger( sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0); sSelect.pSrc = &sFrom; sFrom.nSrc = 1; - sFrom.a[0].pTab = pTab; + sFrom.a[0].pSTab = pTab; sFrom.a[0].zName = pTab->zName; /* tag-20240424-1 */ sFrom.a[0].iCursor = -1; sqlite3SelectPrep(pParse, &sSelect, 0); |