diff options
Diffstat (limited to 'sql/sql_select.h')
-rw-r--r-- | sql/sql_select.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/sql/sql_select.h b/sql/sql_select.h index d5a1bf82bc8..2f0722db635 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -56,16 +56,16 @@ typedef struct st_table_ref */ key_part_map null_rejecting; table_map depend_map; // Table depends on these tables. - byte *null_ref_key; // null byte position in the key_buf. - // used for REF_OR_NULL optimization. + /* null byte position in the key_buf. Used for REF_OR_NULL optimization */ + byte *null_ref_key; } TABLE_REF; + /* -** CACHE_FIELD and JOIN_CACHE is used on full join to cache records in outer -** table + CACHE_FIELD and JOIN_CACHE is used on full join to cache records in outer + table */ - typedef struct st_cache_field { char *str; uint length,blob_length; @@ -83,7 +83,7 @@ typedef struct st_join_cache { /* -** The structs which holds the join connections and join states + The structs which holds the join connections and join states */ enum join_type { JT_UNKNOWN,JT_SYSTEM,JT_CONST,JT_EQ_REF,JT_REF,JT_MAYBE_REF, JT_ALL, JT_RANGE, JT_NEXT, JT_FT, JT_REF_OR_NULL, @@ -103,6 +103,7 @@ typedef enum_nested_loop_state typedef int (*Read_record_func)(struct st_join_table *tab); Next_select_func setup_end_select_func(JOIN *join); + typedef struct st_join_table { st_join_table() {} /* Remove gcc warning */ TABLE *table; @@ -134,6 +135,7 @@ typedef struct st_join_table { uint used_fields,used_fieldlength,used_blobs; enum join_type type; bool cached_eq_ref_table,eq_ref_table,not_used_in_distinct; + bool sorted; TABLE_REF ref; JOIN_CACHE cache; JOIN *join; @@ -447,10 +449,11 @@ class store_key :public Sql_alloc { if (field_arg->type() == FIELD_TYPE_BLOB) { - /* Key segments are always packed with a 2 byte length prefix */ - to_field=new Field_varstring(ptr, length, 2, (uchar*) null, 1, - Field::NONE, field_arg->field_name, - field_arg->table, field_arg->charset()); + /* Key segments are always packed with a 2 byte length prefix */ + to_field= new Field_varstring(ptr, length, 2, (uchar*) null, 1, + Field::NONE, field_arg->field_name, + field_arg->table->s, field_arg->charset()); + to_field->init(field_arg->table); } else to_field=field_arg->new_key_field(thd->mem_root, field_arg->table, @@ -480,7 +483,11 @@ class store_key_field: public store_key } enum store_key_result copy() { + TABLE *table= copy_field.to_field->table; + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, + table->write_set); copy_field.do_copy(©_field); + dbug_tmp_restore_column_map(table->write_set, old_map); return err != 0 ? STORE_KEY_FATAL : STORE_KEY_OK; } const char *name() const { return field_name; } @@ -500,7 +507,11 @@ public: {} enum store_key_result copy() { + TABLE *table= to_field->table; + my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, + table->write_set); int res= item->save_in_field(to_field, 1); + dbug_tmp_restore_column_map(table->write_set, old_map); return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res); } @@ -537,7 +548,7 @@ public: const char *name() const { return "const"; } }; -bool cp_buffer_from_ref(THD *thd, TABLE_REF *ref); +bool cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref); bool error_if_full_join(JOIN *join); int report_error(TABLE *table, int error); int safe_index_read(JOIN_TAB *tab); |