<?xml version="1.0" encoding="utf-8"?>
<launchpad-bug id="998340">
  <date_last_updated>2012-05-12 07:05:44.333135+00:00</date_last_updated>
  <api_links>
    <bug_api_link>https://api.launchpad.net/1.0/bugs/998340</bug_api_link>
    <bug_owner_link>https://api.launchpad.net/1.0/~igorb-seattle</bug_owner_link>
    <milestone_link></milestone_link>
    <linked_branches_collection_link>https://api.launchpad.net/1.0/bugs/998340/linked_branches</linked_branches_collection_link>
    <activity_link>https://api.launchpad.net/1.0/bugs/998340/activity</activity_link>
  </api_links>
  <bug_web_link>https://bugs.launchpad.net/bugs/998340</bug_web_link>
  <owner>Igor Babaev</owner>
  <assignee>Alexey Botchkov</assignee>
  <milestone_title></milestone_title>
  <duplicate_link></duplicate_link>
  <duplicate_bug_id></duplicate_bug_id>
  <title>Valgrind complains on simple selects containing expression DAY(FROM_UNIXTIME(-1))</title>
  <status>New</status>
  <importance>High</importance>
  <created>2012-05-12 06:36:54.880746+00:00</created>
  <description>
<![CDATA[The following test case makes valgrind complain when running mariadb-5.1:

SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1)));
SELECT LEFT('1', DAY(FROM_UNIXTIME(-1)));
SELECT RIGHT('1', DAY(FROM_UNIXTIME(-1)));
SELECT REPEAT('1', DAY(FROM_UNIXTIME(-1)));
SELECT RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');
SELECT LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?');

CREATE TABLE t1
SELECT SUBSTRING('1', DAY(FROM_UNIXTIME(-1))) AS f1,
       LEFT('1', DAY(FROM_UNIXTIME(-1))) AS f2,
       RIGHT('1', DAY(FROM_UNIXTIME(-1))) AS f3,
       REPEAT('1', DAY(FROM_UNIXTIME(-1))) AS f4,
       RPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f5,
       LPAD('hi', DAY(FROM_UNIXTIME(-1)),'?') AS f6;
SHOW CREATE TABLE t1;
DROP TABLE t1;

(see also bug##12634989 from mysql-trunk)

The complains are like this:

==24162== Conditional jump or move depends on uninitialised value(s)
==24162==    at 0x622A1A: Item_func_substr::fix_length_and_dec() (item_strfunc.cc:1273)
==24162==    by 0x5EF4B7: Item_func::fix_fields(THD*, Item**) (item_func.cc:205)
==24162==    by 0x61E3DA: Item_str_func::fix_fields(THD*, Item**) (item_strfunc.cc:67)
==24162==    by 0x70BE1B: setup_fields(THD*, Item**, List<Item>&, enum_mark_columns, List<Item>*, bool) (sql_base.cc:7714)
==24162==    by 0x71F07B: JOIN::prepare(Item***, TABLE_LIST*, unsigned int, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, st_select_lex*, st_select_lex_unit*) (sql_select.cc:530)
==24162==    by 0x7268A7: mysql_select(THD*, Item***, TABLE_LIST*, unsigned int, List<Item>&, Item*, unsigned int, st_order*, st_order*, Item*, st_order*, unsigned long long, select_result*, st_select_lex_unit*, st_select_lex*) (sql_select.cc:2545)
==24162==    by 0x71E818: handle_select(THD*, st_lex*, select_result*, unsigned long) (sql_select.cc:280)
==24162==    by 0x6BD119: execute_sqlcom_select(THD*, TABLE_LIST*) (sql_parse.cc:5241)
==24162==    by 0x6B4232: mysql_execute_command(THD*) (sql_parse.cc:2380)
==24162==    by 0x6BF845: mysql_parse(THD*, char*, unsigned int, char const**) (sql_parse.cc:6216)
==24162==    by 0x6B1B30: dispatch_command(enum_server_command, THD*, char*, unsigned int) (sql_parse.cc:1294)
==24162==    by 0x6B0AE0: do_command(THD*) (sql_parse.cc:906)
==24162==    by 0x6AD563: handle_one_connection (sql_connect.cc:1208)
==24162==    by 0x5D16A4E: start_thread (in /lib64/libpthread-2.11.2.so)

Most probably we have the same problem in other versions of MariaDB]]>  </description>
  <activities>
    <activity datechanged="2012-05-12T06:36:54.880746+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[]]>      </newvalue>
      <whatchanged>bug</whatchanged>
      <person>Igor Babaev</person>
      <message>added bug</message>
    </activity>
    <activity datechanged="2012-05-12T06:42:12.049122+00:00">
      <oldvalue>
<![CDATA[]]>      </oldvalue>
      <newvalue>
<![CDATA[Alexey Botchkov (holyfoot)]]>      </newvalue>
      <whatchanged>maria: assignee</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2012-05-12T06:42:39.825724+00:00">
      <oldvalue>
<![CDATA[Undecided]]>      </oldvalue>
      <newvalue>
<![CDATA[High]]>      </newvalue>
      <whatchanged>maria: importance</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
    <activity datechanged="2012-05-12T07:05:44.211573+00:00">
      <oldvalue>
<![CDATA[Valgrind complains from simple selects containing expression DAY(FROM_UNIXTIME(-1))]]>      </oldvalue>
      <newvalue>
<![CDATA[Valgrind complains on simple selects containing expression DAY(FROM_UNIXTIME(-1))]]>      </newvalue>
      <whatchanged>summary</whatchanged>
      <person>Igor Babaev</person>
      <message></message>
    </activity>
  </activities>
</launchpad-bug>
