<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/mariadb-git.git/sql/item_strfunc.h, branch 10.0-merge</title>
<subtitle>github.com: MariaDB/server.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/'/>
<entry>
<title>MDEV-12681 Wrong VIEW results for CHAR(0xDF USING latin1)</title>
<updated>2017-11-15T11:52:03+00:00</updated>
<author>
<name>Alexander Barkov</name>
<email>bar@mariadb.org</email>
</author>
<published>2017-11-15T11:52:03+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=02e35ef5f237b03c3e735fa7afe21dd92086cbc5'/>
<id>02e35ef5f237b03c3e735fa7afe21dd92086cbc5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-8949: COLUMN_CREATE unicode name breakage</title>
<updated>2017-11-14T09:49:46+00:00</updated>
<author>
<name>Oleksandr Byelkin</name>
<email>sanja@mariadb.com</email>
</author>
<published>2017-11-13T15:30:02+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=2913f615f050f356f7be178e5d91650b86b33e4e'/>
<id>2913f615f050f356f7be178e5d91650b86b33e4e</id>
<content type='text'>
Use utf-mb4 if it is possible.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Use utf-mb4 if it is possible.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-13173 An RLIKE that previously worked on 10.0 now returns "Got error 'pcre_exec: recursion limit of 100 exceeded' from regexp"</title>
<updated>2017-07-20T18:13:28+00:00</updated>
<author>
<name>Sergei Golubchik</name>
<email>serg@mariadb.org</email>
</author>
<published>2017-07-19T20:22:14+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=2fcd8c12522f5f935066b661c42b5b7cb416d148'/>
<id>2fcd8c12522f5f935066b661c42b5b7cb416d148</id>
<content type='text'>
1. use Regexp_processor_pcre::set_recursion_limit() to set the
   recursion limit depending on the current available stack size
2. make pcre stack frame to be estimated no less than 500 bytes.
   sometimes pcre estimates it too low, even though the manual
   says 500+16 bytes (it was estimated only 188 for me, actual
   frame size was 512).
3. do it for embedded too
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
1. use Regexp_processor_pcre::set_recursion_limit() to set the
   recursion limit depending on the current available stack size
2. make pcre stack frame to be estimated no less than 500 bytes.
   sometimes pcre estimates it too low, even though the manual
   says 500+16 bytes (it was estimated only 188 for me, actual
   frame size was 512).
3. do it for embedded too
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-10306 Wrong results with combination of CONCAT, SUBSTR and CONVERT in subquery</title>
<updated>2017-06-19T08:45:32+00:00</updated>
<author>
<name>Alexander Barkov</name>
<email>bar@mariadb.org</email>
</author>
<published>2017-06-19T08:45:32+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=3a37afec293e36e51b83a9bd338ad5f74e7f63c0'/>
<id>3a37afec293e36e51b83a9bd338ad5f74e7f63c0</id>
<content type='text'>
The bug happens because of a combination of unfortunate circumstances:

1. Arguments args[0] and args[2] of Item_func_concat point recursively
(through Item_direct_view_ref's) to the same Item_func_conv_charset.
Both args[0]-&gt;args[0]-&gt;ref[0] and args[2]-&gt;args[0]-&gt;ref[0] refer to
this Item_func_conv_charset.

2. When Item_func_concat::args[0]-&gt;val_str() is called,
Item_func_conv_charset::val_str() writes its result to
Item_func_conc_charset::tmp_value.

3. Then, for optimization purposes (to avoid copying),
Item_func_substr::val_str() initializes Item_func_substr::tmp_value
to point to the buffer fragment owned by Item_func_conv_charset::tmp_value
Item_func_substr::tmp_value is returned as a result of
Item_func_concat::args[0]-&gt;val_str().

4. Due to optimization to avoid memory reallocs,
Item_func_concat::val_str() remembers the result of args[0]-&gt;val_str()
in "res" and further uses "res" to collect the return value.

5. When Item_func_concat::args[2]-&gt;val_str() is called,
Item_func_conv_charset::tmp_value gets overwritten (see #1),
which effectively overwrites args[0]'s Item_func_substr::tmp_value (see #3),
which effectively overwrites "res" (see #4).

This patch does the following:

a. Changes Item_func_conv_charset::val_str(String *str) to use
   tmp_value and str the other way around. After this change tmp_value
   is used to store a temporary result, while str is used to return the value.
   The fixes the second problem (without SUBSTR):
     SELECT CONCAT(t2,'-',t2) c2
       FROM (SELECT CONVERT(t USING latin1) t2 FROM t1) sub;
   As Item_func_concat::val_str() supplies two different buffers when calling
   args[0]-&gt;val_str() and args[2]-&gt;val_str(), in the new reduction the result
   created during args[0]-&gt;val_str() does not get overwritten by
   args[2]-&gt;val_str().

b. Fixing the same problem in val_str() for similar classes

   Item_func_to_base64
   Item_func_from_base64
   Item_func_weight_string
   Item_func_hex
   Item_func_unhex
   Item_func_quote
   Item_func_compress
   Item_func_uncompress
   Item_func_des_encrypt
   Item_func_des_decrypt
   Item_func_conv_charset
   Item_func_reverse
   Item_func_soundex
   Item_func_aes_encrypt
   Item_func_aes_decrypt
   Item_func_buffer

c. Fixing Item_func::val_str_from_val_str_ascii() the same way.
   Now Item_str_ascii_func::ascii_buff is used for temporary value,
   while the parameter passed to val_str() is used to return the result.
   This fixes the same problem when conversion (from ASCII to e.g. UCS2)
   takes place. See the ctype_ucs.test for example queries that returned
   wrong results before the fix.

d. Some Item_func descendand classes had temporary String buffers
   (tmp_value and tmp_str), but did not really use them.
   Removing these temporary buffers from:

   Item_func_decode_histogram
   Item_func_format
   Item_func_binlog_gtid_pos
   Item_func_spatial_collection:

e. Removing Item_func_buffer::tmp_value, because it's not used any more.

f. Renaming Item_func_[un]compress::buffer to "tmp_value",
   for consistency with other classes.

Note, this patch does not fix the following classes
(although they have a similar problem):

   Item_str_conv
   Item_func_make_set
   Item_char_typecast

They have a complex implementations and simple swapping between "tmp_value"
and "str" won't work. These classes will be fixed separately.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The bug happens because of a combination of unfortunate circumstances:

1. Arguments args[0] and args[2] of Item_func_concat point recursively
(through Item_direct_view_ref's) to the same Item_func_conv_charset.
Both args[0]-&gt;args[0]-&gt;ref[0] and args[2]-&gt;args[0]-&gt;ref[0] refer to
this Item_func_conv_charset.

2. When Item_func_concat::args[0]-&gt;val_str() is called,
Item_func_conv_charset::val_str() writes its result to
Item_func_conc_charset::tmp_value.

3. Then, for optimization purposes (to avoid copying),
Item_func_substr::val_str() initializes Item_func_substr::tmp_value
to point to the buffer fragment owned by Item_func_conv_charset::tmp_value
Item_func_substr::tmp_value is returned as a result of
Item_func_concat::args[0]-&gt;val_str().

4. Due to optimization to avoid memory reallocs,
Item_func_concat::val_str() remembers the result of args[0]-&gt;val_str()
in "res" and further uses "res" to collect the return value.

5. When Item_func_concat::args[2]-&gt;val_str() is called,
Item_func_conv_charset::tmp_value gets overwritten (see #1),
which effectively overwrites args[0]'s Item_func_substr::tmp_value (see #3),
which effectively overwrites "res" (see #4).

This patch does the following:

a. Changes Item_func_conv_charset::val_str(String *str) to use
   tmp_value and str the other way around. After this change tmp_value
   is used to store a temporary result, while str is used to return the value.
   The fixes the second problem (without SUBSTR):
     SELECT CONCAT(t2,'-',t2) c2
       FROM (SELECT CONVERT(t USING latin1) t2 FROM t1) sub;
   As Item_func_concat::val_str() supplies two different buffers when calling
   args[0]-&gt;val_str() and args[2]-&gt;val_str(), in the new reduction the result
   created during args[0]-&gt;val_str() does not get overwritten by
   args[2]-&gt;val_str().

b. Fixing the same problem in val_str() for similar classes

   Item_func_to_base64
   Item_func_from_base64
   Item_func_weight_string
   Item_func_hex
   Item_func_unhex
   Item_func_quote
   Item_func_compress
   Item_func_uncompress
   Item_func_des_encrypt
   Item_func_des_decrypt
   Item_func_conv_charset
   Item_func_reverse
   Item_func_soundex
   Item_func_aes_encrypt
   Item_func_aes_decrypt
   Item_func_buffer

c. Fixing Item_func::val_str_from_val_str_ascii() the same way.
   Now Item_str_ascii_func::ascii_buff is used for temporary value,
   while the parameter passed to val_str() is used to return the result.
   This fixes the same problem when conversion (from ASCII to e.g. UCS2)
   takes place. See the ctype_ucs.test for example queries that returned
   wrong results before the fix.

d. Some Item_func descendand classes had temporary String buffers
   (tmp_value and tmp_str), but did not really use them.
   Removing these temporary buffers from:

   Item_func_decode_histogram
   Item_func_format
   Item_func_binlog_gtid_pos
   Item_func_spatial_collection:

e. Removing Item_func_buffer::tmp_value, because it's not used any more.

f. Renaming Item_func_[un]compress::buffer to "tmp_value",
   for consistency with other classes.

Note, this patch does not fix the following classes
(although they have a similar problem):

   Item_str_conv
   Item_func_make_set
   Item_char_typecast

They have a complex implementations and simple swapping between "tmp_value"
and "str" won't work. These classes will be fixed separately.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-12666: CURRENT_ROLE() and DATABASE() does not work in a view</title>
<updated>2017-06-15T16:20:35+00:00</updated>
<author>
<name>Vicențiu Ciorbaru</name>
<email>vicentiu@mariadb.org</email>
</author>
<published>2017-05-22T14:06:01+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=f0ad93403f4f39873618759585ca765169ecf000'/>
<id>f0ad93403f4f39873618759585ca765169ecf000</id>
<content type='text'>
The problem lies in how CURRENT_ROLE is defined. The
Item_func_current_role inherits from Item_func_sysconst, which defines
a safe_charset_converter to be a const_charset_converter.

During view creation, if there is no role previously set, the current_role()
function returns NULL.

This is captured on item instantiation and the
const_charset_converter call subsequently returns an Item_null.
In turn, the function is replaced with Item_null and the view is
then created with an Item_null instead of Item_func_current_role.

Without this patch, the first SHOW CREATE VIEW from the testcase would
have a where clause of WHERE role_name = NULL, while the second SHOW
CREATE VIEW would show a correctly created view.

The same applies for the DATABASE function, as it can change as well.

There is an additional problem with CURRENT_ROLE() when used in a
prepared statement. During prepared statement creation we used to set
the string_value of the function to the current role as well as the
null_value flag. During execution, if CURRENT_ROLE was not null, the
null_value flag was never set to not-null during fix_fields.

Item_func_current_user however can never be NULL so it did not show this
problem in a view before. At the same time, the CURRENT_USER() can not
be changed between prepared statement execution and creation so the
implementation where the value is stored during fix_fields is
sufficient.

Note also that DATABASE() function behaves differently during prepared
statements. See bug 25843 for details or commit
7e0ad09edff587dadc3e9855fc81e1b7de8f2199
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The problem lies in how CURRENT_ROLE is defined. The
Item_func_current_role inherits from Item_func_sysconst, which defines
a safe_charset_converter to be a const_charset_converter.

During view creation, if there is no role previously set, the current_role()
function returns NULL.

This is captured on item instantiation and the
const_charset_converter call subsequently returns an Item_null.
In turn, the function is replaced with Item_null and the view is
then created with an Item_null instead of Item_func_current_role.

Without this patch, the first SHOW CREATE VIEW from the testcase would
have a where clause of WHERE role_name = NULL, while the second SHOW
CREATE VIEW would show a correctly created view.

The same applies for the DATABASE function, as it can change as well.

There is an additional problem with CURRENT_ROLE() when used in a
prepared statement. During prepared statement creation we used to set
the string_value of the function to the current role as well as the
null_value flag. During execution, if CURRENT_ROLE was not null, the
null_value flag was never set to not-null during fix_fields.

Item_func_current_user however can never be NULL so it did not show this
problem in a view before. At the same time, the CURRENT_USER() can not
be changed between prepared statement execution and creation so the
implementation where the value is stored during fix_fields is
sufficient.

Note also that DATABASE() function behaves differently during prepared
statements. See bug 25843 for details or commit
7e0ad09edff587dadc3e9855fc81e1b7de8f2199
</pre>
</div>
</content>
</entry>
<entry>
<title>Merge branch '5.5' into 10.0</title>
<updated>2015-05-04T20:00:24+00:00</updated>
<author>
<name>Sergei Golubchik</name>
<email>serg@mariadb.org</email>
</author>
<published>2015-05-04T20:00:24+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=49c853fb948aeaeb5c7e3f02da3f14da51ee4100'/>
<id>49c853fb948aeaeb5c7e3f02da3f14da51ee4100</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-7814 Assertion `args[0]-&gt;fixed' fails in Item_func_conv_charset::Item_func_conv_charset</title>
<updated>2015-04-15T08:08:37+00:00</updated>
<author>
<name>Alexander Barkov</name>
<email>bar@mariadb.org</email>
</author>
<published>2015-04-15T08:08:37+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=59d847bd26b8988678e6215265e2ff14333b3446'/>
<id>59d847bd26b8988678e6215265e2ff14333b3446</id>
<content type='text'>
Removing a wrong assertion.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Removing a wrong assertion.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-6044 MySQL BUG#12735829 - SPACE() FUNCTION WARNING REFERS TO REPEAT() IN ER_WARN_ALLOWED_PACKET_OVERFLOWED</title>
<updated>2014-09-04T04:50:06+00:00</updated>
<author>
<name>Alexander Barkov</name>
<email>bar@mariadb.org</email>
</author>
<published>2014-09-04T04:50:06+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=58eb51d1cfb50058ce52dda5ef95fb7f2144467d'/>
<id>58eb51d1cfb50058ce52dda5ef95fb7f2144467d</id>
<content type='text'>
Merged from 5.6

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Merged from 5.6

</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-6661 PI() does not work well in UCS2/UTF16/UTF32 context</title>
<updated>2014-09-01T16:57:32+00:00</updated>
<author>
<name>Alexander Barkov</name>
<email>bar@mariadb.org</email>
</author>
<published>2014-09-01T16:57:32+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=1427e1db99ac44dedbc78e8655742a8ed9bfd755'/>
<id>1427e1db99ac44dedbc78e8655742a8ed9bfd755</id>
<content type='text'>
MDEV-6666 Malformed result for CONCAT(utf8_column, binary_string)

Item_static_string_func::safe_charset_converter() and 
Item_hex_string::safe_charset_converter() did not
handle character sets with mbminlen&gt;1 properly, as well as
did not handle conversion from binary to multi-byte well.

Introducing Item::const_charset_converter(), to reuse it in a number
of Item_*::safe_charset_converter().

</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
MDEV-6666 Malformed result for CONCAT(utf8_column, binary_string)

Item_static_string_func::safe_charset_converter() and 
Item_hex_string::safe_charset_converter() did not
handle character sets with mbminlen&gt;1 properly, as well as
did not handle conversion from binary to multi-byte well.

Introducing Item::const_charset_converter(), to reuse it in a number
of Item_*::safe_charset_converter().

</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-5745 analyze MySQL fix for bug#12368495</title>
<updated>2014-07-28T08:47:14+00:00</updated>
<author>
<name>Alexander Barkov</name>
<email>bar@mariadb.org</email>
</author>
<published>2014-07-28T08:47:14+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=c57c5be12a2d7d066cc508043da87cf51eb75cd3'/>
<id>c57c5be12a2d7d066cc508043da87cf51eb75cd3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
