@@ -4185,16 +4185,23 @@ class Item_ident : public Item {
41854185 field_name is normally identical to Item::item_name.
41864186 */
41874187 const char *field_name;
4188-
4189- /*
4190- Cached pointer to table which contains this field, used for the same reason
4191- by prep. stmt. too in case then we have not-fully qualified field.
4192- 0 - means no cached value.
4193- @todo Notice that this is usually the same as Item_field::table_ref.
4194- cached_table should be replaced by table_ref ASAP.
4188+ /* *
4189+ Points to the Table_ref object of the table or view that the column or
4190+ reference is resolved against (only valid after resolving).
4191+ Notice that for the following types of "tables", no Table_ref object is
4192+ assigned and hence m_table_ref is NULL:
4193+ - Temporary tables assigned by join optimizer for sorting and aggregation.
4194+ - Stored procedure dummy tables.
4195+ For fields referencing such tables, table number is always 0, and other
4196+ uses of m_table_ref is not needed.
41954197 */
4196- Table_ref *cached_table;
4197- Query_block *depended_from;
4198+ Table_ref *m_table_ref{nullptr };
4199+ /* *
4200+ For a column or reference that is an outer reference, depended_from points
4201+ to the qualifying query block, otherwise it is NULL
4202+ (only valid after resolving).
4203+ */
4204+ Query_block *depended_from{nullptr };
41984205
41994206 Item_ident (Name_resolution_context *context_arg, const char *db_name_arg,
42004207 const char *table_name_arg, const char *field_name_arg)
@@ -4205,9 +4212,7 @@ class Item_ident : public Item {
42054212 context(context_arg),
42064213 db_name(db_name_arg),
42074214 table_name(table_name_arg),
4208- field_name(field_name_arg),
4209- cached_table(nullptr ),
4210- depended_from(nullptr ) {
4215+ field_name(field_name_arg) {
42114216 item_name.set (field_name_arg);
42124217 }
42134218
@@ -4220,9 +4225,7 @@ class Item_ident : public Item {
42204225 m_alias_of_expr(false ),
42214226 db_name(db_name_arg),
42224227 table_name(table_name_arg),
4223- field_name(field_name_arg),
4224- cached_table(nullptr ),
4225- depended_from(nullptr ) {
4228+ field_name(field_name_arg) {
42264229 item_name.set (field_name_arg);
42274230 }
42284231
@@ -4238,7 +4241,7 @@ class Item_ident : public Item {
42384241 db_name(item->db_name),
42394242 table_name(item->table_name),
42404243 field_name(item->field_name),
4241- cached_table (item->cached_table ),
4244+ m_table_ref (item->m_table_ref ),
42424245 depended_from(item->depended_from) {}
42434246
42444247 bool do_itemize (Parse_context *pc, Item **res) override ;
@@ -4380,16 +4383,6 @@ class Item_field : public Item_ident {
43804383 bool no_conversions) override ;
43814384
43824385 public:
4383- /* *
4384- Table containing this resolved field. This is required e.g for calculation
4385- of table map. Notice that for the following types of "tables",
4386- no Table_ref object is assigned and hence table_ref is NULL:
4387- - Temporary tables assigned by join optimizer for sorting and aggregation.
4388- - Stored procedure dummy tables.
4389- For fields referencing such tables, table number is always 0, and other
4390- uses of table_ref is not needed.
4391- */
4392- Table_ref *table_ref{nullptr };
43934386 // / Source field
43944387 Field *field{nullptr };
43954388
@@ -4581,7 +4574,7 @@ class Item_field : public Item_ident {
45814574 enum_query_type query_type) const override ;
45824575 bool is_outer_field () const override {
45834576 assert (fixed);
4584- return table_ref ->outer_join || table_ref ->outer_join_nest ();
4577+ return m_table_ref ->outer_join || m_table_ref ->outer_join_nest ();
45854578 }
45864579 Field::geometry_type get_geometry_type () const override {
45874580 assert (data_type () == MYSQL_TYPE_GEOMETRY);
@@ -6147,21 +6140,21 @@ class Item_view_ref final : public Item_ref {
61476140 Item_view_ref (Name_resolution_context *context_arg, Item **item,
61486141 const char *db_name_arg, const char *alias_name_arg,
61496142 const char *table_name_arg, const char *field_name_arg,
6150- Table_ref *tl )
6143+ Table_ref *tr )
61516144 : Item_ref(context_arg, item, db_name_arg, alias_name_arg,
61526145 field_name_arg),
61536146 first_inner_table (nullptr ) {
6154- if (tl ->is_view ()) {
6147+ if (tr ->is_view ()) {
61556148 m_orig_db_name = db_name_arg;
61566149 m_orig_table_name = table_name_arg;
61576150 } else {
61586151 assert (db_name_arg == nullptr );
61596152 m_orig_table_name = table_name_arg;
61606153 }
6161- cached_table = tl ;
6162- if (cached_table ->is_inner_table_of_outer_join ()) {
6154+ m_table_ref = tr ;
6155+ if (m_table_ref ->is_inner_table_of_outer_join ()) {
61636156 set_nullable (true );
6164- first_inner_table = cached_table ->any_outer_leaf_table ();
6157+ first_inner_table = m_table_ref ->any_outer_leaf_table ();
61656158 }
61666159 }
61676160
@@ -6198,7 +6191,7 @@ class Item_view_ref final : public Item_ref {
61986191 return !(inner_map & ~INNER_TABLE_BIT) && first_inner_table != nullptr
61996192 ? ref_item ()->real_item ()->type () == FIELD_ITEM
62006193 ? down_cast<Item_field *>(ref_item ()->real_item ())
6201- ->table_ref ->map ()
6194+ ->m_table_ref ->map ()
62026195 : first_inner_table->map ()
62036196 : inner_map;
62046197 }
@@ -6899,8 +6892,8 @@ class Item_cache : public Item_basic_constant {
68996892 add_accum_properties (item);
69006893 if (item->type () == FIELD_ITEM) {
69016894 cached_field = down_cast<Item_field *>(item);
6902- if (cached_field->table_ref != nullptr )
6903- used_table_map = cached_field->table_ref ->map ();
6895+ if (cached_field->m_table_ref != nullptr )
6896+ used_table_map = cached_field->m_table_ref ->map ();
69046897 } else {
69056898 used_table_map = item->used_tables ();
69066899 }
0 commit comments