~ubuntu-branches/ubuntu/karmic/mysql-dfsg-5.1/karmic

« back to all changes in this revision

Viewing changes to sql/sql_select.cc

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-02-10 16:42:05 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090210164205-ej41ocvm4z1s14nq
Tags: 5.1.31-1ubuntu1
* Merge from debian experimental, remaining changes: 
  - debian/mysql-server-5.1.config: ask for MySQL root password at priority
    high instead of medium so that the password prompt is seen on a default
    install. (LP: #319843)
  - debian/control: 
    + Don't build mysql-server, mysql-client, mysql-common and 
      libmysqlclient15-dev binary packages since they're still provided 
      by mysql-dfsg-5.0.
    + Rename libmysqlclient-dev package to libmysqlclient16-dev (LP: #316280).
      Make it conflict with libmysqlclient15-dev.
    + Make mysql-{client,server}-5.1 packages conflict and
      replace mysql-{client,server}-5.0, but not provide 
      mysql-{client,server}.
    + Depend on a specific version of mysql-common rather than the src 
      version of mysql-dfsg-5.1 since mysql-common is currently part of
      mysql-dfsg-5.0.
  - debian/rules: added -fno-strict-aliasing to CFLAGS to get
    around mysql testsuite build failures.
* debian/patches/92_ssl_test_cert.dpatch: certificate expiration in 
  test suite (LP: #323755).
* Dropped changes:
  - all of the changes made to support both 5.0 and 5.1 installed at the
    same time have been dropped now that amarok doesn't depend on
    mysql-server-5.1 anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
402
402
{
403
403
  int res;
404
404
  nesting_map save_allow_sum_func=thd->lex->allow_sum_func ;
 
405
  /* 
 
406
    Need to save the value, so we can turn off only the new NON_AGG_FIELD
 
407
    additions coming from the WHERE
 
408
  */
 
409
  uint8 saved_flag= thd->lex->current_select->full_group_by_flag;
405
410
  DBUG_ENTER("setup_without_group");
406
411
 
407
412
  thd->lex->allow_sum_func&= ~(1 << thd->lex->current_select->nest_level);
408
413
  res= setup_conds(thd, tables, leaves, conds);
409
414
 
 
415
  /* it's not wrong to have non-aggregated columns in a WHERE */
 
416
  if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY)
 
417
    thd->lex->current_select->full_group_by_flag= saved_flag |
 
418
      (thd->lex->current_select->full_group_by_flag & ~NON_AGG_FIELD_USED);
 
419
 
410
420
  thd->lex->allow_sum_func|= 1 << thd->lex->current_select->nest_level;
411
421
  res= res || setup_order(thd, ref_pointer_array, tables, fields, all_fields,
412
422
                          order);
1657
1667
                      (zero_result_cause?zero_result_cause:"No tables used"));
1658
1668
    else
1659
1669
    {
1660
 
      result->send_fields(*columns_list,
1661
 
                          Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF);
 
1670
      if (result->send_fields(*columns_list,
 
1671
                              Protocol::SEND_NUM_ROWS | Protocol::SEND_EOF))
 
1672
      {
 
1673
        DBUG_VOID_RETURN;
 
1674
      }
1662
1675
      /*
1663
1676
        We have to test for 'conds' here as the WHERE may not be constant
1664
1677
        even if we don't have any tables for prepared statements or if
2574
2587
        if (s->dependent & table->map)
2575
2588
          s->dependent |= table->reginfo.join_tab->dependent;
2576
2589
      }
2577
 
      if (s->dependent)
 
2590
      if (outer_join & s->table->map)
2578
2591
        s->table->maybe_null= 1;
2579
2592
    }
2580
2593
    /* Catch illegal cross references for outer joins */
6863
6876
{
6864
6877
  if (specialflag &  SPECIAL_SAFE_MODE)
6865
6878
    return 0;                   // skip this optimize /* purecov: inspected */
 
6879
  tables&= ~PSEUDO_TABLE_BITS;
6866
6880
  for (JOIN_TAB **tab=join->map2table ; tables ; tab++, tables>>=1)
6867
6881
  {
6868
6882
    if (tables & 1 && !eq_ref_table(join, order, *tab))
8585
8599
  }
8586
8600
    
8587
8601
  /* Flatten nested joins that can be flattened. */
 
8602
  TABLE_LIST *right_neighbor= NULL;
 
8603
  bool fix_name_res= FALSE;
8588
8604
  li.rewind();
8589
8605
  while ((table= li++))
8590
8606
  {
8597
8613
      {
8598
8614
        tbl->embedding= table->embedding;
8599
8615
        tbl->join_list= table->join_list;
8600
 
      }      
 
8616
      }
8601
8617
      li.replace(nested_join->join_list);
 
8618
      /* Need to update the name resolution table chain when flattening joins */
 
8619
      fix_name_res= TRUE;
 
8620
      table= *li.ref();
8602
8621
    }
 
8622
    if (fix_name_res)
 
8623
      table->next_name_resolution_table= right_neighbor ?
 
8624
        right_neighbor->first_leaf_for_name_resolution() :
 
8625
        NULL;
 
8626
    right_neighbor= table;
8603
8627
  }
8604
8628
  DBUG_RETURN(conds); 
8605
8629
}
9274
9298
    */
9275
9299
    if ((type= item->field_type()) == MYSQL_TYPE_DATETIME ||
9276
9300
        type == MYSQL_TYPE_TIME || type == MYSQL_TYPE_DATE ||
 
9301
        type == MYSQL_TYPE_NEWDATE ||
9277
9302
        type == MYSQL_TYPE_TIMESTAMP || type == MYSQL_TYPE_GEOMETRY)
9278
9303
      new_field= item->tmp_table_field_from_field_type(table, 1);
9279
9304
    /* 
9791
9816
    }
9792
9817
    if (type == Item::SUM_FUNC_ITEM && !group && !save_sum_fields)
9793
9818
    {                                           /* Can't calc group yet */
9794
 
      ((Item_sum*) item)->result_field=0;
9795
 
      for (i=0 ; i < ((Item_sum*) item)->arg_count ; i++)
 
9819
      Item_sum *sum_item= (Item_sum *) item;
 
9820
      sum_item->result_field=0;
 
9821
      for (i=0 ; i < sum_item->get_arg_count() ; i++)
9796
9822
      {
9797
 
        Item **argp= ((Item_sum*) item)->args + i;
9798
 
        Item *arg= *argp;
 
9823
        Item *arg= sum_item->get_arg(i);
9799
9824
        if (!arg->const_item())
9800
9825
        {
9801
9826
          Field *new_field=
9823
9848
            string_total_length+= new_field->pack_length();
9824
9849
          }
9825
9850
          thd->mem_root= mem_root_save;
9826
 
          thd->change_item_tree(argp, new Item_field(new_field));
 
9851
          arg= sum_item->set_arg(i, thd, new Item_field(new_field));
9827
9852
          thd->mem_root= &table->mem_root;
9828
9853
          if (!(new_field->flags & NOT_NULL_FLAG))
9829
9854
          {
9832
9857
              new_field->maybe_null() is still false, it will be
9833
9858
              changed below. But we have to setup Item_field correctly
9834
9859
            */
9835
 
            (*argp)->maybe_null=1;
 
9860
            arg->maybe_null=1;
9836
9861
          }
9837
9862
          new_field->field_index= fieldnr++;
9838
9863
        }
13834
13859
  length=0;
13835
13860
  for (i=0 ; i < table_count ; i++)
13836
13861
  {
 
13862
    bool have_bit_fields= FALSE;
13837
13863
    uint null_fields=0,used_fields;
13838
13864
    Field **f_ptr,*field;
13839
13865
    MY_BITMAP *read_set= tables[i].table->read_set;
13848
13874
        length+=field->fill_cache_field(copy);
13849
13875
        if (copy->blob_field)
13850
13876
          (*blob_ptr++)=copy;
13851
 
        if (field->maybe_null())
 
13877
        if (field->real_maybe_null())
13852
13878
          null_fields++;
 
13879
        if (field->type() == MYSQL_TYPE_BIT &&
 
13880
            ((Field_bit*)field)->bit_len)
 
13881
          have_bit_fields= TRUE;    
13853
13882
        copy++;
13854
13883
      }
13855
13884
    }
13856
13885
    /* Copy null bits from table */
13857
 
    if (null_fields && tables[i].table->s->null_fields)
 
13886
    if (null_fields || have_bit_fields)
13858
13887
    {                                           /* must copy null bits */
13859
13888
      copy->str= tables[i].table->null_flags;
13860
13889
      copy->length= tables[i].table->s->null_bytes;
14533
14562
            param->quick_group=0;                       // UDF SUM function
14534
14563
          param->sum_func_count++;
14535
14564
 
14536
 
          for (uint i=0 ; i < sum_item->arg_count ; i++)
 
14565
          for (uint i=0 ; i < sum_item->get_arg_count() ; i++)
14537
14566
          {
14538
 
            if (sum_item->args[0]->real_item()->type() == Item::FIELD_ITEM)
 
14567
            if (sum_item->get_arg(i)->real_item()->type() == Item::FIELD_ITEM)
14539
14568
              param->field_count++;
14540
14569
            else
14541
14570
              param->func_count++;