~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/item/sum.cc

  • Committer: Monty Taylor
  • Date: 2010-10-12 20:20:44 UTC
  • mto: (1842.1.3 build) (1843.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1843.
  • Revision ID: mordred@inaugust.com-20101012202044-yfrmnmkznvkqfxe4
Added support for valgrind suppressions.
Run strip-valgrind as part of make valgrind.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include <drizzled/item/sum.h>
34
34
#include <drizzled/field/decimal.h>
35
35
#include <drizzled/field/double.h>
36
 
#include <drizzled/field/int64.h>
 
36
#include <drizzled/field/int64_t.h>
37
37
#include <drizzled/field/date.h>
38
38
#include <drizzled/field/datetime.h>
39
39
 
508
508
                                  Table *table,
509
509
                                  uint32_t convert_blob_length)
510
510
{
511
 
  Field *field= NULL;
512
 
 
 
511
  Field *field;
513
512
  switch (result_type()) {
514
513
  case REAL_RESULT:
515
514
    field= new Field_double(max_length, maybe_null, name, decimals, true);
516
515
    break;
517
 
 
518
516
  case INT_RESULT:
519
 
    field= new field::Int64(max_length, maybe_null, name, unsigned_flag);
 
517
    field= new Field_int64_t(max_length, maybe_null, name, unsigned_flag);
520
518
    break;
521
 
 
522
519
  case STRING_RESULT:
523
520
    if (max_length/collation.collation->mbmaxlen <= 255 ||
524
521
        convert_blob_length > Field_varstring::MAX_SIZE ||
525
522
        !convert_blob_length)
526
 
    {
527
523
      return make_string_field(table);
528
 
    }
529
524
 
530
525
    table->setVariableWidth();
531
526
    field= new Field_varstring(convert_blob_length, maybe_null,
532
527
                               name, collation.collation);
533
528
    break;
534
 
 
535
529
  case DECIMAL_RESULT:
536
530
    field= new Field_decimal(max_length, maybe_null, name,
537
 
                             decimals, unsigned_flag);
 
531
                                 decimals, unsigned_flag);
538
532
    break;
539
 
 
540
533
  case ROW_RESULT:
 
534
  default:
541
535
    // This case should never be choosen
542
536
    assert(0);
543
537
    return 0;
544
538
  }
545
 
 
546
539
  if (field)
547
540
    field->init(table);
548
 
 
549
541
  return field;
550
542
}
551
543
 
655
647
    */
656
648
    break;
657
649
  case ROW_RESULT:
 
650
  default:
658
651
    assert(0);
659
652
  }
660
653
  collation.set(item->collation);
693
686
    max_length= item->max_length;
694
687
    break;
695
688
  case ROW_RESULT:
 
689
  default:
696
690
    assert(0);
697
691
  };
698
692
  /* MIN/MAX can return NULL for empty set indepedent of the used column */
804
798
    break;
805
799
  case INT_RESULT:
806
800
  case DECIMAL_RESULT:
807
 
    {
808
 
      /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */
809
 
      int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS;
810
 
      max_length= my_decimal_precision_to_length(precision, decimals,
811
 
                                                 unsigned_flag);
812
 
      curr_dec_buff= 0;
813
 
      hybrid_type= DECIMAL_RESULT;
814
 
      my_decimal_set_zero(dec_buffs);
815
 
      break;
816
 
    }
 
801
  {
 
802
    /* SUM result can't be longer than length(arg) + length(MAX_ROWS) */
 
803
    int precision= args[0]->decimal_precision() + DECIMAL_LONGLONG_DIGITS;
 
804
    max_length= my_decimal_precision_to_length(precision, decimals,
 
805
                                               unsigned_flag);
 
806
    curr_dec_buff= 0;
 
807
    hybrid_type= DECIMAL_RESULT;
 
808
    my_decimal_set_zero(dec_buffs);
 
809
    break;
 
810
  }
817
811
  case ROW_RESULT:
 
812
  default:
818
813
    assert(0);
819
814
  }
 
815
  return;
820
816
}
821
817
 
822
818
 
970
966
    table_field_type= DRIZZLE_TYPE_DOUBLE;
971
967
    break;
972
968
  case INT_RESULT:
973
 
    /*
974
 
      Preserving int8, int16, int32 field types gives ~10% performance boost
975
 
      as the size of result tree becomes significantly smaller.
976
 
      Another speed up we gain by using int64_t for intermediate
977
 
      calculations. The range of int64 is enough to hold sum 2^32 distinct
978
 
      integers each <= 2^32.
979
 
    */
980
 
    if (table_field_type == DRIZZLE_TYPE_LONG)
981
 
    {
982
 
      val.traits= Hybrid_type_traits_fast_decimal::instance();
983
 
      break;
984
 
    }
985
 
    table_field_type= DRIZZLE_TYPE_LONGLONG;
986
 
    /* fallthrough */
 
969
  /*
 
970
    Preserving int8, int16, int32 field types gives ~10% performance boost
 
971
    as the size of result tree becomes significantly smaller.
 
972
    Another speed up we gain by using int64_t for intermediate
 
973
    calculations. The range of int64 is enough to hold sum 2^32 distinct
 
974
    integers each <= 2^32.
 
975
  */
 
976
  if (table_field_type == DRIZZLE_TYPE_LONG)
 
977
  {
 
978
    val.traits= Hybrid_type_traits_fast_decimal::instance();
 
979
    break;
 
980
  }
 
981
  table_field_type= DRIZZLE_TYPE_LONGLONG;
 
982
  /* fallthrough */
987
983
  case DECIMAL_RESULT:
988
984
    val.traits= Hybrid_type_traits_decimal::instance();
989
985
    if (table_field_type != DRIZZLE_TYPE_LONGLONG)
990
986
      table_field_type= DRIZZLE_TYPE_DECIMAL;
991
987
    break;
992
988
  case ROW_RESULT:
 
989
  default:
993
990
    assert(0);
994
991
  }
995
 
 
996
992
  val.traits->fix_length_and_dec(this, args[0]);
997
993
}
998
994
 
1031
1027
  field_def.init_for_tmp_table(table_field_type, args[0]->max_length,
1032
1028
                               args[0]->decimals, args[0]->maybe_null);
1033
1029
 
1034
 
  if (! (table= session->getInstanceTable(field_list)))
 
1030
  if (! (table= session->create_virtual_tmp_table(field_list)))
1035
1031
    return(true);
1036
1032
 
1037
1033
  /* XXX: check that the case of CHAR(0) works OK */
1440
1436
    break;
1441
1437
  case INT_RESULT:
1442
1438
  case DECIMAL_RESULT:
1443
 
    {
1444
 
      int precision= args[0]->decimal_precision()*2 + prec_increment;
1445
 
      decimals= min(args[0]->decimals + prec_increment, (unsigned int) DECIMAL_MAX_SCALE);
1446
 
      max_length= my_decimal_precision_to_length(precision, decimals,
1447
 
                                                 unsigned_flag);
 
1439
  {
 
1440
    int precision= args[0]->decimal_precision()*2 + prec_increment;
 
1441
    decimals= min(args[0]->decimals + prec_increment, (unsigned int) DECIMAL_MAX_SCALE);
 
1442
    max_length= my_decimal_precision_to_length(precision, decimals,
 
1443
                                               unsigned_flag);
1448
1444
 
1449
 
      break;
1450
 
    }
 
1445
    break;
 
1446
  }
1451
1447
  case ROW_RESULT:
 
1448
  default:
1452
1449
    assert(0);
1453
1450
  }
 
1451
  return;
1454
1452
}
1455
1453
 
1456
1454
 
1619
1617
  assert(fixed == 1);
1620
1618
  if (null_value)
1621
1619
    return 0.0;
1622
 
 
1623
1620
  switch (hybrid_type) {
1624
1621
  case STRING_RESULT:
1625
 
    {
1626
 
      char *end_not_used;
1627
 
      int err_not_used;
1628
 
      String *res;  res=val_str(&str_value);
1629
 
      return (res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
1630
 
                               &end_not_used, &err_not_used) : 0.0);
1631
 
    }
 
1622
  {
 
1623
    char *end_not_used;
 
1624
    int err_not_used;
 
1625
    String *res;  res=val_str(&str_value);
 
1626
    return (res ? my_strntod(res->charset(), (char*) res->ptr(), res->length(),
 
1627
                             &end_not_used, &err_not_used) : 0.0);
 
1628
  }
1632
1629
  case INT_RESULT:
1633
1630
    return (double) sum_int;
1634
1631
  case DECIMAL_RESULT:
1637
1634
  case REAL_RESULT:
1638
1635
    return sum;
1639
1636
  case ROW_RESULT:
 
1637
  default:
1640
1638
    // This case should never be choosen
1641
 
    break;
 
1639
    assert(0);
 
1640
    return 0;
1642
1641
  }
1643
 
 
1644
 
  assert(0);
1645
 
  return 0;
1646
1642
}
1647
1643
 
1648
1644
int64_t Item_sum_hybrid::val_int()
1670
1666
  assert(fixed == 1);
1671
1667
  if (null_value)
1672
1668
    return 0;
1673
 
 
1674
1669
  switch (hybrid_type) {
1675
1670
  case STRING_RESULT:
1676
1671
    string2my_decimal(E_DEC_FATAL_ERROR, &value, val);
1685
1680
    int2my_decimal(E_DEC_FATAL_ERROR, sum_int, unsigned_flag, val);
1686
1681
    break;
1687
1682
  case ROW_RESULT:
 
1683
  default:
1688
1684
    // This case should never be choosen
1689
1685
    assert(0);
1690
1686
    break;
1691
1687
  }
1692
 
 
1693
1688
  return val;                                   // Keep compiler happy
1694
1689
}
1695
1690
 
1700
1695
  assert(fixed == 1);
1701
1696
  if (null_value)
1702
1697
    return 0;
1703
 
 
1704
1698
  switch (hybrid_type) {
1705
1699
  case STRING_RESULT:
1706
1700
    return &value;
1716
1710
  case ROW_RESULT:
1717
1711
  default:
1718
1712
    // This case should never be choosen
 
1713
    assert(0);
1719
1714
    break;
1720
1715
  }
1721
 
 
1722
1716
  return str;                                   // Keep compiler happy
1723
1717
}
1724
1718
 
1756
1750
{
1757
1751
  switch (hybrid_type) {
1758
1752
  case STRING_RESULT:
 
1753
  {
 
1754
    String *result=args[0]->val_str(&tmp_value);
 
1755
    if (!args[0]->null_value &&
 
1756
        (null_value || sortcmp(&value,result,collation.collation) > 0))
1759
1757
    {
1760
 
      String *result=args[0]->val_str(&tmp_value);
1761
 
      if (!args[0]->null_value &&
1762
 
          (null_value || sortcmp(&value,result,collation.collation) > 0))
1763
 
      {
1764
 
        value.copy(*result);
1765
 
        null_value=0;
1766
 
      }
 
1758
      value.copy(*result);
 
1759
      null_value=0;
1767
1760
    }
1768
 
    break;
 
1761
  }
 
1762
  break;
1769
1763
  case INT_RESULT:
 
1764
  {
 
1765
    int64_t nr=args[0]->val_int();
 
1766
    if (!args[0]->null_value && (null_value ||
 
1767
                                 (unsigned_flag &&
 
1768
                                  (uint64_t) nr < (uint64_t) sum_int) ||
 
1769
                                 (!unsigned_flag && nr < sum_int)))
1770
1770
    {
1771
 
      int64_t nr=args[0]->val_int();
1772
 
      if (!args[0]->null_value && (null_value ||
1773
 
                                   (unsigned_flag &&
1774
 
                                    (uint64_t) nr < (uint64_t) sum_int) ||
1775
 
                                   (!unsigned_flag && nr < sum_int)))
1776
 
      {
1777
 
        sum_int=nr;
1778
 
        null_value=0;
1779
 
      }
 
1771
      sum_int=nr;
 
1772
      null_value=0;
1780
1773
    }
1781
 
    break;
 
1774
  }
 
1775
  break;
1782
1776
  case DECIMAL_RESULT:
 
1777
  {
 
1778
    my_decimal value_buff, *val= args[0]->val_decimal(&value_buff);
 
1779
    if (!args[0]->null_value &&
 
1780
        (null_value || (my_decimal_cmp(&sum_dec, val) > 0)))
1783
1781
    {
1784
 
      my_decimal value_buff, *val= args[0]->val_decimal(&value_buff);
1785
 
      if (!args[0]->null_value &&
1786
 
          (null_value || (my_decimal_cmp(&sum_dec, val) > 0)))
1787
 
      {
1788
 
        my_decimal2decimal(val, &sum_dec);
1789
 
        null_value= 0;
1790
 
      }
 
1782
      my_decimal2decimal(val, &sum_dec);
 
1783
      null_value= 0;
1791
1784
    }
1792
 
    break;
 
1785
  }
 
1786
  break;
1793
1787
  case REAL_RESULT:
 
1788
  {
 
1789
    double nr= args[0]->val_real();
 
1790
    if (!args[0]->null_value && (null_value || nr < sum))
1794
1791
    {
1795
 
      double nr= args[0]->val_real();
1796
 
      if (!args[0]->null_value && (null_value || nr < sum))
1797
 
      {
1798
 
        sum=nr;
1799
 
        null_value=0;
1800
 
      }
 
1792
      sum=nr;
 
1793
      null_value=0;
1801
1794
    }
1802
 
    break;
 
1795
  }
 
1796
  break;
1803
1797
  case ROW_RESULT:
 
1798
  default:
1804
1799
    // This case should never be choosen
1805
1800
    assert(0);
1806
1801
    break;
1819
1814
{
1820
1815
  switch (hybrid_type) {
1821
1816
  case STRING_RESULT:
 
1817
  {
 
1818
    String *result=args[0]->val_str(&tmp_value);
 
1819
    if (!args[0]->null_value &&
 
1820
        (null_value || sortcmp(&value,result,collation.collation) < 0))
1822
1821
    {
1823
 
      String *result=args[0]->val_str(&tmp_value);
1824
 
      if (!args[0]->null_value &&
1825
 
          (null_value || sortcmp(&value,result,collation.collation) < 0))
1826
 
      {
1827
 
        value.copy(*result);
1828
 
        null_value=0;
1829
 
      }
 
1822
      value.copy(*result);
 
1823
      null_value=0;
1830
1824
    }
1831
 
    break;
 
1825
  }
 
1826
  break;
1832
1827
  case INT_RESULT:
 
1828
  {
 
1829
    int64_t nr=args[0]->val_int();
 
1830
    if (!args[0]->null_value && (null_value ||
 
1831
                                 (unsigned_flag &&
 
1832
                                  (uint64_t) nr > (uint64_t) sum_int) ||
 
1833
                                 (!unsigned_flag && nr > sum_int)))
1833
1834
    {
1834
 
      int64_t nr=args[0]->val_int();
1835
 
      if (!args[0]->null_value && (null_value ||
1836
 
                                   (unsigned_flag &&
1837
 
                                    (uint64_t) nr > (uint64_t) sum_int) ||
1838
 
                                   (!unsigned_flag && nr > sum_int)))
1839
 
      {
1840
 
        sum_int=nr;
1841
 
        null_value=0;
1842
 
      }
 
1835
      sum_int=nr;
 
1836
      null_value=0;
1843
1837
    }
1844
 
    break;
 
1838
  }
 
1839
  break;
1845
1840
  case DECIMAL_RESULT:
 
1841
  {
 
1842
    my_decimal value_buff, *val= args[0]->val_decimal(&value_buff);
 
1843
    if (!args[0]->null_value &&
 
1844
        (null_value || (my_decimal_cmp(val, &sum_dec) > 0)))
1846
1845
    {
1847
 
      my_decimal value_buff, *val= args[0]->val_decimal(&value_buff);
1848
 
      if (!args[0]->null_value &&
1849
 
          (null_value || (my_decimal_cmp(val, &sum_dec) > 0)))
1850
 
      {
1851
 
        my_decimal2decimal(val, &sum_dec);
1852
 
        null_value= 0;
1853
 
      }
 
1846
      my_decimal2decimal(val, &sum_dec);
 
1847
      null_value= 0;
1854
1848
    }
1855
 
    break;
 
1849
  }
 
1850
  break;
1856
1851
  case REAL_RESULT:
 
1852
  {
 
1853
    double nr= args[0]->val_real();
 
1854
    if (!args[0]->null_value && (null_value || nr > sum))
1857
1855
    {
1858
 
      double nr= args[0]->val_real();
1859
 
      if (!args[0]->null_value && (null_value || nr > sum))
1860
 
      {
1861
 
        sum=nr;
1862
 
        null_value=0;
1863
 
      }
 
1856
      sum=nr;
 
1857
      null_value=0;
1864
1858
    }
1865
 
    break;
 
1859
  }
 
1860
  break;
1866
1861
  case ROW_RESULT:
 
1862
  default:
1867
1863
    // This case should never be choosen
1868
1864
    assert(0);
1869
1865
    break;
1870
1866
  }
1871
 
 
1872
1867
  return 0;
1873
1868
}
1874
1869
 
1956
1951
{
1957
1952
  switch(hybrid_type) {
1958
1953
  case STRING_RESULT:
1959
 
    {
1960
 
      char buff[MAX_FIELD_WIDTH];
1961
 
      String tmp(buff,sizeof(buff),result_field->charset()),*res;
1962
 
 
1963
 
      res=args[0]->val_str(&tmp);
1964
 
      if (args[0]->null_value)
1965
 
      {
 
1954
  {
 
1955
    char buff[MAX_FIELD_WIDTH];
 
1956
    String tmp(buff,sizeof(buff),result_field->charset()),*res;
 
1957
 
 
1958
    res=args[0]->val_str(&tmp);
 
1959
    if (args[0]->null_value)
 
1960
    {
 
1961
      result_field->set_null();
 
1962
      result_field->reset();
 
1963
    }
 
1964
    else
 
1965
    {
 
1966
      result_field->set_notnull();
 
1967
      result_field->store(res->ptr(),res->length(),tmp.charset());
 
1968
    }
 
1969
    break;
 
1970
  }
 
1971
  case INT_RESULT:
 
1972
  {
 
1973
    int64_t nr=args[0]->val_int();
 
1974
 
 
1975
    if (maybe_null)
 
1976
    {
 
1977
      if (args[0]->null_value)
 
1978
      {
 
1979
        nr=0;
 
1980
        result_field->set_null();
 
1981
      }
 
1982
      else
 
1983
        result_field->set_notnull();
 
1984
    }
 
1985
    result_field->store(nr, unsigned_flag);
 
1986
    break;
 
1987
  }
 
1988
  case REAL_RESULT:
 
1989
  {
 
1990
    double nr= args[0]->val_real();
 
1991
 
 
1992
    if (maybe_null)
 
1993
    {
 
1994
      if (args[0]->null_value)
 
1995
      {
 
1996
        nr=0.0;
 
1997
        result_field->set_null();
 
1998
      }
 
1999
      else
 
2000
        result_field->set_notnull();
 
2001
    }
 
2002
    result_field->store(nr);
 
2003
    break;
 
2004
  }
 
2005
  case DECIMAL_RESULT:
 
2006
  {
 
2007
    my_decimal value_buff, *arg_dec= args[0]->val_decimal(&value_buff);
 
2008
 
 
2009
    if (maybe_null)
 
2010
    {
 
2011
      if (args[0]->null_value)
1966
2012
        result_field->set_null();
1967
 
        result_field->reset();
1968
 
      }
1969
2013
      else
1970
 
      {
1971
2014
        result_field->set_notnull();
1972
 
        result_field->store(res->ptr(),res->length(),tmp.charset());
1973
 
      }
1974
 
      break;
1975
 
    }
1976
 
  case INT_RESULT:
1977
 
    {
1978
 
      int64_t nr=args[0]->val_int();
1979
 
 
1980
 
      if (maybe_null)
1981
 
      {
1982
 
        if (args[0]->null_value)
1983
 
        {
1984
 
          nr=0;
1985
 
          result_field->set_null();
1986
 
        }
1987
 
        else
1988
 
          result_field->set_notnull();
1989
 
      }
1990
 
      result_field->store(nr, unsigned_flag);
1991
 
      break;
1992
 
    }
1993
 
  case REAL_RESULT:
1994
 
    {
1995
 
      double nr= args[0]->val_real();
1996
 
 
1997
 
      if (maybe_null)
1998
 
      {
1999
 
        if (args[0]->null_value)
2000
 
        {
2001
 
          nr=0.0;
2002
 
          result_field->set_null();
2003
 
        }
2004
 
        else
2005
 
          result_field->set_notnull();
2006
 
      }
2007
 
      result_field->store(nr);
2008
 
      break;
2009
 
    }
2010
 
  case DECIMAL_RESULT:
2011
 
    {
2012
 
      my_decimal value_buff, *arg_dec= args[0]->val_decimal(&value_buff);
2013
 
 
2014
 
      if (maybe_null)
2015
 
      {
2016
 
        if (args[0]->null_value)
2017
 
          result_field->set_null();
2018
 
        else
2019
 
          result_field->set_notnull();
2020
 
      }
2021
 
      /*
2022
 
        We must store zero in the field as we will use the field value in
2023
 
        add()
2024
 
      */
2025
 
      if (!arg_dec)                               // Null
2026
 
        arg_dec= &decimal_zero;
2027
 
      result_field->store_decimal(arg_dec);
2028
 
      break;
2029
 
    }
 
2015
    }
 
2016
    /*
 
2017
      We must store zero in the field as we will use the field value in
 
2018
      add()
 
2019
    */
 
2020
    if (!arg_dec)                               // Null
 
2021
      arg_dec= &decimal_zero;
 
2022
    result_field->store_decimal(arg_dec);
 
2023
    break;
 
2024
  }
2030
2025
  case ROW_RESULT:
 
2026
  default:
2031
2027
    assert(0);
2032
2028
  }
2033
2029
}
2222
2218
  case DECIMAL_RESULT:
2223
2219
    min_max_update_decimal_field();
2224
2220
    break;
2225
 
  case REAL_RESULT:
2226
 
  case ROW_RESULT:
 
2221
  default:
2227
2222
    min_max_update_real_field();
2228
2223
  }
2229
2224
}
2236
2231
 
2237
2232
  if (!args[0]->null_value)
2238
2233
  {
2239
 
    result_field->val_str_internal(&tmp_value);
 
2234
    result_field->val_str(&tmp_value);
2240
2235
 
2241
2236
    if (result_field->is_null() ||
2242
2237
        (cmp_sign * sortcmp(res_str,&tmp_value,collation.collation)) < 0)
2608
2603
  tmp_table_param->force_copy_fields= force_copy_fields;
2609
2604
  assert(table == 0);
2610
2605
 
2611
 
  if (!(table= create_tmp_table(session, tmp_table_param, list, (Order*) 0, 1,
 
2606
  if (!(table= create_tmp_table(session, tmp_table_param, list, (order_st*) 0, 1,
2612
2607
                                0,
2613
2608
                                (select_lex->options | session->options),
2614
2609
                                HA_POS_ERROR, (char*)"")))
2719
2714
  if (always_null)
2720
2715
    return 0;
2721
2716
  copy_fields(tmp_table_param);
2722
 
  if (copy_funcs(tmp_table_param->items_to_copy, table->in_use))
2723
 
    return true;
 
2717
  copy_funcs(tmp_table_param->items_to_copy);
2724
2718
 
2725
2719
  for (Field **field= table->getFields() ; *field ; field++)
2726
2720
  {
2844
2838
                                    const void* key2)
2845
2839
{
2846
2840
  Item_func_group_concat* grp_item= (Item_func_group_concat*) arg;
2847
 
  Order **order_item, **end;
 
2841
  order_st **order_item, **end;
2848
2842
  Table *table= grp_item->table;
2849
2843
 
2850
2844
  for (order_item= grp_item->order, end=order_item+ grp_item->arg_count_order;
2918
2912
      uint32_t offset= (field->offset(field->getTable()->record[0]) -
2919
2913
                    table->getShare()->null_bytes);
2920
2914
      assert(offset < table->getShare()->getRecordLength());
2921
 
      res= field->val_str_internal(&tmp, key + offset);
 
2915
      res= field->val_str(&tmp, key + offset);
2922
2916
    }
2923
2917
    else
2924
2918
      res= (*arg)->val_str(&tmp);
2988
2982
    order - arg_count_order
2989
2983
  */
2990
2984
  if (!(args= (Item**) memory::sql_alloc(sizeof(Item*) * arg_count +
2991
 
                                 sizeof(Order*)*arg_count_order)))
 
2985
                                 sizeof(order_st*)*arg_count_order)))
2992
2986
    return;
2993
2987
 
2994
 
  order= (Order**)(args + arg_count);
 
2988
  order= (order_st**)(args + arg_count);
2995
2989
 
2996
2990
  /* fill args items of show and sort */
2997
2991
  List_iterator_fast<Item> li(*select_list);
3001
2995
 
3002
2996
  if (arg_count_order)
3003
2997
  {
3004
 
    Order **order_ptr= order;
3005
 
    for (Order *order_item= (Order*) order_list->first;
 
2998
    order_st **order_ptr= order;
 
2999
    for (order_st *order_item= (order_st*) order_list->first;
3006
3000
         order_item != NULL;
3007
3001
         order_item= order_item->next)
3008
3002
    {
3115
3109
  if (always_null)
3116
3110
    return 0;
3117
3111
  copy_fields(tmp_table_param);
3118
 
  if (copy_funcs(tmp_table_param->items_to_copy, table->in_use))
3119
 
    return true;
 
3112
  copy_funcs(tmp_table_param->items_to_copy);
3120
3113
 
3121
3114
  for (uint32_t i= 0; i < arg_count_field; i++)
3122
3115
  {
3270
3263
    field list.
3271
3264
  */
3272
3265
  if (!(table= create_tmp_table(session, tmp_table_param, all_fields,
3273
 
                                (Order*) 0, 0, true,
 
3266
                                (order_st*) 0, 0, true,
3274
3267
                                (select_lex->options | session->options),
3275
3268
                                HA_POS_ERROR, (char*) "")))
3276
3269
  {