~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/sql_select.h

  • Committer: Eric Herman
  • Date: 2008-12-06 19:42:46 UTC
  • mto: (656.1.6 devel)
  • mto: This revision was merged to the branch mainline in revision 665.
  • Revision ID: eric@mysql.com-20081206194246-5cdexuu81i366eek
removed trailing whitespace with simple script:

for file in $(find . -name "*.c") $(find . -name "*.cc") $(find . -name "*.h"); do ruby -pe 'gsub(/\s+$/, $/)' < $file > $file.out; mv $file.out $file; done;

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
  bool null_rejecting;
61
61
  /*
62
62
    !NULL - This KEYUSE was created from an equality that was wrapped into
63
 
            an Item_func_trig_cond. This means the equality (and validity of 
64
 
            this KEYUSE element) can be turned on and off. The on/off state 
 
63
            an Item_func_trig_cond. This means the equality (and validity of
 
64
            this KEYUSE element) can be turned on and off. The on/off state
65
65
            is indicted by the pointed value:
66
66
              *cond_guard == true <=> equality condition is on
67
67
              *cond_guard == false <=> equality condition is off
88
88
  unsigned char *key_buff2;               ///< key_buff+key_length
89
89
  store_key     **key_copy;               //
90
90
  Item          **items;                  ///< val()'s for each keypart
91
 
  /*  
 
91
  /*
92
92
    Array of pointers to trigger variables. Some/all of the pointers may be
93
93
    NULL.  The ref access can be used iff
94
 
    
95
 
      for each used key part i, (!cond_guards[i] || *cond_guards[i]) 
 
94
 
 
95
      for each used key part i, (!cond_guards[i] || *cond_guards[i])
96
96
 
97
97
    This array is used by subquery code. The subquery code may inject
98
 
    triggered conditions, i.e. conditions that can be 'switched off'. A ref 
99
 
    access created from such condition is not valid when at least one of the 
 
98
    triggered conditions, i.e. conditions that can be 'switched off'. A ref
 
99
    access created from such condition is not valid when at least one of the
100
100
    underlying conditions is switched off (see subquery code for more details)
101
101
  */
102
102
  bool          **cond_guards;
123
123
*/
124
124
 
125
125
typedef struct st_cache_field {
126
 
  /* 
127
 
    Where source data is located (i.e. this points to somewhere in 
 
126
  /*
 
127
    Where source data is located (i.e. this points to somewhere in
128
128
    tableX->record[0])
129
129
  */
130
130
  unsigned char *str;
137
137
} CACHE_FIELD;
138
138
 
139
139
 
140
 
typedef struct st_join_cache 
 
140
typedef struct st_join_cache
141
141
{
142
142
  unsigned char *buff;
143
143
  unsigned char *pos;    /* Start of free space in the buffer */
144
144
  unsigned char *end;
145
145
  uint32_t records;  /* # of row cominations currently stored in the cache */
146
146
  uint32_t record_nr;
147
 
  uint32_t ptr_record; 
148
 
  /* 
 
147
  uint32_t ptr_record;
 
148
  /*
149
149
    Number of fields (i.e. cache_field objects). Those correspond to table
150
150
    columns, and there are also special fields for
151
151
     - table's column null bits
152
152
     - table's null-complementation byte
153
153
     - [new] table's rowid.
154
154
  */
155
 
  uint32_t fields; 
156
 
  uint32_t length; 
 
155
  uint32_t fields;
 
156
  uint32_t length;
157
157
  uint32_t blobs;
158
158
  CACHE_FIELD *field;
159
159
  CACHE_FIELD **blob_ptr;
199
199
  SQL_SELECT    *select;
200
200
  COND          *select_cond;
201
201
  QUICK_SELECT_I *quick;
202
 
  /* 
 
202
  /*
203
203
    The value of select_cond before we've attempted to do Index Condition
204
204
    Pushdown. We may need to restore everything back if we first choose one
205
205
    index but then reconsider (see test_if_skip_sort_order() for such
215
215
  st_join_table *last_inner;    /**< last table table for embedding outer join */
216
216
  st_join_table *first_upper;  /**< first inner table for embedding outer join */
217
217
  st_join_table *first_unmatched; /**< used for optimization purposes only     */
218
 
  
 
218
 
219
219
  /* Special content for EXPLAIN 'Extra' column or NULL if none */
220
220
  const char    *info;
221
 
  /* 
 
221
  /*
222
222
    Bitmap of TAB_INFO_* bits that encodes special line for EXPLAIN 'Extra'
223
223
    column, or 0 if there is no info.
224
224
  */
227
227
  Read_record_func read_first_record;
228
228
  Next_select_func next_select;
229
229
  READ_RECORD   read_record;
230
 
  /* 
 
230
  /*
231
231
    Currently the following two fields are used only for a [NOT] IN subquery
232
232
    if it is executed by an alternative full table scan when the left operand of
233
233
    the subquery predicate is evaluated to NULL.
234
 
  */  
235
 
  Read_record_func save_read_first_record;/* to save read_first_record */ 
 
234
  */
 
235
  Read_record_func save_read_first_record;/* to save read_first_record */
236
236
  int (*save_read_record) (READ_RECORD *);/* to save read_record.read_record */
237
237
  double        worst_seeks;
238
238
  key_map       const_keys;                     /**< Keys with constant part */
253
253
    E(#records) is in found_records.
254
254
  */
255
255
  ha_rows       read_time;
256
 
  
 
256
 
257
257
  table_map     dependent,key_dependent;
258
258
  uint          use_quick,index;
259
259
  uint          status;                         ///< Save status for cache
262
262
  bool          cached_eq_ref_table,eq_ref_table,not_used_in_distinct;
263
263
  /* true <=> index-based access method must return records in order */
264
264
  bool          sorted;
265
 
  /* 
 
265
  /*
266
266
    If it's not 0 the number stored this field indicates that the index
267
 
    scan has been chosen to access the table data and we expect to scan 
 
267
    scan has been chosen to access the table data and we expect to scan
268
268
    this number of rows for the table.
269
 
  */ 
270
 
  ha_rows       limit; 
 
269
  */
 
270
  ha_rows       limit;
271
271
  TABLE_REF     ref;
272
272
  JOIN_CACHE    cache;
273
273
  JOIN          *join;
284
284
  SJ_TMP_TABLE  *flush_weedout_table;
285
285
  SJ_TMP_TABLE  *check_weed_out_table;
286
286
  struct st_join_table  *do_firstmatch;
287
 
 
288
 
  /* 
289
 
     ptr  - this join tab should do an InsideOut scan. Points 
 
287
 
 
288
  /*
 
289
     ptr  - this join tab should do an InsideOut scan. Points
290
290
            to the tab for which we'll need to check tab->found_match.
291
291
 
292
292
     NULL - Not an insideout scan.
297
297
  /* Used by InsideOut scan. Just set to true when have found a row. */
298
298
  bool found_match;
299
299
 
300
 
  enum { 
 
300
  enum {
301
301
    /* If set, the rowid of this table must be put into the temptable. */
302
 
    KEEP_ROWID=1, 
303
 
    /* 
 
302
    KEEP_ROWID=1,
 
303
    /*
304
304
      If set, one should call h->position() to obtain the rowid,
305
305
      otherwise, the rowid is assumed to already be in h->ref
306
306
      (this is because join caching and filesort() save the rowid and then
346
346
  */
347
347
  double records_read;
348
348
 
349
 
  /* 
 
349
  /*
350
350
    Cost accessing the table in course of the entire complete join execution,
351
 
    i.e. cost of one access method use (e.g. 'range' or 'ref' scan ) times 
 
351
    i.e. cost of one access method use (e.g. 'range' or 'ref' scan ) times
352
352
    number the access method will be invoked.
353
353
  */
354
354
  double read_time;
416
416
  */
417
417
  ha_rows  fetch_limit;
418
418
  POSITION positions[MAX_TABLES+1],best_positions[MAX_TABLES+1];
419
 
  
 
419
 
420
420
  /* *
421
 
    Bitmap of nested joins embedding the position at the end of the current 
 
421
    Bitmap of nested joins embedding the position at the end of the current
422
422
    partial join (valid only during join optimizer run).
423
423
  */
424
424
  nested_join_map cur_embedding_map;
444
444
  SELECT_LEX_UNIT *unit;
445
445
  /// select that processed
446
446
  SELECT_LEX *select_lex;
447
 
  /** 
 
447
  /**
448
448
    true <=> optimizer must not mark any table as a constant table.
449
449
    This is needed for subqueries in form "a IN (SELECT .. UNION SELECT ..):
450
450
    when we optimize the select that reads the results of the union from a
451
451
    temporary table, we must not mark the temp. table as constant because
452
452
    the number of rows in it may vary from one subquery execution to another.
453
453
  */
454
 
  bool no_const_tables; 
455
 
  
 
454
  bool no_const_tables;
 
455
 
456
456
  JOIN *tmp_join; ///< copy of this JOIN to be used with temporary tables
457
457
  ROLLUP rollup;                                ///< Used with rollup
458
458
 
504
504
  Item **items0, **items1, **items2, **items3, **current_ref_pointer_array;
505
505
  uint32_t ref_pointer_array_size; ///< size of above in bytes
506
506
  const char *zero_result_cause; ///< not 0 if exec must return zero result
507
 
  
508
 
  bool union_part; ///< this subselect is part of union 
 
507
 
 
508
  bool union_part; ///< this subselect is part of union
509
509
  bool optimized; ///< flag to avoid double optimization in EXPLAIN
510
 
  
 
510
 
511
511
  Array<Item_in_subselect> sj_subselects;
512
512
 
513
513
  /* Descriptions of temporary tables used to weed-out semi-join duplicates */
515
515
 
516
516
  table_map cur_emb_sj_nests;
517
517
 
518
 
  /* 
519
 
    storage for caching buffers allocated during query execution. 
 
518
  /*
 
519
    storage for caching buffers allocated during query execution.
520
520
    These buffers allocations need to be cached as the thread memory pool is
521
521
    cleared only at the end of the execution of the whole query and not caching
522
 
    allocations that occur in repetition at execution time will result in 
 
522
    allocations that occur in repetition at execution time will result in
523
523
    excessive memory usage.
524
 
  */  
 
524
  */
525
525
  SORT_FIELD *sortorder;                        // make_unireg_sortorder()
526
526
  Table **table_reexec;                         // make_simple_join()
527
527
  JOIN_TAB *join_tab_reexec;                    // make_simple_join()
664
664
                        uint64_t select_options, ha_rows rows_limit,
665
665
                        char* alias);
666
666
void free_tmp_table(Session *session, Table *entry);
667
 
void count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param, 
 
667
void count_field_types(SELECT_LEX *select_lex, TMP_TABLE_PARAM *param,
668
668
                       List<Item> &fields, bool reset_with_sum_func);
669
669
bool setup_copy_fields(Session *session, TMP_TABLE_PARAM *param,
670
670
                       Item **ref_pointer_array,
675
675
Field* create_tmp_field_from_field(Session *session, Field* org_field,
676
676
                                   const char *name, Table *table,
677
677
                                   Item_field *item, uint32_t convert_blob_length);
678
 
                                                                      
 
678
 
679
679
/* functions from opt_sum.cc */
680
680
bool simple_pred(Item_func *func_item, Item **args, bool *inv_order);
681
681
int opt_sum_query(TableList *tables, List<Item> &all_fields,COND *conds);
695
695
  {
696
696
    if (field_arg->type() == DRIZZLE_TYPE_BLOB)
697
697
    {
698
 
      /* 
 
698
      /*
699
699
        Key segments are always packed with a 2 byte length prefix.
700
700
        See mi_rkey for details.
701
701
      */
702
 
      to_field= new Field_varstring(ptr, length, 2, null, 1, 
 
702
      to_field= new Field_varstring(ptr, length, 2, null, 1,
703
703
                                    Field::NONE, field_arg->field_name,
704
704
                                    field_arg->table->s, field_arg->charset());
705
705
      to_field->init(field_arg->table);
760
760
  }
761
761
  const char *name() const { return field_name; }
762
762
 
763
 
 protected: 
 
763
 protected:
764
764
  enum store_key_result copy_inner()
765
765
  {
766
766
    copy_field.do_copy(&copy_field);
783
783
  {}
784
784
  const char *name() const { return "func"; }
785
785
 
786
 
 protected:  
 
786
 protected:
787
787
  enum store_key_result copy_inner()
788
788
  {
789
789
    int res= item->save_in_field(to_field, 1);
790
790
    null_key= to_field->is_null() || item->null_value;
791
 
    return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res); 
 
791
    return (err != 0 || res > 2 ? STORE_KEY_FATAL : (store_key_result) res);
792
792
  }
793
793
};
794
794
 
807
807
  }
808
808
  const char *name() const { return "const"; }
809
809
 
810
 
protected:  
 
810
protected:
811
811
  enum store_key_result copy_inner()
812
812
  {
813
813
    int res;
815
815
    {
816
816
      inited=1;
817
817
      if ((res= item->save_in_field(to_field, 1)))
818
 
      {       
 
818
      {
819
819
        if (!err)
820
820
          err= res;
821
821
      }