1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
21
classes to use when handling where clause
24
#ifdef USE_PRAGMA_INTERFACE
25
#pragma interface /* gcc class implementation */
30
/* Values in optimize */
31
#define KEY_OPTIMIZE_EXISTS 1
32
#define KEY_OPTIMIZE_REF_OR_NULL 2
34
typedef struct keyuse_t {
36
Item *val; /**< or value if no field */
37
table_map used_tables;
39
uint optimize; // 0, or KEY_OPTIMIZE_*
40
key_part_map keypart_map;
41
ha_rows ref_table_rows;
43
If true, the comparison this value was created from will not be
44
satisfied if val has NULL 'value'.
48
!NULL - This KEYUSE was created from an equality that was wrapped into
49
an Item_func_trig_cond. This means the equality (and validity of
50
this KEYUSE element) can be turned on and off. The on/off state
51
is indicted by the pointed value:
52
*cond_guard == TRUE <=> equality condition is on
53
*cond_guard == FALSE <=> equality condition is off
55
NULL - Otherwise (the source equality can't be turned off)
59
0..64 <=> This was created from semi-join IN-equality # sj_pred_no.
67
typedef struct st_table_ref
70
uint key_parts; ///< num of ...
71
uint key_length; ///< length of key_buff
73
uchar *key_buff; ///< value to look for with key
74
uchar *key_buff2; ///< key_buff+key_length
75
store_key **key_copy; //
76
Item **items; ///< val()'s for each keypart
78
Array of pointers to trigger variables. Some/all of the pointers may be
79
NULL. The ref access can be used iff
81
for each used key part i, (!cond_guards[i] || *cond_guards[i])
83
This array is used by subquery code. The subquery code may inject
84
triggered conditions, i.e. conditions that can be 'switched off'. A ref
85
access created from such condition is not valid when at least one of the
86
underlying conditions is switched off (see subquery code for more details)
90
(null_rejecting & (1<<i)) means the condition is '=' and no matching
91
rows will be produced if items[i] IS NULL (see add_not_null_conds())
93
key_part_map null_rejecting;
94
table_map depend_map; ///< Table depends on these tables.
95
/* null byte position in the key_buf. Used for REF_OR_NULL optimization */
99
TRUE <=> disable the "cache" as doing lookup with the same key value may
100
produce different results (because of Index Condition Pushdown)
107
CACHE_FIELD and JOIN_CACHE is used on full join to cache records in outer
111
typedef struct st_cache_field {
113
Where source data is located (i.e. this points to somewhere in
117
uint length; /* Length of data at *str, in bytes */
118
uint blob_length; /* Valid IFF blob_field != 0 */
119
Field_blob *blob_field;
120
bool strip; /* TRUE <=> Strip endspaces ?? */
122
TABLE *get_rowid; /* _ != NULL <=> */
126
typedef struct st_join_cache
129
uchar *pos; /* Start of free space in the buffer */
131
uint records; /* # of row cominations currently stored in the cache */
135
Number of fields (i.e. cache_field objects). Those correspond to table
136
columns, and there are also special fields for
137
- table's column null bits
138
- table's null-complementation byte
139
- [new] table's rowid.
145
CACHE_FIELD **blob_ptr;
151
The structs which holds the join connections and join states
153
enum join_type { JT_UNKNOWN,JT_SYSTEM,JT_CONST,JT_EQ_REF,JT_REF,JT_MAYBE_REF,
154
JT_ALL, JT_RANGE, JT_NEXT, JT_REF_OR_NULL,
155
JT_UNIQUE_SUBQUERY, JT_INDEX_SUBQUERY, JT_INDEX_MERGE};
159
enum enum_nested_loop_state
161
NESTED_LOOP_KILLED= -2, NESTED_LOOP_ERROR= -1,
162
NESTED_LOOP_OK= 0, NESTED_LOOP_NO_MORE_ROWS= 1,
163
NESTED_LOOP_QUERY_LIMIT= 3, NESTED_LOOP_CURSOR_LIMIT= 4
167
/* Values for JOIN_TAB::packed_info */
168
#define TAB_INFO_HAVE_VALUE 1
169
#define TAB_INFO_USING_INDEX 2
170
#define TAB_INFO_USING_WHERE 4
171
#define TAB_INFO_FULL_SCAN_ON_NULL 8
175
typedef enum_nested_loop_state
176
(*Next_select_func)(JOIN *, struct st_join_table *, bool);
177
typedef int (*Read_record_func)(struct st_join_table *tab);
178
Next_select_func setup_end_select_func(JOIN *join);
181
typedef struct st_join_table {
182
st_join_table() {} /* Remove gcc warning */
184
KEYUSE *keyuse; /**< pointer to first used key */
187
QUICK_SELECT_I *quick;
189
The value of select_cond before we've attempted to do Index Condition
190
Pushdown. We may need to restore everything back if we first choose one
191
index but then reconsider (see test_if_skip_sort_order() for such
193
NULL means no index condition pushdown was performed.
195
Item *pre_idx_push_select_cond;
196
Item **on_expr_ref; /**< pointer to the associated on expression */
197
COND_EQUAL *cond_equal; /**< multiple equalities for the on expression */
198
st_join_table *first_inner; /**< first inner table for including outerjoin */
199
bool found; /**< true after all matches or null complement */
200
bool not_null_compl;/**< true before null complement is added */
201
st_join_table *last_inner; /**< last table table for embedding outer join */
202
st_join_table *first_upper; /**< first inner table for embedding outer join */
203
st_join_table *first_unmatched; /**< used for optimization purposes only */
205
/* Special content for EXPLAIN 'Extra' column or NULL if none */
208
Bitmap of TAB_INFO_* bits that encodes special line for EXPLAIN 'Extra'
209
column, or 0 if there is no info.
213
Read_record_func read_first_record;
214
Next_select_func next_select;
215
READ_RECORD read_record;
217
Currently the following two fields are used only for a [NOT] IN subquery
218
if it is executed by an alternative full table scan when the left operand of
219
the subquery predicate is evaluated to NULL.
221
Read_record_func save_read_first_record;/* to save read_first_record */
222
int (*save_read_record) (READ_RECORD *);/* to save read_record.read_record */
224
key_map const_keys; /**< Keys with constant part */
225
key_map checked_keys; /**< Keys checked in find_best */
227
key_map keys; /**< all keys with can be used */
229
/* Either #rows in the table or 1 for const table. */
232
Number of records that will be scanned (yes scanned, not returned) by the
233
best 'independent' access method, i.e. table scan or QUICK_*_SELECT)
235
ha_rows found_records;
237
Cost of accessing the table using "ALL" or range/index_merge access
238
method (but not 'index' for some reason), i.e. this matches method which
239
E(#records) is in found_records.
243
table_map dependent,key_dependent;
244
uint use_quick,index;
245
uint status; ///< Save status for cache
246
uint used_fields,used_fieldlength,used_blobs;
248
bool cached_eq_ref_table,eq_ref_table,not_used_in_distinct;
249
/* TRUE <=> index-based access method must return records in order */
252
If it's not 0 the number stored this field indicates that the index
253
scan has been chosen to access the table data and we expect to scan
254
this number of rows for the table.
260
/** Bitmap of nested joins this table is part of */
262
/* SemiJoinDuplicateElimination variables: */
264
Embedding SJ-nest (may be not the direct parent), or NULL if none.
265
This variable holds the result of table pullout.
267
TABLE_LIST *emb_sj_nest;
269
/* Variables for semi-join duplicate elimination */
270
SJ_TMP_TABLE *flush_weedout_table;
271
SJ_TMP_TABLE *check_weed_out_table;
272
struct st_join_table *do_firstmatch;
275
ptr - this join tab should do an InsideOut scan. Points
276
to the tab for which we'll need to check tab->found_match.
278
NULL - Not an insideout scan.
280
struct st_join_table *insideout_match_tab;
281
uchar *insideout_buf; // Buffer to save index tuple to be able to skip dups
283
/* Used by InsideOut scan. Just set to true when have found a row. */
287
/* If set, the rowid of this table must be put into the temptable. */
290
If set, one should call h->position() to obtain the rowid,
291
otherwise, the rowid is assumed to already be in h->ref
292
(this is because join caching and filesort() save the rowid and then
293
put it back into h->ref)
297
/* A set of flags from the above enum */
298
int rowid_keep_flags;
301
/* NestedOuterJoins: Bitmap of nested joins this table is part of */
302
nested_join_map embedding_map;
305
inline bool is_using_loose_index_scan()
307
return (select && select->quick &&
308
(select->quick->get_type() ==
309
QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX));
313
enum_nested_loop_state sub_select_cache(JOIN *join, JOIN_TAB *join_tab, bool
315
enum_nested_loop_state sub_select(JOIN *join,JOIN_TAB *join_tab, bool
317
enum_nested_loop_state end_send_group(JOIN *join, JOIN_TAB *join_tab,
318
bool end_of_records);
319
enum_nested_loop_state end_write_group(JOIN *join, JOIN_TAB *join_tab,
320
bool end_of_records);
323
Information about a position of table within a join order. Used in join
326
typedef struct st_position
329
The "fanout": number of output rows that will be produced (after
330
pushed down selection condition is applied) per each row combination of
336
Cost accessing the table in course of the entire complete join execution,
337
i.e. cost of one access method use (e.g. 'range' or 'ref' scan ) times
338
number the access method will be invoked.
344
NULL - 'index' or 'range' or 'index_merge' or 'ALL' access is used.
345
Other - [eq_]ref[_or_null] access is used. Pointer to {t.keypart1 = expr}
349
/* If ref-based access is used: bitmap of tables this table depends on */
350
table_map ref_depend_map;
352
bool use_insideout_scan;
356
typedef struct st_rollup
358
enum State { STATE_NONE, STATE_INITED, STATE_READY };
360
Item_null_result **null_items;
361
Item ***ref_pointer_arrays;
367
Describes use of one temporary table to weed out join duplicates.
371
- create a temp table
372
- when we reach the weed-out tab, walk through rowid-ed tabs and
374
For each table we need
379
class SJ_TMP_TABLE : public Sql_alloc
382
/* Array of pointers to tables that should be "used" */
400
MI_COLUMNDEF *start_recinfo;
401
MI_COLUMNDEF *recinfo;
403
/* Pointer to next table (next->start_idx > this->end_idx) */
408
class JOIN :public Sql_alloc
410
JOIN(const JOIN &rhs); /**< not implemented */
411
JOIN& operator=(const JOIN &rhs); /**< not implemented */
413
JOIN_TAB *join_tab,**best_ref;
414
JOIN_TAB **map2table; ///< mapping between table indexes and JOIN_TABs
415
JOIN_TAB *join_tab_save; ///< saved join_tab for subquery reexecution
416
TABLE **table,**all_tables;
418
The table which has an index that allows to produce the requried ordering.
419
A special value of 0x1 means that the ordering will be produced by
420
passing 1st non-const table to filesort(). NULL means no such table exists.
422
TABLE *sort_by_table;
423
uint tables; /**< Number of tables in the join */
424
uint outer_tables; /**< Number of tables that are not inside semijoin */
426
uint send_group_parts;
427
bool sort_and_group,first_record,full_join,group, no_field_update;
430
TRUE when we want to resume nested loop iterations when
431
fetching data from a cursor
433
bool resume_nested_loop;
434
table_map const_table_map,found_const_table_map,outer_join;
435
ha_rows send_records,found_records,examined_rows,row_limit, select_limit;
437
Used to fetch no more than given amount of rows per one
438
fetch operation of server side cursor.
439
The value is checked in end_send and end_send_group in fashion, similar
441
- fetch_limit= HA_POS_ERROR if there is no cursor.
442
- when we open a cursor, we set fetch_limit to 0,
443
- on each fetch iteration we add num_rows to fetch to fetch_limit
446
POSITION positions[MAX_TABLES+1],best_positions[MAX_TABLES+1];
449
Bitmap of nested joins embedding the position at the end of the current
450
partial join (valid only during join optimizer run).
452
nested_join_map cur_embedding_map;
456
List<Cached_item> group_fields, group_fields_cache;
458
/// used to store 2 possible tmp table of SELECT
459
TABLE *exec_tmp_table1, *exec_tmp_table2;
461
Item_sum **sum_funcs, ***sum_funcs_end;
462
/** second copy of sumfuncs (for queries with 2 temporary tables */
463
Item_sum **sum_funcs2, ***sum_funcs_end2;
465
Item *tmp_having; ///< To store having when processed temporary table
466
Item *having_history; ///< Store having for explain
467
ulonglong select_options;
468
select_result *result;
469
TMP_TABLE_PARAM tmp_table_param;
471
/// unit structure (with global parameters) for this select
472
SELECT_LEX_UNIT *unit;
473
/// select that processed
474
SELECT_LEX *select_lex;
476
TRUE <=> optimizer must not mark any table as a constant table.
477
This is needed for subqueries in form "a IN (SELECT .. UNION SELECT ..):
478
when we optimize the select that reads the results of the union from a
479
temporary table, we must not mark the temp. table as constant because
480
the number of rows in it may vary from one subquery execution to another.
482
bool no_const_tables;
484
JOIN *tmp_join; ///< copy of this JOIN to be used with temporary tables
485
ROLLUP rollup; ///< Used with rollup
487
bool select_distinct; ///< Set if SELECT DISTINCT
489
If we have the GROUP BY statement in the query,
490
but the group_list was emptied by optimizer, this
492
It happens when fields in the GROUP BY are from
495
bool group_optimized_away;
498
simple_xxxxx is set if ORDER/GROUP BY doesn't include any references
499
to other tables than the first non-constant table in the JOIN.
500
It's also set if ORDER/GROUP BY is empty.
502
bool simple_order, simple_group;
504
Is set only in case if we have a GROUP BY clause
505
and no ORDER BY after constant elimination of 'order'.
508
/** Is set if we have a GROUP BY and we have ORDER BY on a constant. */
509
bool skip_sort_order;
511
bool need_tmp, hidden_group_fields;
512
DYNAMIC_ARRAY keyuse;
513
Item::cond_result cond_value, having_value;
514
List<Item> all_fields; ///< to store all fields that used in query
515
///Above list changed to use temporary table
516
List<Item> tmp_all_fields1, tmp_all_fields2, tmp_all_fields3;
517
///Part, shared with list above, emulate following list
518
List<Item> tmp_fields_list1, tmp_fields_list2, tmp_fields_list3;
519
List<Item> &fields_list; ///< hold field list passed to mysql_select
522
ORDER *order, *group_list, *proc_param; //hold parameters of mysql_select
523
COND *conds; // ---"---
524
Item *conds_history; // store WHERE for explain
525
TABLE_LIST *tables_list; ///<hold 'tables' parameter of mysql_select
526
List<TABLE_LIST> *join_list; ///< list of joined tables in reverse order
527
COND_EQUAL *cond_equal;
528
SQL_SELECT *select; ///<created in optimisation phase
529
JOIN_TAB *return_tab; ///<used only for outer joins
530
Item **ref_pointer_array; ///<used pointer reference for this select
531
// Copy of above to be used with different lists
532
Item **items0, **items1, **items2, **items3, **current_ref_pointer_array;
533
uint ref_pointer_array_size; ///< size of above in bytes
534
const char *zero_result_cause; ///< not 0 if exec must return zero result
536
bool union_part; ///< this subselect is part of union
537
bool optimized; ///< flag to avoid double optimization in EXPLAIN
539
Array<Item_in_subselect> sj_subselects;
541
/* Descriptions of temporary tables used to weed-out semi-join duplicates */
542
SJ_TMP_TABLE *sj_tmp_tables;
544
table_map cur_emb_sj_nests;
547
storage for caching buffers allocated during query execution.
548
These buffers allocations need to be cached as the thread memory pool is
549
cleared only at the end of the execution of the whole query and not caching
550
allocations that occur in repetition at execution time will result in
551
excessive memory usage.
553
SORT_FIELD *sortorder; // make_unireg_sortorder()
554
TABLE **table_reexec; // make_simple_join()
555
JOIN_TAB *join_tab_reexec; // make_simple_join()
556
/* end of allocation caching storage */
558
JOIN(THD *thd_arg, List<Item> &fields_arg, ulonglong select_options_arg,
559
select_result *result_arg)
560
:fields_list(fields_arg), sj_subselects(thd_arg->mem_root, 4)
562
init(thd_arg, fields_arg, select_options_arg, result_arg);
565
void init(THD *thd_arg, List<Item> &fields_arg, ulonglong select_options_arg,
566
select_result *result_arg)
568
join_tab= join_tab_save= 0;
576
resume_nested_loop= FALSE;
579
fetch_limit= HA_POS_ERROR;
587
sum_funcs= sum_funcs2= 0;
588
having= tmp_having= having_history= 0;
589
select_options= select_options_arg;
592
select_lex= 0; //for safety
594
select_distinct= test(select_options & SELECT_DISTINCT);
600
hidden_group_fields= 0; /*safety*/
604
ref_pointer_array= items0= items1= items2= items3= 0;
605
ref_pointer_array_size= 0;
606
zero_result_cause= 0;
609
group_optimized_away= 0;
611
all_fields= fields_arg;
612
fields_list= fields_arg;
613
bzero((char*) &keyuse,sizeof(keyuse));
614
tmp_table_param.init();
615
tmp_table_param.end_write_records= HA_POS_ERROR;
616
rollup.state= ROLLUP::STATE_NONE;
619
no_const_tables= FALSE;
622
int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num,
623
COND *conds, uint og_num, ORDER *order, ORDER *group,
624
Item *having, ORDER *proc_param, SELECT_LEX *select,
625
SELECT_LEX_UNIT *unit);
631
bool alloc_func_list();
632
bool flatten_subqueries();
633
bool setup_subquery_materialization();
634
bool make_sum_func_list(List<Item> &all_fields, List<Item> &send_fields,
635
bool before_group_by, bool recompute= FALSE);
637
inline void set_items_ref_array(Item **ptr)
639
memcpy((char*) ref_pointer_array, (char*) ptr, ref_pointer_array_size);
640
current_ref_pointer_array= ptr;
642
inline void init_items_ref_array()
644
items0= ref_pointer_array + all_fields.elements;
645
memcpy(items0, ref_pointer_array, ref_pointer_array_size);
646
current_ref_pointer_array= items0;
650
bool rollup_make_fields(List<Item> &all_fields, List<Item> &fields,
652
int rollup_send_data(uint idx);
653
int rollup_write_data(uint idx, TABLE *table);
654
void remove_subq_pushed_predicates(Item **where);
656
Release memory and, if possible, the open tables held by this execution
657
plan (and nested plans). It's used to release some tables before
658
the end of execution in order to increase concurrency and reduce
662
/** Cleanup this JOIN, possibly for reuse */
663
void cleanup(bool full);
665
bool save_join_tab();
666
bool init_save_join_tab();
667
bool send_row_on_empty_set()
669
return (do_send_rows && tmp_table_param.sum_func_count != 0 &&
672
bool change_result(select_result *result);
673
bool is_top_level_join() const
675
return (unit == &thd->lex->unit && (unit->fake_select_lex == 0 ||
676
select_lex == unit->fake_select_lex));
681
typedef struct st_select_check {
682
uint const_ref,reg_ref;
685
extern const char *join_type_str[];
686
void TEST_join(JOIN *join);
688
/* Extern functions in sql_select.cc */
689
bool store_val_in_field(Field *field, Item *val, enum_check_fields check_flag);
690
TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
691
ORDER *group, bool distinct, bool save_sum_fields,
692
ulonglong select_options, ha_rows rows_limit,
694
void free_tmp_table(THD *thd, TABLE *entry);
695
void count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param,
696
List<Item> &fields, bool reset_with_sum_func);
697
bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,
698
Item **ref_pointer_array,
699
List<Item> &new_list1, List<Item> &new_list2,
700
uint elements, List<Item> &fields);
701
void copy_fields(TMP_TABLE_PARAM *param);
702
void copy_funcs(Item **func_ptr);
703
bool create_myisam_from_heap(THD *thd, TABLE *table,
704
MI_COLUMNDEF *start_recinfo,
705
MI_COLUMNDEF **recinfo,
706
int error, bool ignore_last_dupp_key_error);
707
uint find_shortest_key(TABLE *table, const key_map *usable_keys);
708
Field* create_tmp_field_from_field(THD *thd, Field* org_field,
709
const char *name, TABLE *table,
710
Item_field *item, uint convert_blob_length);
712
/* functions from opt_sum.cc */
713
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);
714
int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds);
716
/* from sql_delete.cc, used by opt_range.cc */
717
extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b);
719
/** class to copying an field/item to a key struct */
721
class store_key :public Sql_alloc
724
bool null_key; /* TRUE <=> the value of the key has a null part */
725
enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV };
726
store_key(THD *thd, Field *field_arg, uchar *ptr, uchar *null, uint length)
727
:null_key(0), null_ptr(null), err(0)
729
if (field_arg->type() == MYSQL_TYPE_BLOB)
732
Key segments are always packed with a 2 byte length prefix.
733
See mi_rkey for details.
735
to_field= new Field_varstring(ptr, length, 2, null, 1,
736
Field::NONE, field_arg->field_name,
737
field_arg->table->s, field_arg->charset());
738
to_field->init(field_arg->table);
741
to_field=field_arg->new_key_field(thd->mem_root, field_arg->table,
744
virtual ~store_key() {} /** Not actually needed */
745
virtual const char *name() const=0;
748
@brief sets ignore truncation warnings mode and calls the real copy method
750
@details this function makes sure truncation warnings when preparing the
751
key buffers don't end up as errors (because of an enclosing INSERT/UPDATE).
753
enum store_key_result copy()
755
enum store_key_result result;
756
THD *thd= to_field->table->in_use;
757
enum_check_fields saved_count_cuted_fields= thd->count_cuted_fields;
759
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
761
result= copy_inner();
763
thd->count_cuted_fields= saved_count_cuted_fields;
769
Field *to_field; // Store data here
773
virtual enum store_key_result copy_inner()=0;
777
class store_key_field: public store_key
779
Copy_field copy_field;
780
const char *field_name;
782
store_key_field(THD *thd, Field *to_field_arg, uchar *ptr,
784
uint length, Field *from_field, const char *name_arg)
785
:store_key(thd, to_field_arg,ptr,
786
null_ptr_arg ? null_ptr_arg : from_field->maybe_null() ? &err
787
: (uchar*) 0, length), field_name(name_arg)
791
copy_field.set(to_field,from_field,0);
794
const char *name() const { return field_name; }
797
enum store_key_result copy_inner()
799
TABLE *table= copy_field.to_field->table;
800
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table,
802
copy_field.do_copy(©_field);
803
dbug_tmp_restore_column_map(table->write_set, old_map);
804
null_key= to_field->is_null();
805
return err != 0 ? STORE_KEY_FATAL : STORE_KEY_OK;
810
class store_key_item :public store_key
815
store_key_item(THD *thd, Field *to_field_arg, uchar *ptr,
816
uchar *null_ptr_arg, uint length, Item *item_arg)
817
:store_key(thd, to_field_arg, ptr,
818
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
819
&err : (uchar*) 0, length), item(item_arg)
821
const char *name() const { return "func"; }
824
enum store_key_result copy_inner()
826
TABLE *table= to_field->table;
827
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table,
829
int res= item->save_in_field(to_field, 1);
830
dbug_tmp_restore_column_map(table->write_set, old_map);
831
null_key= to_field->is_null() || item->null_value;
832
return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res);
837
class store_key_const_item :public store_key_item
841
store_key_const_item(THD *thd, Field *to_field_arg, uchar *ptr,
842
uchar *null_ptr_arg, uint length,
844
:store_key_item(thd, to_field_arg,ptr,
845
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
846
&err : (uchar*) 0, length, item_arg), inited(0)
849
const char *name() const { return "const"; }
852
enum store_key_result copy_inner()
858
if ((res= item->save_in_field(to_field, 1)))
864
null_key= to_field->is_null() || item->null_value;
865
return (err > 2 ? STORE_KEY_FATAL : (store_key_result) err);
869
bool cp_buffer_from_ref(THD *thd, TABLE *table, TABLE_REF *ref);
870
bool error_if_full_join(JOIN *join);
871
int report_error(TABLE *table, int error);
872
int safe_index_read(JOIN_TAB *tab);
873
COND *remove_eq_conds(THD *thd, COND *cond, Item::cond_result *cond_value);
874
int test_if_item_cache_changed(List<Cached_item> &list);