Hey oleg.smirnov, thank you for your thoughtful feedback. To address your concern, I want to mention a comment at the top of that code block you cited which I've copied here for convenience:
This instance will have been marked as fixed on the basis of its
|
attachment to a SELECT_LEX (during get_qb_hints) but that is
|
insufficient to consider it fixed for the case where a TABLE
|
instance is required but not yet available. If the associated
|
table isn't yet fixed, then reset this instance's fixed value to
|
DELAYED. Later, during fix_hints_for_table(TABLE*), the hint and
|
its corresponding TABLE instance will be marked with fixed=FIXED.
|
To expand on that comment a bit:
- opt_hints_table has not yet been created at the point where it is needed at call-sites (see table.cc:10116 where this new method fix_hints_for_table is called)
- opt_hints_qb does exist and can be used to temporarily fix hints for the table, by setting them to the DELAYED state where they'll be properly fixed later
- temporarily fixing hints relies on TABLE_LIST which does not (as you correctly pointed out) have everything needed to avoid putting hints into the DELAYED state
- A post-condition of Opt_hints_qb::fix_hints_for_table is that Opt_hints_qb instances will be in the DELAYED state, unless they're fixed and their corresponding Opt_hints_table instance exists and is also fixed.
Before my change, fixing hints for tables relied on Opt_hints_qb::fix_hints_for_table(TABLE*) overload implementation. My new overload for that method, Opt_hints_qb::fix_hints_for_table(TABLE_LIST*) is implemented at the same layer in the abstraction. Table-level hint fixing is also done on Opt_hints_qb instance (see the setup_tables function in sql_base.cc). There, in setup_tables, we check if query block hints are initialized and if there is no opt_hints_table, then create the new opt_hints_table instance by calling fix_hints_for_table. I'm doing the same, but adding to the condition that the opt_hints_table instance may not exist or if it does, that hints were delayed.
A consequence of my approach with TABLE_LIST appears to be the missing warning that you point out. Maybe that can be fixed? Or maybe it is a limitation of the hints architecture? I'm looking to see how we can solve that problem.
oleg.smirnov maybe this is related to the TABLE_LIST hint API that I added, I will check.