8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 10:03:03 +01:00

Fixed CORE-6086, thanks to Vlad

This commit is contained in:
Dmitry Yemanov 2019-06-23 08:07:41 +03:00
parent a7d953adca
commit 49754a89fd
3 changed files with 5 additions and 2 deletions

View File

@ -601,6 +601,7 @@ void DsqlCompilerScratch::clearCTEs()
flags &= ~DsqlCompilerScratch::FLAG_RECURSIVE_CTE; flags &= ~DsqlCompilerScratch::FLAG_RECURSIVE_CTE;
ctes.clear(); ctes.clear();
cteAliases.clear(); cteAliases.clear();
currCteAlias = NULL;
} }
// Look for unused CTEs and issue a warning about its presence. Also, make DSQL // Look for unused CTEs and issue a warning about its presence. Also, make DSQL

View File

@ -216,6 +216,7 @@ public:
void addCTEAlias(const Firebird::string& alias) void addCTEAlias(const Firebird::string& alias)
{ {
thread_db* tdbb = JRD_get_thread_data(); thread_db* tdbb = JRD_get_thread_data();
fb_assert(currCteAlias == NULL);
cteAliases.add(FB_NEW_POOL(*tdbb->getDefaultPool()) Firebird::string(*tdbb->getDefaultPool(), alias)); cteAliases.add(FB_NEW_POOL(*tdbb->getDefaultPool()) Firebird::string(*tdbb->getDefaultPool(), alias));
} }

View File

@ -1232,13 +1232,14 @@ RseNode* PASS1_derived_table(DsqlCompilerScratch* dsqlScratch, SelectExprNode* i
dsqlScratch->recursiveCtx = context; dsqlScratch->recursiveCtx = context;
dsqlScratch->context = &temp; dsqlScratch->context = &temp;
const string* const* saveCteAlias = dsqlScratch->currCteAlias; const string* const saveCteAlias =
dsqlScratch->currCteAlias ? *dsqlScratch->currCteAlias : NULL;
dsqlScratch->resetCTEAlias(alias); dsqlScratch->resetCTEAlias(alias);
rse = PASS1_rse(dsqlScratch, input, updateLock); rse = PASS1_rse(dsqlScratch, input, updateLock);
if (saveCteAlias) if (saveCteAlias)
dsqlScratch->resetCTEAlias(**saveCteAlias); dsqlScratch->resetCTEAlias(*saveCteAlias);
dsqlScratch->recursiveCtx = saveRecursiveCtx; dsqlScratch->recursiveCtx = saveRecursiveCtx;
// Finish off by cleaning up contexts and put them into derivedContext // Finish off by cleaning up contexts and put them into derivedContext