<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/mariadb-git.git/sql/sql_sort.h, branch 10.56-MDEV-30986</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>Merge remote-tracking branch '10.4' into 10.5</title>
<updated>2023-03-31T19:32:41+00:00</updated>
<author>
<name>Oleksandr Byelkin</name>
<email>sanja@mariadb.com</email>
</author>
<published>2023-03-31T19:32:41+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=ac5a534a4caa6c86762e721dfe7183be2fee29ca'/>
<id>ac5a534a4caa6c86762e721dfe7183be2fee29ca</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-20057 Distinct SUM on CROSS JOIN and grouped returns wrong result</title>
<updated>2023-02-17T14:08:50+00:00</updated>
<author>
<name>Monty</name>
<email>monty@mariadb.org</email>
</author>
<published>2023-02-16T12:19:33+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=476b24d084e7e717310155bb986eb086d3c1e1a6'/>
<id>476b24d084e7e717310155bb986eb086d3c1e1a6</id>
<content type='text'>
SELECT DISTINCT did not work with expressions with sum functions.
Distinct was only done on the values stored in the intermediate temporary
tables, which only stored the value of each sum function.

In other words:
SELECT DISTINCT sum(a),sum(b),avg(c) ... worked.
SELECT DISTINCT sum(a),sum(b) &gt; 2,sum(c)+sum(d) would not work.

The later query would do ONLY apply distinct on the sum(a) part.

Reviewer: Sergei Petrunia &lt;sergey@mariadb.com&gt;


This was fixed by extending remove_dup_with_hash_index() and
remove_dup_with_compare() to take into account the columns in the result
list that where not stored in the temporary table.

Note that in many cases the above dup removal functions are not used as
the optimizer may be able to either remove duplicates early or it will
discover that duplicate remove is not needed. The later happens for
example if the group by fields is part of the result.

Other things:
- Backported from 11.0 the change of Sort_param.tmp_buffer from char* to
  String.
- Changed Type_handler::make_sort_key() to take String as a parameter
  instead of Sort_param. This was done to allow make_sort_key() functions
  to be reused by distinct elimination functions.
  This makes Type_handler_string_result::make_sort_key() similar to code
  in 11.0
- Simplied error handling in remove_dup_with_compare() to remove code
  duplication.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
SELECT DISTINCT did not work with expressions with sum functions.
Distinct was only done on the values stored in the intermediate temporary
tables, which only stored the value of each sum function.

In other words:
SELECT DISTINCT sum(a),sum(b),avg(c) ... worked.
SELECT DISTINCT sum(a),sum(b) &gt; 2,sum(c)+sum(d) would not work.

The later query would do ONLY apply distinct on the sum(a) part.

Reviewer: Sergei Petrunia &lt;sergey@mariadb.com&gt;


This was fixed by extending remove_dup_with_hash_index() and
remove_dup_with_compare() to take into account the columns in the result
list that where not stored in the temporary table.

Note that in many cases the above dup removal functions are not used as
the optimizer may be able to either remove duplicates early or it will
discover that duplicate remove is not needed. The later happens for
example if the group by fields is part of the result.

Other things:
- Backported from 11.0 the change of Sort_param.tmp_buffer from char* to
  String.
- Changed Type_handler::make_sort_key() to take String as a parameter
  instead of Sort_param. This was done to allow make_sort_key() functions
  to be reused by distinct elimination functions.
  This makes Type_handler_string_result::make_sort_key() similar to code
  in 11.0
- Simplied error handling in remove_dup_with_compare() to remove code
  duplication.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-24015: SQL Error (1038): Out of sort memory when enough memory for the sort buffer is provided</title>
<updated>2020-10-28T05:23:22+00:00</updated>
<author>
<name>Varun Gupta</name>
<email>varun.gupta@mariadb.com</email>
</author>
<published>2020-10-26T06:35:47+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=db56f9b8521077c119d700927510c7a0e54bd820'/>
<id>db56f9b8521077c119d700927510c7a0e54bd820</id>
<content type='text'>
For a correlated subquery filesort is executed multiple times.
During each execution, sortlength() computed total sort key length in
Sort_keys::sort_length, without resetting it first.

Eventually Sort_keys::sort_length got larger than @@sort_buffer_size, which
caused filesort() to be aborted with error.

Fixed by making sortlength() to compute lengths only during the first
invocation. Subsequent invocations return pre-computed values.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For a correlated subquery filesort is executed multiple times.
During each execution, sortlength() computed total sort key length in
Sort_keys::sort_length, without resetting it first.

Eventually Sort_keys::sort_length got larger than @@sort_buffer_size, which
caused filesort() to be aborted with error.

Fixed by making sortlength() to compute lengths only during the first
invocation. Subsequent invocations return pre-computed values.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-22836: Server crashes in err_conv / ErrBuff::set_str</title>
<updated>2020-06-09T13:13:19+00:00</updated>
<author>
<name>Varun Gupta</name>
<email>varun.gupta@mariadb.com</email>
</author>
<published>2020-06-09T04:53:47+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=04c5cdffeb419f7679d8c300a4dccb56c23958fa'/>
<id>04c5cdffeb419f7679d8c300a4dccb56c23958fa</id>
<content type='text'>
The issue here is charset for Sort_param::tmp_buffer is cleared when bzero is done for Sort_param.
Make sure to set the charset explicitly in the constructor for tmp_buffer.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The issue here is charset for Sort_param::tmp_buffer is cleared when bzero is done for Sort_param.
Make sure to set the charset explicitly in the constructor for tmp_buffer.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-22303: Incorrect ordering with REGEXP_REPLACE and OFFSET/LIMIT</title>
<updated>2020-06-01T12:23:07+00:00</updated>
<author>
<name>Varun Gupta</name>
<email>varun.gupta@mariadb.com</email>
</author>
<published>2020-05-29T20:57:33+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=ade8253cb9260371ffd393f0962f56619c949c07'/>
<id>ade8253cb9260371ffd393f0962f56619c949c07</id>
<content type='text'>
For character sets and collation where character to weight mapping &gt; 1,
there we need to make sure while creating a sort key,
a temporary buffer is created to store the value of the item by val_str function
and then copy that value back to the sort buffer.
In this case when using a priority queue Sort_param::tmp_buffer was not allocated.

Minor refactoring:
Changed Sort_param::tmp_buffer from char* to String
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
For character sets and collation where character to weight mapping &gt; 1,
there we need to make sure while creating a sort key,
a temporary buffer is created to store the value of the item by val_str function
and then copy that value back to the sort buffer.
In this case when using a priority queue Sort_param::tmp_buffer was not allocated.

Minor refactoring:
Changed Sort_param::tmp_buffer from char* to String
</pre>
</div>
</content>
</entry>
<entry>
<title>perfschema memory related instrumentation changes</title>
<updated>2020-03-10T18:24:22+00:00</updated>
<author>
<name>Sergei Golubchik</name>
<email>serg@mariadb.org</email>
</author>
<published>2020-01-29T12:50:26+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=7c58e97bf6f80a251046c5b3e7bce826fe058bd6'/>
<id>7c58e97bf6f80a251046c5b3e7bce826fe058bd6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-21580: Allow packed sort keys in sort buffer</title>
<updated>2020-03-10T09:39:17+00:00</updated>
<author>
<name>Varun Gupta</name>
<email>varun.gupta@mariadb.com</email>
</author>
<published>2020-03-09T23:26:38+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=b753ac066bc26acda9deb707a31c112f1bbf9ec2'/>
<id>b753ac066bc26acda9deb707a31c112f1bbf9ec2</id>
<content type='text'>
This task deals with packing the sort key inside the sort buffer, which  would
lead to efficient usage of the memory allocated for the sort buffer.

The changes brought by this feature are
  1) Sort buffers would have sort keys of variable length
  2) The format for sort keys inside the sort buffer would look like
     |&lt;sort_length&gt;&lt;null_byte&gt;&lt;key_part1&gt;&lt;null_byte&gt;&lt;key_part2&gt;.......|
      sort_length is the extra bytes that are required to store the variable
      length of a sort key.
  3) When packing of sort key is done we store the ORIGINAL VALUES inside
     the sort buffer and not the STRXFRM form (mem-comparable sort keys).
  4) Special comparison function packed_keys_comparison() is introduced
     to compare 2 sort keys.

This patch also contains contributions from Sergei Petrunia.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This task deals with packing the sort key inside the sort buffer, which  would
lead to efficient usage of the memory allocated for the sort buffer.

The changes brought by this feature are
  1) Sort buffers would have sort keys of variable length
  2) The format for sort keys inside the sort buffer would look like
     |&lt;sort_length&gt;&lt;null_byte&gt;&lt;key_part1&gt;&lt;null_byte&gt;&lt;key_part2&gt;.......|
      sort_length is the extra bytes that are required to store the variable
      length of a sort key.
  3) When packing of sort key is done we store the ORIGINAL VALUES inside
     the sort buffer and not the STRXFRM form (mem-comparable sort keys).
  4) Special comparison function packed_keys_comparison() is introduced
     to compare 2 sort keys.

This patch also contains contributions from Sergei Petrunia.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-21263: Fix -Wclass-memaccess</title>
<updated>2020-01-22T08:06:02+00:00</updated>
<author>
<name>Marko Mäkelä</name>
<email>marko.makela@mariadb.com</email>
</author>
<published>2020-01-22T08:06:02+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=6f2ca4eac167a12529f6062b300d89af83b310ec'/>
<id>6f2ca4eac167a12529f6062b300d89af83b310ec</id>
<content type='text'>
Since commit f52bf92014efae6a1da9c2f26a7e3792ed5f5396 the type
Sql_sort is non-trivial, because it includes a data member
Bounds_checked_array&lt;SORT_FIELD&gt; local_sortorder.
There still is no vtable, so memset() is safe to invoke, but
we must add a cast to silence a warning in GCC 8 or later.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Since commit f52bf92014efae6a1da9c2f26a7e3792ed5f5396 the type
Sql_sort is non-trivial, because it includes a data member
Bounds_checked_array&lt;SORT_FIELD&gt; local_sortorder.
There still is no vtable, so memset() is safe to invoke, but
we must add a cast to silence a warning in GCC 8 or later.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-21263: Use C++11 default constructor</title>
<updated>2020-01-21T10:56:54+00:00</updated>
<author>
<name>Marko Mäkelä</name>
<email>marko.makela@mariadb.com</email>
</author>
<published>2020-01-21T10:56:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=e1b62f30269e098fb092e577529684fa4189516a'/>
<id>e1b62f30269e098fb092e577529684fa4189516a</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-21263: Allow packed values of non-sorted fields in the sort buffer</title>
<updated>2020-01-20T20:07:47+00:00</updated>
<author>
<name>Varun Gupta</name>
<email>varun.gupta@mariadb.com</email>
</author>
<published>2020-01-20T20:07:47+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=f52bf92014efae6a1da9c2f26a7e3792ed5f5396'/>
<id>f52bf92014efae6a1da9c2f26a7e3792ed5f5396</id>
<content type='text'>
This task deals with packing the non-sorted fields (or addon fields).
This would lead to efficient usage of the memory allocated for the sort buffer.
The changes brought by this feature are
  1) Sort buffers would have records of variable length
  2) Each record in the sort buffer would be stored like
     &lt;sort_key1&gt;&lt;sort_key2&gt;....&lt;addon_length&gt;&lt;null_bytes&gt;&lt;field1&gt;&lt;field2&gt;....
     addon_length is the extra bytes that are required to store the variable
     length of addon field across different records.
  3) Changes in rr_unpack_from_buffer and rr_from_tempfile to take into account
     the variable length of records.

Ported  WL#1509 Pack values of non-sorted fields in the sort buffer from
MySQL by Tor Didriksen
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This task deals with packing the non-sorted fields (or addon fields).
This would lead to efficient usage of the memory allocated for the sort buffer.
The changes brought by this feature are
  1) Sort buffers would have records of variable length
  2) Each record in the sort buffer would be stored like
     &lt;sort_key1&gt;&lt;sort_key2&gt;....&lt;addon_length&gt;&lt;null_bytes&gt;&lt;field1&gt;&lt;field2&gt;....
     addon_length is the extra bytes that are required to store the variable
     length of addon field across different records.
  3) Changes in rr_unpack_from_buffer and rr_from_tempfile to take into account
     the variable length of records.

Ported  WL#1509 Pack values of non-sorted fields in the sort buffer from
MySQL by Tor Didriksen
</pre>
</div>
</content>
</entry>
</feed>
