<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/mariadb-git.git/sql/sql_window.cc, branch MDEV-9804</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 'origin/10.2' into bb-10.2-ext</title>
<updated>2017-05-05T12:12:54+00:00</updated>
<author>
<name>Alexander Barkov</name>
<email>bar@mariadb.org</email>
</author>
<published>2017-05-05T12:12:54+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=ac53b49b1be807f588aebd83883ec93b764f5d54'/>
<id>ac53b49b1be807f588aebd83883ec93b764f5d54</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixed the bug mdev-11990.</title>
<updated>2017-05-03T20:50:35+00:00</updated>
<author>
<name>Igor Babaev</name>
<email>igor@askmonty.org</email>
</author>
<published>2017-05-03T20:49:43+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=ce8ee7d90b4f7dd784e1d7587093e671b35303f0'/>
<id>ce8ee7d90b4f7dd784e1d7587093e671b35303f0</id>
<content type='text'>
The usage of windows functions when all tables were optimized away
by min/max optimization were not supported. As result a result,
the queries that used window functions with min/max aggregation
over the whole table returned wrong result sets.
The patch fixed this problem.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The usage of windows functions when all tables were optimized away
by min/max optimization were not supported. As result a result,
the queries that used window functions with min/max aggregation
over the whole table returned wrong result sets.
The patch fixed this problem.
</pre>
</div>
</content>
</entry>
<entry>
<title>Changing field::field_name and Item::name to LEX_CSTRING</title>
<updated>2017-04-23T19:35:46+00:00</updated>
<author>
<name>Monty</name>
<email>monty@mariadb.org</email>
</author>
<published>2017-04-23T16:39:57+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=5a759d31f766087d5e135e1d3d3d987693bc9b88'/>
<id>5a759d31f766087d5e135e1d3d3d987693bc9b88</id>
<content type='text'>
Benefits of this patch:
- Removed a lot of calls to strlen(), especially for field_string
- Strings generated by parser are now const strings, less chance of
  accidently changing a string
- Removed a lot of calls with LEX_STRING as parameter (changed to pointer)
- More uniform code
- Item::name_length was not kept up to date. Now fixed
- Several bugs found and fixed (Access to null pointers,
  access of freed memory, wrong arguments to printf like functions)
- Removed a lot of casts from (const char*) to (char*)

Changes:
- This caused some ABI changes
  - lex_string_set now uses LEX_CSTRING
  - Some fucntions are now taking const char* instead of char*
- Create_field::change and after changed to LEX_CSTRING
- handler::connect_string, comment and engine_name() changed to LEX_CSTRING
- Checked printf() related calls to find bugs. Found and fixed several
  errors in old code.
- A lot of changes from LEX_STRING to LEX_CSTRING, especially related to
  parsing and events.
- Some changes from LEX_STRING and LEX_STRING &amp; to LEX_CSTRING*
- Some changes for char* to const char*
- Added printf argument checking for my_snprintf()
- Introduced null_clex_str, star_clex_string, temp_lex_str to simplify
  code
- Added item_empty_name and item_used_name to be able to distingush between
  items that was given an empty name and items that was not given a name
  This is used in sql_yacc.yy to know when to give an item a name.
- select table_name."*' is not anymore same as table_name.*
- removed not used function Item::rename()
- Added comparision of item-&gt;name_length before some calls to
  my_strcasecmp() to speed up comparison
- Moved Item_sp_variable::make_field() from item.h to item.cc
- Some minimal code changes to avoid copying to const char *
- Fixed wrong error message in wsrep_mysql_parse()
- Fixed wrong code in find_field_in_natural_join() where real_item() was
  set when it shouldn't
- ER_ERROR_ON_RENAME was used with extra arguments.
- Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already
  give the error.

TODO:
- Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c
- Change code to not modify LEX_CSTRING for database name
  (as part of lower_case_table_names)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Benefits of this patch:
- Removed a lot of calls to strlen(), especially for field_string
- Strings generated by parser are now const strings, less chance of
  accidently changing a string
- Removed a lot of calls with LEX_STRING as parameter (changed to pointer)
- More uniform code
- Item::name_length was not kept up to date. Now fixed
- Several bugs found and fixed (Access to null pointers,
  access of freed memory, wrong arguments to printf like functions)
- Removed a lot of casts from (const char*) to (char*)

Changes:
- This caused some ABI changes
  - lex_string_set now uses LEX_CSTRING
  - Some fucntions are now taking const char* instead of char*
- Create_field::change and after changed to LEX_CSTRING
- handler::connect_string, comment and engine_name() changed to LEX_CSTRING
- Checked printf() related calls to find bugs. Found and fixed several
  errors in old code.
- A lot of changes from LEX_STRING to LEX_CSTRING, especially related to
  parsing and events.
- Some changes from LEX_STRING and LEX_STRING &amp; to LEX_CSTRING*
- Some changes for char* to const char*
- Added printf argument checking for my_snprintf()
- Introduced null_clex_str, star_clex_string, temp_lex_str to simplify
  code
- Added item_empty_name and item_used_name to be able to distingush between
  items that was given an empty name and items that was not given a name
  This is used in sql_yacc.yy to know when to give an item a name.
- select table_name."*' is not anymore same as table_name.*
- removed not used function Item::rename()
- Added comparision of item-&gt;name_length before some calls to
  my_strcasecmp() to speed up comparison
- Moved Item_sp_variable::make_field() from item.h to item.cc
- Some minimal code changes to avoid copying to const char *
- Fixed wrong error message in wsrep_mysql_parse()
- Fixed wrong code in find_field_in_natural_join() where real_item() was
  set when it shouldn't
- ER_ERROR_ON_RENAME was used with extra arguments.
- Removed some (wrong) ER_OUTOFMEMORY, as alloc_root will already
  give the error.

TODO:
- Check possible unsafe casts in plugin/auth_examples/qa_auth_interface.c
- Change code to not modify LEX_CSTRING for database name
  (as part of lower_case_table_names)
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-11868: min ( distinct ) over ( ) returns wrong value</title>
<updated>2017-02-15T12:09:27+00:00</updated>
<author>
<name>Vicențiu Ciorbaru</name>
<email>vicentiu@mariadb.org</email>
</author>
<published>2017-02-15T06:43:39+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=d06a44e027070a65c5cfc0079aa977e73fa12d0e'/>
<id>d06a44e027070a65c5cfc0079aa977e73fa12d0e</id>
<content type='text'>
The bug was not visible in current HEAD. Introduced test case to catch
regressions. Also improve error messages regarding distinct usage in
window functions.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The bug was not visible in current HEAD. Introduced test case to catch
regressions. Also improve error messages regarding distinct usage in
window functions.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-10092: Server crashes in in ha_heap::rnd_pos / Table_read_cursor::get_next</title>
<updated>2017-02-15T12:09:27+00:00</updated>
<author>
<name>Vicențiu Ciorbaru</name>
<email>vicentiu@mariadb.org</email>
</author>
<published>2017-02-14T16:31:30+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=d4746422547f1901831f9c891a3600275daf6534'/>
<id>d4746422547f1901831f9c891a3600275daf6534</id>
<content type='text'>
The bug was caused by several issues.
2 problems in seek_io_cache. Due to wrong offsets used, we would end up
seeking way too much (first change), or over the intended seek point
(second change). Fixing it requires correctly detecting available data
in buffer (first change), and not using "IO_SIZE alligned" reads. The
second is needed because _my_b_cache_read adjusts the pos_in_file itself
based on read_pos and read_end. Pretending buffer is empty when we want
to force a read will aleviate this problem.

Secondly, the big-table cursors didn't repect the interface definitions
of always returning the rownumber that Table_read_cursor::fetch() would activate.

At the same time, next(), prev() and move_to() should not perform any
row activation.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The bug was caused by several issues.
2 problems in seek_io_cache. Due to wrong offsets used, we would end up
seeking way too much (first change), or over the intended seek point
(second change). Fixing it requires correctly detecting available data
in buffer (first change), and not using "IO_SIZE alligned" reads. The
second is needed because _my_b_cache_read adjusts the pos_in_file itself
based on read_pos and read_end. Pretending buffer is empty when we want
to force a read will aleviate this problem.

Secondly, the big-table cursors didn't repect the interface definitions
of always returning the rownumber that Table_read_cursor::fetch() would activate.

At the same time, next(), prev() and move_to() should not perform any
row activation.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-10859: Wrong result of aggregate window function in query with HAVING and no ORDER BY</title>
<updated>2017-02-15T12:09:27+00:00</updated>
<author>
<name>Vicențiu Ciorbaru</name>
<email>vicentiu@mariadb.org</email>
</author>
<published>2017-02-14T12:02:29+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=9fe9fb68acd763ad3908c03d82d4de577d6f0c21'/>
<id>9fe9fb68acd763ad3908c03d82d4de577d6f0c21</id>
<content type='text'>
Window functions need to be computed after applying the HAVING clause.
An optimization that we have for regular, non-window function, cases is
to apply having only during sending of the rows to the client. This
allows rows that should be filtered from the temporary table used to
store aggregation results to be stored there.

This behaviour is undesireable for window functions, as we have to
compute window functions on the result-set after HAVING is applied.
Storing extra rows in the table leads to wrong values as the frame
bounds might capture those -to be filtered afterwards- rows.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Window functions need to be computed after applying the HAVING clause.
An optimization that we have for regular, non-window function, cases is
to apply having only during sending of the rows to the client. This
allows rows that should be filtered from the temporary table used to
store aggregation results to be stored there.

This behaviour is undesireable for window functions, as we have to
compute window functions on the result-set after HAVING is applied.
Storing extra rows in the table leads to wrong values as the frame
bounds might capture those -to be filtered afterwards- rows.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-11746: Wrong result upon using FIRST_VALUE with a window frame</title>
<updated>2017-02-14T05:46:58+00:00</updated>
<author>
<name>Vicențiu Ciorbaru</name>
<email>vicentiu@mariadb.org</email>
</author>
<published>2017-02-07T15:16:20+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=5bf338435aae358b2661ce2dc04b5a70d3d0c783'/>
<id>5bf338435aae358b2661ce2dc04b5a70d3d0c783</id>
<content type='text'>
The same approach is needed for LAST_VALUE, otherwise the LAST_VALUE sum
functions are not cleared correctly. Now LAST_VALUE behaves as NTH_VALUE
with 0 offset, only that the frame that it is examining is the bottom bound,
not the top bound.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The same approach is needed for LAST_VALUE, otherwise the LAST_VALUE sum
functions are not cleared correctly. Now LAST_VALUE behaves as NTH_VALUE
with 0 offset, only that the frame that it is examining is the bottom bound,
not the top bound.
</pre>
</div>
</content>
</entry>
<entry>
<title>MDEV-11746: Wrong result upon using FIRST_VALUE with a window frame</title>
<updated>2017-02-14T05:46:58+00:00</updated>
<author>
<name>Vicențiu Ciorbaru</name>
<email>vicentiu@mariadb.org</email>
</author>
<published>2017-02-07T14:49:41+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=57341852b5b1e40b1f92e248d84f95de988022c0'/>
<id>57341852b5b1e40b1f92e248d84f95de988022c0</id>
<content type='text'>
Reimplement FIRST_VALUE to act as NTH_VALUE with 0 offset. The previous
implementation was flawed when the window frame would remove values.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Reimplement FIRST_VALUE to act as NTH_VALUE with 0 offset. The previous
implementation was flawed when the window frame would remove values.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fixed bug mdev-11138.</title>
<updated>2017-02-05T05:51:40+00:00</updated>
<author>
<name>Igor Babaev</name>
<email>igor@askmonty.org</email>
</author>
<published>2017-02-05T05:51:40+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=e51b015fc354ec40c8430d4f4ea6346bc9a8e07b'/>
<id>e51b015fc354ec40c8430d4f4ea6346bc9a8e07b</id>
<content type='text'>
Supported usage of expressions with window functions
in SELECTs without tables.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Supported usage of expressions with window functions
in SELECTs without tables.
</pre>
</div>
</content>
</entry>
<entry>
<title>Post-review addition to the fix for mdev-10868.</title>
<updated>2016-10-01T00:40:42+00:00</updated>
<author>
<name>Igor Babaev</name>
<email>igor@askmonty.org</email>
</author>
<published>2016-09-30T20:13:18+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/mariadb-git.git/commit/?id=6681a4998e6c05f6350f9160012a6b6ef84ff513'/>
<id>6681a4998e6c05f6350f9160012a6b6ef84ff513</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
