diff --git a/src/jrd/Statement.cpp b/src/jrd/Statement.cpp index b876daced9..77280ba896 100644 --- a/src/jrd/Statement.cpp +++ b/src/jrd/Statement.cpp @@ -226,7 +226,7 @@ Statement::Statement(thread_db* tdbb, MemoryPool* p, CompilerScratch* csb) } // Turn a parsed scratch into a statement. -Statement* Statement::makeStatement(thread_db* tdbb, CompilerScratch* csb, bool internalFlag) +Statement* Statement::makeStatement(thread_db* tdbb, CompilerScratch* csb, bool internalFlag, dsc* exprDesc) { DEV_BLKCHK(csb, type_csb); SET_TDBB(tdbb); @@ -306,6 +306,12 @@ Statement* Statement::makeStatement(thread_db* tdbb, CompilerScratch* csb, bool const auto pool = tdbb->getDefaultPool(); + if (exprDesc) + { + fb_assert(csb->csb_node->getKind() == DmlNode::KIND_VALUE); + static_cast(csb->csb_node)->getDesc(tdbb, csb, exprDesc); + } + statement = FB_NEW_POOL(*pool) Statement(tdbb, pool, csb); tdbb->setRequest(old_request); diff --git a/src/jrd/Statement.h b/src/jrd/Statement.h index 6f68a360e1..179be5acef 100644 --- a/src/jrd/Statement.h +++ b/src/jrd/Statement.h @@ -45,7 +45,7 @@ private: Statement(thread_db* tdbb, MemoryPool* p, CompilerScratch* csb); public: - static Statement* makeStatement(thread_db* tdbb, CompilerScratch* csb, bool internalFlag); + static Statement* makeStatement(thread_db* tdbb, CompilerScratch* csb, bool internalFlag, dsc* exprDesc = nullptr); static Request* makeRequest(thread_db* tdbb, CompilerScratch* csb, bool internalFlag); StmtNumber getStatementId() const diff --git a/src/jrd/dfw.epp b/src/jrd/dfw.epp index a3a956462d..0aa107e9a3 100644 --- a/src/jrd/dfw.epp +++ b/src/jrd/dfw.epp @@ -2760,8 +2760,11 @@ static bool create_expression_index(thread_db* tdbb, SSHORT phase, DeferredWork* { idx.idx_expression = static_cast(MET_get_dependencies( tdbb, relation, NULL, 0, NULL, &IDX.RDB$EXPRESSION_BLR, - &idx.idx_expression_statement, &csb, work->dfw_name, obj_expression_index, 0, + nullptr, &csb, work->dfw_name, obj_expression_index, 0, transaction)); + + idx.idx_expression_statement = Statement::makeStatement(tdbb, csb, false, + &idx.idx_expression_desc); } } // end scope @@ -2769,7 +2772,6 @@ static bool create_expression_index(thread_db* tdbb, SSHORT phase, DeferredWork* idx.idx_count = 1; idx.idx_flags |= idx_expressn; - idx.idx_expression->getDesc(tdbb, csb, &idx.idx_expression_desc); idx.idx_rpt[0].idx_itype = DFW_assign_index_type(tdbb, work->dfw_name, idx.idx_expression_desc.dsc_dtype, diff --git a/src/jrd/met.epp b/src/jrd/met.epp index ad3117557f..125761d26e 100644 --- a/src/jrd/met.epp +++ b/src/jrd/met.epp @@ -2620,16 +2620,17 @@ void MET_lookup_index_expression(thread_db* tdbb, jrd_rel* relation, index_desc* { // scope Jrd::ContextPoolHolder context(tdbb, attachment->createPool()); + idx->idx_expression = static_cast(MET_parse_blob( tdbb, relation, &IDX.RDB$EXPRESSION_BLR, &csb, - &idx->idx_expression_statement, false, false)); + nullptr, false, false)); + + idx->idx_expression_statement = Statement::makeStatement(tdbb, csb, false, + &idx->idx_expression_desc); } // end scope } END_FOR - if (csb) - idx->idx_expression->getDesc(tdbb, csb, &idx->idx_expression_desc); - delete csb; // if there is no existing index block for this index, create