You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MB-65809 Handle subquery plans in prepared statements
For a prepared statement with SAVE option, or if plan stability is
turned on (PREPARED_ONLY, AD_HOC, AD_HOC_READ_ONLY), subquery plans
is part of the prepared statement plan. To properly unmarshal such
plans, we now put a couple of extra fields in planContext, which is
part of each operator. The extra fields keep track of the saved
subquery plans from the prepared statement (with the subquery text
as key), as well as unmarshalled subquery plan (with the
*algebra.Select as key).
When we unmarshal plans for a prepared statement, we first look for
the subquery plans, and if found, we generate a map of the saved
subquery plan (subqMap), and also create a new subquery plans
place holder (subqPlans). These two fields are put as part of the
plan context. We then proceed to unmarshal the main query plan. As
the main query plan is unmarshalled, when we need to parse an
expression, and there is a possiblity of encountering a subquery
in the expression, we use the new parsing function (introduced in
the previous checkin) for parsing, which will parse and generate
an expression, but then checks whether the subqMap is available,
if so, gather subqueries from the expression just parsed, and
look for saved subquery plan for each subquery. When found, it'll
then unmarshal the subquery plan, and save the subquery plan with
the new subquery pointer (*algebra.Select) into subqPlans. At the
end of this process when the main query plan is unmarshalled, all
the subquery expressions in the main plan should hopefully have
a plan that has been unmarshalled and saved in subqPlans. Then
subqPlans is put in the prepared plan, which then allows subquery
execution to find the appropriate plans (logic for looking for
subquery plans in a prepared statement already exists).
Change-Id: I6ebd5b8dc6288d3d0607596123962fa5db70c1a7
Reviewed-on: https://review.couchbase.org/c/query/+/242212
Reviewed-by: Sitaram Vemulapalli <sitaram.vemulapalli@couchbase.com>
Tested-by: Bingjie Miao <bingjie.miao@couchbase.com>
0 commit comments