MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.
Find a file
Rex eb8053b377 MDEV-31995 Bogus error executing PS for query using CTE with renaming of columns
This commit addresses column naming issues with CTEs in the use of prepared
statements and stored procedures. Usage of either prepared statements or
procedures with Common Table Expressions and column renaming may be affected.

There are three related but different issues addressed here.

1) First execution issue. Consider the following

prepare s from "with cte (col1, col2) as (select a as c1, b as c2 from t
order by c1) select col1, col2 from cte";
execute s;

After parsing, items in the select are named (c1,c2), order by (and group by)
resolution is performed, then item names are set to (col1, col2).
When the statement is executed, context analysis is again performed, but
resolution of elements in the order by statement will not be able to find c1,
because it was renamed to col1 and remains this way.

The solution is to save the names of these items during context resolution
before they have been renamed. We can then reset item names back to those after
parsing so first execution can resolve items referred to in order and group by
clauses.

2) Second Execution Issue

When the derived table contains more than one select 'unioned' together we could
reasonably think that dealing with only items in the first select (which
determines names in the resultant table) would be sufficient.  This can lead to
a different problem.  Consider

prepare st from "with cte (c1,c2) as
  (select a as col1, sum(b) as col2 from t1 where a > 0 group by col1
    union select a as col3, sum(b) as col4 from t2 where b > 2 group by col3)
  select * from cte where c1=1";

When the optimizer (only run during the first execution) pushes the outside
condition "c1=1" into every select in the derived table union, it renames the
items to make the condition valid.  In this example, this leaves the first item
in the second select named 'c1'.  The second execution will now fail 'group by'
resolution.

Again, the solution is to save the names during context analysis, resetting
before subsequent resolution, but making sure that we save/reset the item
names in all the selects in this union.

3) Memory Leak

During parsing Item::set_name() is used to allocate memory in the statement
arena.  We cannot use this call during statement execution as this represents
a memory leak.  We directly set the item list names to those in the column list
of this CTE (also allocated during parsing).

Approved by Igor Babaev <igor@mariadb.com>
2023-10-30 16:47:18 +12:00
BUILD Merge 10.3 into 10.4 2022-12-13 11:37:33 +02:00
client MDEV-30664 mysqldump output is truncated on Windows 2023-10-10 14:04:48 +07:00
cmake MDEV-31605 cmake/stack_direction.c does not work correctly on clang 16 2023-09-19 10:14:03 +03:00
dbug Minimize unsafe C functions usage - replace strcat() and strcpy() (and strncat() and strncpy()) with custom safe_strcat() and safe_strcpy() functions 2023-01-20 15:18:52 +02:00
debian MDEV-31358: Update description for MariaDB debian/rpm packages 2023-07-03 17:45:58 +10:00
Docs Merge 10.3 into 10.4 2022-09-23 13:47:15 +03:00
extra MDEV-25734 mbstream breaks page compression on XFS 2023-10-17 14:32:05 +02:00
include MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB 2023-10-24 03:35:48 +04:00
libmariadb@ae565eea90 New CC v3.1 2023-10-23 14:10:13 +02:00
libmysqld MDEV-31461 mariadb SIGSEGV when built with -DCLIENT_PLUGIN_DIALOG=STATIC 2023-06-19 12:12:21 +02:00
libservices Merge branch '10.3' into 10.4 2019-05-19 20:55:37 +02:00
man Update innochecksum man page 2023-10-13 10:36:26 +11:00
mysql-test MDEV-31995 Bogus error executing PS for query using CTE with renaming of columns 2023-10-30 16:47:18 +12:00
mysys MDEV-30048 Prefix keys for CHAR work differently for MyISAM vs InnoDB 2023-10-24 03:35:48 +04:00
mysys_ssl Fix double definition of CRYPTO_cleanup_all_ex_data 2023-07-31 17:44:07 +02:00
pcre MDEV-31727: pcre stack size not functioning on clang-16 2023-07-21 20:21:37 +10:00
plugin fix SRPM builds on SLES 12.5, cmake 3.5.2 2023-10-12 08:49:58 +02:00
randgen/conf Group commit for maria engine. 2010-02-12 15:12:28 +02:00
scripts MDEV-29914: Fix maridab-upgrade when sql_safe_updates = on is set in my.cnf 2023-10-23 19:25:10 +11:00
sql MDEV-31995 Bogus error executing PS for query using CTE with renaming of columns 2023-10-30 16:47:18 +12:00
sql-bench Merge 10.2 into 10.3 2020-07-02 06:17:51 +03:00
sql-common Remove CLIENT_SSL_VERIFY_SERVER_CERT 2023-07-23 19:23:51 +02:00
storage MDEV-32578 row_merge_fts_doc_tokenize() handles parser plugin inconsistently 2023-10-27 13:13:49 +03:00
strings MDEV-26494 Fix buffer overflow of string lib on Arm64 2023-10-18 20:23:27 +11:00
support-files MDEV-30904 "rpm --setugids" breaks PAM authentication 2023-09-06 22:38:41 +02:00
tests MDEV-28561 Assertion failed: !pfs->m_idle || (state == PSI_SOCKET_STATE_ACTIVE) 2023-09-29 09:30:49 +02:00
unittest MDEV-30034 UNIQUE USING HASH accepts duplicate entries for tricky collations 2023-04-04 12:30:50 +04:00
vio Merge branch '10.3' into 10.4 2022-10-26 14:55:47 +02:00
win MDEV-31315 Add client_ed25519.dll to the list of plugins shipped with HeidiSQL 2023-09-13 11:17:27 +10:00
wsrep-lib@07af42c052 galera: wsrep-lib submodule update 2023-10-24 05:14:31 +02:00
zlib Merge branch 'zlib v1.3' into 10.4 2023-10-18 20:39:48 +02:00
.clang-format .clang-format - do not sort include files. 2019-12-03 22:22:23 +01:00
.gitattributes MDEV-27494 Rename .ic files to .inl 2022-01-17 16:41:51 +01:00
.gitignore Adding .ccls-cache/ to .gitignore 2023-06-02 11:46:14 +10:00
.gitlab-ci.yml All-green GitLab CI in 10.4 branch 2023-05-19 13:21:34 +01:00
.gitmodules Revert "ignore changes in submodules when committing everything" 2023-02-21 23:22:56 +01:00
appveyor.yml Fix typo in appveyor.yml 2022-07-04 19:24:58 +02:00
BUILD-CMAKE Minor spelling fixes in code comments, docs and output 2018-01-12 16:49:02 +02:00
CMakeLists.txt MDEV-14959: Control over memory allocated for SP/PS 2023-09-02 13:00:00 +07:00
config.h.cmake Merge 10.3 into 10.4 2022-10-11 15:18:49 +03:00
configure.cmake MDEV-31605 cmake/stack_direction.c does not work correctly on clang 16 2023-09-19 10:14:03 +03:00
CONTRIBUTING.md Add CONTRIBUTING file and modify README file about live QA regarding new contributors 2018-12-04 23:15:33 +04:00
COPYING Update FSF Address 2019-05-11 21:29:06 +03:00
CREDITS CREDITS: re-instate Tencent Cloud 2023-01-25 16:44:26 +11:00
INSTALL-SOURCE Update AskMonty and Atlassian references to MariaDB 2016-03-08 15:24:01 +02:00
INSTALL-WIN-SOURCE Update AskMonty and Atlassian references to MariaDB 2016-03-08 15:24:01 +02:00
KNOWN_BUGS.txt Changed some MySQL names in messages to MariaDB 2018-12-09 20:49:05 +02:00
README.md Merge 10.3 into 10.4 2021-06-21 12:38:25 +03:00
THIRDPARTY Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
VERSION bump the VERSION 2023-08-14 13:43:36 -04:00

Code status:

  • Appveyor CI status ci.appveyor.com

MariaDB: drop-in replacement for MySQL

MariaDB is designed as a drop-in replacement of MySQL(R) with more features, new storage engines, fewer bugs, and better performance.

MariaDB is brought to you by the MariaDB Foundation and the MariaDB corporation. Please read the CREDITS file for details about the MariaDB Foundation, and who is developing MariaDB.

MariaDB is developed by many of the original developers of MySQL who now work for the MariaDB Corporation, the MariaDB Foundation and by many people in the community.

MySQL, which is the base of MariaDB, is a product and trademark of Oracle Corporation, Inc. For a list of developers and other contributors, see the Credits appendix. You can also run 'SHOW authors' to get a list of active contributors.

A description of the MariaDB project and a manual can be found at:

https://mariadb.com/kb/en/

https://mariadb.com/kb/en/mariadb-vs-mysql-features/

https://mariadb.com/kb/en/mariadb-versus-mysql-compatibility/

https://mariadb.com/kb/en/library/new-and-old-releases/

https://mariadb.org/

As MariaDB is a full replacement of MySQL, the MySQL manual at http://dev.mysql.com/doc is generally applicable.

Help

More help is available from the Maria Discuss mailing list https://launchpad.net/~maria-discuss and the #maria IRC channel on Freenode.

Live QA for beginner contributors

MariaDB has a dedicated time each week when we answer new contributor questions live on Zulip and IRC. From 8:00 to 10:00 UTC on Mondays, and 10:00 to 12:00 UTC on Thursdays, anyone can ask any questions theyd like, and a live developer will be available to assist.

New contributors can ask questions any time, but we will provide immediate feedback during that interval.

Licensing


NOTE:

MariaDB is specifically available only under version 2 of the GNU General Public License (GPLv2). (I.e. Without the "any later version" clause.) This is inherited from MySQL. Please see the README file in the MySQL distribution for more information.

License information can be found in the COPYING file. Third party license information can be found in the THIRDPARTY file.


Bug Reports

Bug and/or error reports regarding MariaDB should be submitted at: https://jira.mariadb.org

For reporting security vulnerabilities see: https://mariadb.org/about/security-policy/

Bugs in the MySQL code can also be submitted at: https://bugs.mysql.com

The code for MariaDB, including all revision history, can be found at: https://github.com/MariaDB/server