~mathiaz/ubuntu/lucid/mysql-dfsg-5.1/zap-bug-552053

« back to all changes in this revision

Viewing changes to sql/item_timefunc.cc

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-06-25 12:55:45 UTC
  • mfrom: (1.1.2 upstream) (0.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090625125545-m8ogs96zzsri74xe
Tags: 5.1.34-1ubuntu1
* Merge from debian experimental (and 5.0 from main), 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)
    + don't ask for root password when upgrading from a 5.0 install.
  - debian/control:
    + Make libmysqlclient16-dev a transitional package depending on
      libmysqlclient-dev.
    + Make libmysqlclient-dev conflict with libmysqlclient15-dev.
    + Don't build mysql-server, mysql-client, mysql-common and
      libmysqlclient15-dev binary packages since they're still provided
      by mysql-dfsg-5.0.
    + 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.
    + Lower mailx from a Recommends to a Suggests to avoid pulling in
      a full MTA on all installs of mysql-server. (LP: #259477)
  - debian/rules:
    + added -fno-strict-aliasing to CFLAGS to get around mysql testsuite
      build failures.
    + install mysql-test and sql-bench to /usr/share/mysql/ rather than
      /usr/.
  - debian/additions/debian-start.inc.sh: support ANSI mode (LP: #310211)
  - Add AppArmor profile:
    - debian/apparmor-profile: apparmor profile.
    - debian/rules, debian/mysql-server-5.0.files: install apparmor profile.
    - debian/mysql-server-5.0.dirs: add etc/apparmor.d/force-complain
    - debian/mysql-server-5.0.postrm: remove symlink in force-complain/ on
      purge.
    - debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    - debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    - debian/mysql-server-5.1.postinst: reload apparmor profiles.
  - debian/additions/my.cnf: remove language option. Error message files are
    located in a different directory in MySQL 5.0. Setting the language
    option to use /usr/share/mysql/english breaks 5.0. Both 5.0 and 5.1
    use a default value that works. (LP: #316974)
  - debian/mysql-server-5.1.mysql.init:
    + Clearly indicate that we do not support running multiple instances
      of mysqld by duplicating the init script.
      (closes: #314785, #324834, #435165, #444216)
    + Properly parameterize all existing references to the mysql config
      file (/etc/mysql/my.cnf).
  - debian/mysql-server-5.0.postinst: Clear out the second password
    when setting up mysql. (LP: #344816)
  - mysql-server-core-5.1 package for files needed by Akonadi:
    + debian/control: create mysql-server-core-5.1 package.
    + debian/mysql-server-core-5.1.files, debian/mysql-server-5.1.files:
      move core mysqld files to mysql-server-core-5.1 package.
  - Don't package sql-bench and mysql-test file.
* Dropped changes:
  - debian/patches/92_ssl_test_cert.dpatch: certificate expiration in
    test suite (LP: #323755). Included upstream.
* Dropped from 5.0:
  - apparmor profile:
    - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6. All version
      of apparmor-profile (>hardy) are higher than this version.
    - debian/mysql-server-5.0.preinst: create symlink for force-complain/
      on pre-feisty upgrades, upgrades where apparmor-profiles profile is
      unchanged (ie non-enforcing) and upgrades where the profile
      doesn't exist. Support for pre-hardy upgrades is no longer needed.
* debian/mysql-server-5.1.postinst: fix debian-sys-maint user creation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
391
391
        if (tmp - val > 6)
392
392
          tmp= (char*) val + 6;
393
393
        l_time->second_part= (int) my_strtoll10(val, &tmp, &error);
394
 
        frac_part= 6 - (tmp - val);
 
394
        frac_part= 6 - (uint) (tmp - val);
395
395
        if (frac_part > 0)
396
396
          l_time->second_part*= (ulong) log_10_int[frac_part];
397
397
        val= tmp;
642
642
        if (!l_time->month)
643
643
          return 1;
644
644
        str->append(locale->month_names->type_names[l_time->month-1],
645
 
                    strlen(locale->month_names->type_names[l_time->month-1]),
 
645
                    (uint) strlen(locale->month_names->type_names[l_time->month-1]),
646
646
                    system_charset_info);
647
647
        break;
648
648
      case 'b':
649
649
        if (!l_time->month)
650
650
          return 1;
651
651
        str->append(locale->ab_month_names->type_names[l_time->month-1],
652
 
                    strlen(locale->ab_month_names->type_names[l_time->month-1]),
 
652
                    (uint) strlen(locale->ab_month_names->type_names[l_time->month-1]),
653
653
                    system_charset_info);
654
654
        break;
655
655
      case 'W':
658
658
        weekday= calc_weekday(calc_daynr(l_time->year,l_time->month,
659
659
                              l_time->day),0);
660
660
        str->append(locale->day_names->type_names[weekday],
661
 
                    strlen(locale->day_names->type_names[weekday]),
 
661
                    (uint) strlen(locale->day_names->type_names[weekday]),
662
662
                    system_charset_info);
663
663
        break;
664
664
      case 'a':
667
667
        weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
668
668
                             l_time->day),0);
669
669
        str->append(locale->ab_day_names->type_names[weekday],
670
 
                    strlen(locale->ab_day_names->type_names[weekday]),
 
670
                    (uint) strlen(locale->ab_day_names->type_names[weekday]),
671
671
                    system_charset_info);
672
672
        break;
673
673
      case 'D':
674
674
        if (type == MYSQL_TIMESTAMP_TIME)
675
675
          return 1;
676
 
        length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
 
676
        length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
677
677
        str->append_with_prefill(intbuff, length, 1, '0');
678
678
        if (l_time->day >= 10 &&  l_time->day <= 19)
679
679
          str->append(STRING_WITH_LEN("th"));
696
696
        }
697
697
        break;
698
698
      case 'Y':
699
 
        length= int10_to_str(l_time->year, intbuff, 10) - intbuff;
 
699
        length= (uint) (int10_to_str(l_time->year, intbuff, 10) - intbuff);
700
700
        str->append_with_prefill(intbuff, length, 4, '0');
701
701
        break;
702
702
      case 'y':
703
 
        length= int10_to_str(l_time->year%100, intbuff, 10) - intbuff;
 
703
        length= (uint) (int10_to_str(l_time->year%100, intbuff, 10) - intbuff);
704
704
        str->append_with_prefill(intbuff, length, 2, '0');
705
705
        break;
706
706
      case 'm':
707
 
        length= int10_to_str(l_time->month, intbuff, 10) - intbuff;
 
707
        length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff);
708
708
        str->append_with_prefill(intbuff, length, 2, '0');
709
709
        break;
710
710
      case 'c':
711
 
        length= int10_to_str(l_time->month, intbuff, 10) - intbuff;
 
711
        length= (uint) (int10_to_str(l_time->month, intbuff, 10) - intbuff);
712
712
        str->append_with_prefill(intbuff, length, 1, '0');
713
713
        break;
714
714
      case 'd':
715
 
        length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
 
715
        length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
716
716
        str->append_with_prefill(intbuff, length, 2, '0');
717
717
        break;
718
718
      case 'e':
719
 
        length= int10_to_str(l_time->day, intbuff, 10) - intbuff;
 
719
        length= (uint) (int10_to_str(l_time->day, intbuff, 10) - intbuff);
720
720
        str->append_with_prefill(intbuff, length, 1, '0');
721
721
        break;
722
722
      case 'f':
723
 
        length= int10_to_str(l_time->second_part, intbuff, 10) - intbuff;
 
723
        length= (uint) (int10_to_str(l_time->second_part, intbuff, 10) - intbuff);
724
724
        str->append_with_prefill(intbuff, length, 6, '0');
725
725
        break;
726
726
      case 'H':
727
 
        length= int10_to_str(l_time->hour, intbuff, 10) - intbuff;
 
727
        length= (uint) (int10_to_str(l_time->hour, intbuff, 10) - intbuff);
728
728
        str->append_with_prefill(intbuff, length, 2, '0');
729
729
        break;
730
730
      case 'h':
731
731
      case 'I':
732
732
        hours_i= (l_time->hour%24 + 11)%12+1;
733
 
        length= int10_to_str(hours_i, intbuff, 10) - intbuff;
 
733
        length= (uint) (int10_to_str(hours_i, intbuff, 10) - intbuff);
734
734
        str->append_with_prefill(intbuff, length, 2, '0');
735
735
        break;
736
736
      case 'i':                                 /* minutes */
737
 
        length= int10_to_str(l_time->minute, intbuff, 10) - intbuff;
 
737
        length= (uint) (int10_to_str(l_time->minute, intbuff, 10) - intbuff);
738
738
        str->append_with_prefill(intbuff, length, 2, '0');
739
739
        break;
740
740
      case 'j':
741
741
        if (type == MYSQL_TIMESTAMP_TIME)
742
742
          return 1;
743
 
        length= int10_to_str(calc_daynr(l_time->year,l_time->month,
 
743
        length= (uint) (int10_to_str(calc_daynr(l_time->year,l_time->month,
744
744
                                        l_time->day) - 
745
 
                     calc_daynr(l_time->year,1,1) + 1, intbuff, 10) - intbuff;
 
745
                     calc_daynr(l_time->year,1,1) + 1, intbuff, 10) - intbuff);
746
746
        str->append_with_prefill(intbuff, length, 3, '0');
747
747
        break;
748
748
      case 'k':
749
 
        length= int10_to_str(l_time->hour, intbuff, 10) - intbuff;
 
749
        length= (uint) (int10_to_str(l_time->hour, intbuff, 10) - intbuff);
750
750
        str->append_with_prefill(intbuff, length, 1, '0');
751
751
        break;
752
752
      case 'l':
753
753
        hours_i= (l_time->hour%24 + 11)%12+1;
754
 
        length= int10_to_str(hours_i, intbuff, 10) - intbuff;
 
754
        length= (uint) (int10_to_str(hours_i, intbuff, 10) - intbuff);
755
755
        str->append_with_prefill(intbuff, length, 1, '0');
756
756
        break;
757
757
      case 'p':
770
770
        break;
771
771
      case 'S':
772
772
      case 's':
773
 
        length= int10_to_str(l_time->second, intbuff, 10) - intbuff;
 
773
        length= (uint) (int10_to_str(l_time->second, intbuff, 10) - intbuff);
774
774
        str->append_with_prefill(intbuff, length, 2, '0');
775
775
        break;
776
776
      case 'T':
788
788
        uint year;
789
789
        if (type == MYSQL_TIMESTAMP_TIME)
790
790
          return 1;
791
 
        length= int10_to_str(calc_week(l_time,
 
791
        length= (uint) (int10_to_str(calc_week(l_time,
792
792
                                       (*ptr) == 'U' ?
793
793
                                       WEEK_FIRST_WEEKDAY : WEEK_MONDAY_FIRST,
794
794
                                       &year),
795
 
                             intbuff, 10) - intbuff;
 
795
                             intbuff, 10) - intbuff);
796
796
        str->append_with_prefill(intbuff, length, 2, '0');
797
797
      }
798
798
      break;
802
802
        uint year;
803
803
        if (type == MYSQL_TIMESTAMP_TIME)
804
804
          return 1;
805
 
        length= int10_to_str(calc_week(l_time,
 
805
        length= (uint) (int10_to_str(calc_week(l_time,
806
806
                                       ((*ptr) == 'V' ?
807
807
                                        (WEEK_YEAR | WEEK_FIRST_WEEKDAY) :
808
808
                                        (WEEK_YEAR | WEEK_MONDAY_FIRST)),
809
809
                                       &year),
810
 
                             intbuff, 10) - intbuff;
 
810
                             intbuff, 10) - intbuff);
811
811
        str->append_with_prefill(intbuff, length, 2, '0');
812
812
      }
813
813
      break;
822
822
                          WEEK_YEAR | WEEK_FIRST_WEEKDAY :
823
823
                          WEEK_YEAR | WEEK_MONDAY_FIRST),
824
824
                         &year);
825
 
        length= int10_to_str(year, intbuff, 10) - intbuff;
 
825
        length= (uint) (int10_to_str(year, intbuff, 10) - intbuff);
826
826
        str->append_with_prefill(intbuff, length, 4, '0');
827
827
      }
828
828
      break;
831
831
          return 1;
832
832
        weekday=calc_weekday(calc_daynr(l_time->year,l_time->month,
833
833
                                        l_time->day),1);
834
 
        length= int10_to_str(weekday, intbuff, 10) - intbuff;
 
834
        length= (uint) (int10_to_str(weekday, intbuff, 10) - intbuff);
835
835
        str->append_with_prefill(intbuff, length, 1, '0');
836
836
        break;
837
837
 
881
881
      value= value*LL(10) + (longlong) (*str - '0');
882
882
    if (transform_msec && i == count - 1) // microseconds always last
883
883
    {
884
 
      long msec_length= 6 - (str - start);
 
884
      long msec_length= 6 - (uint) (str - start);
885
885
      if (msec_length > 0)
886
886
        value*= (long) log_10_int[msec_length];
887
887
    }
1060
1060
  }
1061
1061
  null_value=0;
1062
1062
  month_name= locale->month_names->type_names[month-1];
1063
 
  str->copy(month_name, strlen(month_name), &my_charset_utf8_bin,
 
1063
  str->copy(month_name, (uint) strlen(month_name), &my_charset_utf8_bin,
1064
1064
            collation.collation, &err);
1065
1065
  return str;
1066
1066
}
1210
1210
    return (String*) 0;
1211
1211
  
1212
1212
  day_name= locale->day_names->type_names[weekday];
1213
 
  str->copy(day_name, strlen(day_name), &my_charset_utf8_bin,
 
1213
  str->copy(day_name, (uint) strlen(day_name), &my_charset_utf8_bin,
1214
1214
            collation.collation, &err);
1215
1215
  return str;
1216
1216
}
3176
3176
       format++)
3177
3177
  {
3178
3178
    uint format_name_len;
3179
 
    format_name_len= strlen(format_name);
 
3179
    format_name_len= (uint) strlen(format_name);
3180
3180
    if (val_len == format_name_len &&
3181
3181
        !my_strnncoll(&my_charset_latin1, 
3182
3182
                      (const uchar *) val->ptr(), val_len, 
3183
3183
                      (const uchar *) format_name, val_len))
3184
3184
    {
3185
3185
      const char *format_str= get_date_time_format_str(format, type);
3186
 
      str->set(format_str, strlen(format_str), &my_charset_bin);
 
3186
      str->set(format_str, (uint) strlen(format_str), &my_charset_bin);
3187
3187
      return str;
3188
3188
    }
3189
3189
  }