~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join.cc

  • Committer: Stewart Smith
  • Date: 2010-06-02 07:13:05 UTC
  • mto: This revision was merged to the branch mainline in revision 1587.
  • Revision ID: stewart@flamingspork.com-20100602071305-qz25a3vkq7fdgr0n
remove redundant part from innodb.test, it's now in auto_increment_update.test, along with behaviour change to match MyISAM.

Show diffs side-by-side

added added

removed removed

Lines of Context:
495
495
    {           /* Impossible cond */
496
496
      zero_result_cause=  having_value == Item::COND_FALSE ?
497
497
                           "Impossible HAVING" : "Impossible WHERE";
498
 
      goto setup_subq_exit;
 
498
      error= 0;
 
499
      return(0);
499
500
    }
500
501
  }
501
502
 
514
515
      if (res == HA_ERR_KEY_NOT_FOUND)
515
516
      {
516
517
        zero_result_cause= "No matching min/max row";
517
 
        goto setup_subq_exit;
 
518
        error=0;
 
519
        return(0);
518
520
      }
519
521
      if (res > 1)
520
522
      {
524
526
      if (res < 0)
525
527
      {
526
528
        zero_result_cause= "No matching min/max row";
527
 
        goto setup_subq_exit;
 
529
        error=0;
 
530
        return(0);
528
531
      }
529
532
      zero_result_cause= "Select tables optimized away";
530
533
      tables_list= 0;       // All tables resolved
543
546
        COND *table_independent_conds= make_cond_for_table(conds, PSEUDO_TABLE_BITS, 0, 0);
544
547
        conds= table_independent_conds;
545
548
      }
546
 
      goto setup_subq_exit;
547
549
    }
548
550
  }
549
551
  if (!tables_list)
576
578
       select_lex->master_unit() == &session->lex->unit)) // upper level SELECT
577
579
  {
578
580
    zero_result_cause= "no matching row in const table";
579
 
    goto setup_subq_exit;
 
581
    error= 0;
 
582
    return(0);
580
583
  }
581
584
  if (!(session->options & OPTION_BIG_SELECTS) &&
582
585
      best_read > (double) session->variables.max_join_size &&
642
645
  {
643
646
    zero_result_cause=
644
647
      "Impossible WHERE noticed after reading const tables";
645
 
    goto setup_subq_exit;
 
648
    return(0);        // error == 0
646
649
  }
647
650
 
648
651
  error= -1;          /* if goto err */
1107
1110
 
1108
1111
  error= 0;
1109
1112
  return(0);
1110
 
 
1111
 
setup_subq_exit:
1112
 
  /* Even with zero matching rows, subqueries in the HAVING clause
1113
 
     may need to be evaluated if there are aggregate functions in the query.
1114
 
  */
1115
 
  if (setup_subquery_materialization())
1116
 
    return 1;
1117
 
  error= 0;
1118
 
  return 0;
1119
1113
}
1120
1114
 
1121
1115
/**
5391
5385
    join->unit->select_limit_cnt= 1;            // Only send first row
5392
5386
    return(0);
5393
5387
  }
5394
 
  Field **first_field=entry->getFields() + entry->getShare()->sizeFields() - field_count;
 
5388
  Field **first_field=entry->field+entry->getShare()->fields - field_count;
5395
5389
  offset= (field_count ?
5396
 
           entry->getField(entry->getShare()->sizeFields() - field_count)->offset(entry->record[0]) : 0);
5397
 
  reclength= entry->getShare()->getRecordLength() - offset;
 
5390
           entry->field[entry->getShare()->fields - field_count]->
 
5391
           offset(entry->record[0]) : 0);
 
5392
  reclength= entry->getShare()->reclength-offset;
5398
5393
 
5399
5394
  entry->free_io_cache();                               // Safety
5400
5395
  entry->cursor->info(HA_STATUS_VARIABLE);
5401
5396
  if (entry->getShare()->db_type() == heap_engine ||
5402
5397
      (!entry->getShare()->blob_fields &&
5403
5398
       ((ALIGN_SIZE(reclength) + HASH_OVERHEAD) * entry->cursor->stats.records <
5404
 
        session->variables.sortbuff_size)))
5405
 
  {
 
5399
        session->variables.sortbuff_size)))
5406
5400
    error= remove_dup_with_hash_index(join->session, entry,
5407
 
                                      field_count, first_field,
5408
 
                                      reclength, having);
5409
 
  }
 
5401
                                     field_count, first_field,
 
5402
                                     reclength, having);
5410
5403
  else
5411
 
  {
5412
 
    error= remove_dup_with_compare(join->session, entry, first_field, offset, having);
5413
 
  }
 
5404
    error= remove_dup_with_compare(join->session, entry, first_field, offset,
 
5405
                                  having);
5414
5406
 
5415
5407
  free_blobs(first_field);
5416
 
 
5417
5408
  return(error);
5418
5409
}
5419
5410
 
5516
5507
    table->reginfo.join_tab=s;
5517
5508
    table->reginfo.not_exists_optimize=0;
5518
5509
    memset(table->const_key_parts, 0,
5519
 
           sizeof(key_part_map)*table->getShare()->sizeKeys());
 
5510
           sizeof(key_part_map)*table->getShare()->keys);
5520
5511
    all_table_map|= table->map;
5521
5512
    s->join=join;
5522
5513
    s->info=0;                                  // For describe
6054
6045
 
6055
6046
  for (uint32_t i=0 ; i < join_tab->ref.key_parts ; i++)
6056
6047
  {
6057
 
    Field *field=table->getField(table->key_info[join_tab->ref.key].key_part[i].fieldnr - 1);
 
6048
    Field *field=table->field[table->key_info[join_tab->ref.key].key_part[i].
 
6049
                              fieldnr-1];
6058
6050
    Item *value=join_tab->ref.items[i];
6059
6051
    cond->add(new Item_func_equal(new Item_field(field), value));
6060
6052
  }