summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-23094: Multiple calls to a Stored Procedure from another Stored ↵bb-10.4-MDEV-23094Oleksandr Byelkin2020-08-311-2/+4
| | | | | | | | Procedure crashes server Added system-SELECT to IF/WHILE/REPET/FOR for correct subqueries connecting. Added control of system/usual selects for correct error detection.
* Merge 10.3 into 10.4Marko Mäkelä2020-08-101-1/+10
|\
| * Merge mariadb-10.3.24Marko Mäkelä2020-08-101-1/+2
| |\
| * | MDEV-22022 Various mangled SQL statements will crash 10.3 to 10.5 debug buildsAlexander Barkov2020-08-041-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Lex_input_stream::scan_ident_delimited() could go beyond the end of the input when a starting backtick (`) delimiter did not have a corresponding ending backtick. Fix: catch the case when yyGet() returns 0, which means either eof-of-query or straight 0x00 byte inside backticks, and make the parser fail on syntax error, displaying the left backtick as the syntax error place. In case of filename in a script like this: SET CHARACTER_SET_CLIENT=17; -- 17 is 'filename' SELECT doc.`Children`.0 FROM t1; the ending backtick was not recognized as such because my_charlen() returns 0 for a straight backtick (backticks must normally be encoded as @0060 in filename). The same fix works for 'filename': the execution skips the backtick and reaches the end of the query, then yyGet() returns 0. This fix is OK for now. But eventually 'filename' should either be disallowed as a parser character set, or fixed to handle encoded punctuation properly.
* | | Merge branch '10.3' into 10.4Oleksandr Byelkin2020-08-031-2/+35
|\ \ \ | | |/ | |/|
| * | Merge branch '10.2' into 10.3Oleksandr Byelkin2020-08-031-1/+2
| |\ \ | | |/ | |/|
| | * Merge branch '10.1' into 10.2Oleksandr Byelkin2020-08-021-1/+2
| | |\
| | | * MDEV-23221: A subquery causes crashSergei Petrunia2020-07-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix the crash: IN-to-EXISTS rewrite causes an error (and so JOIN::optimize() fails with an error, too), don't call update_used_tables(). Terminate the query execution instead. * Fix the cause of the error in the IN-to-EXISTS rewrite: don't do the rewrite if doing it will cause an error of this kind: This version of MariaDB doesn't yet support 'SUBQUERY in ROW in left expression of IN/ALL/ANY' * Fix another issue exposed by this testcase: JOIN::setup_subquery_caches() may be invoked before any select has saved its query plan, and will crash because none of the SELECTs has called create_explain_query_if_not_exists() to create the Explain Data Structure for this SELECT. TODO: When merging this to 10.2, remove the poorly-placed call to create_explain_query_if_not_exists made by fix for M_D_E_V-16153
| * | | MDEV-19632 Replication aborts with ER_SLAVE_CONVERSION_FAILED upon CREATE ↵Alexander Barkov2020-08-011-1/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... SELECT in ORACLE mode - Adding optional qualifiers to data types: CREATE TABLE t1 (a schema.DATE); Qualifiers now work only for three pre-defined schemas: mariadb_schema oracle_schema maxdb_schema These schemas are virtual (hard-coded) for now, but may turn into real databases on disk in the future. - mariadb_schema.TYPE now always resolves to a true MariaDB data type TYPE without sql_mode specific translations. - oracle_schema.DATE translates to MariaDB DATETIME. - maxdb_schema.TIMESTAMP translates to MariaDB DATETIME. - Fixing SHOW CREATE TABLE to use a qualifier for a data type TYPE if the current sql_mode translates TYPE to something else. The above changes fix the reported problem, so this script: SET sql_mode=ORACLE; CREATE TABLE t2 AS SELECT mariadb_date_column FROM t1; is now replicated as: SET sql_mode=ORACLE; CREATE TABLE t2 (mariadb_date_column mariadb_schema.DATE); and the slave can unambiguously treat DATE as the true MariaDB DATE without ORACLE specific translation to DATETIME. Similar, SET sql_mode=MAXDB; CREATE TABLE t2 AS SELECT mariadb_timestamp_column FROM t1; is now replicated as: SET sql_mode=MAXDB; CREATE TABLE t2 (mariadb_timestamp_column mariadb_schema.TIMESTAMP); so the slave treats TIMESTAMP as the true MariaDB TIMESTAMP without MAXDB specific translation to DATETIME.
* | | | fix obvious bugs hidden by current_select assigned to builtin selectOleksandr Byelkin2020-07-281-4/+5
| | | |
* | | | MDEV-21998: Server crashes in st_select_lex::add_table_to_list upon mix of ↵Oleksandr Byelkin2020-07-281-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | KILL and sequences Continue support the hack of current select equal builtin select if selects stack is empty even after subselects.
* | | | MDEV-21997 Server crashes in LEX::create_item_ident_sp upon use of unknown ↵Oleksandr Byelkin2020-07-221-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | identifier If there is no current_select and variable is not found among SP variables it can be only an error.
* | | | Merge 10.3 into 10.4Marko Mäkelä2020-07-151-1/+3
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2020-07-141-1/+3
| |\ \ \ | | |/ /
| | * | MDEV-22463: Element_type &Bounds_checked_array<Item *>::operator[](size_t) ↵Varun Gupta2020-07-131-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [Element_type = Item *]: Assertion `n < m_size' failed. Allocate space for fields inside the window function (arguments, PARTITION BY and ORDER BY clause) in the ref pointer array. All fields inside the window function are part of the temporary table that is required for the window function computation.
* | | | Merge 10.3 into 10.4Marko Mäkelä2020-05-051-5/+15
|\ \ \ \ | |/ / /
| * | | Merge branch '10.2' into 10.3Oleksandr Byelkin2020-05-041-5/+15
| |\ \ \ | | |/ /
| | * | Merge branch '10.1' into 10.2Oleksandr Byelkin2020-05-021-4/+14
| | |\ \ | | | |/
| | | * Merge branch '5.5' into 10.1Oleksandr Byelkin2020-04-301-4/+14
| | | |\
| | | | * Bug#28388217 - SERVER CAN FAIL WHILE REPLICATING CONDITIONAL COMMENTSMaheedhar PV2020-04-291-4/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Cause: In case of version based condtional comments, if the condition evaluates to false, it is converted to a regular comment for replication by replacing "!" by " ". Nested comment in a conditional comment is replicated as is. Nested comments are supported only in case of conditional comments and when a the comment on slave is no more a conditional comment, the statement execution fails on the slave. Fix: Convert the nested comment, start from "/*" to "(*" and comment end from "*/" to "*)" for replication. Change-Id: I1a8e385a267b2370529eade094f0258fa96886c0
| | * | | Merge branch '10.1' into 10.2Sergei Petrunia2020-01-171-2/+2
| | |\ \ \ | | | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # sql/sp_head.cc # sql/sql_select.cc # sql/sql_trigger.cc
| | | * | MDEV-21341: Fix UBSAN failures: Issue SixSergei Petrunia2020-01-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Variant #2 of the patch, which keeps the sp_head object inside the MEM_ROOT that sp_head object owns) (10.3 requires extra work due to sp_package, will commit a separate patch for it) sp_head::operator new() and operator delete() were dereferencing sp_head* pointers to memory that didn't hold a valid sp_head object (it was not created/already destroyed). This caused UBSan to crash when looking up type information. Fixed by providing static sp_head::create() and sp_head::destroy() methods.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2020-04-161-4/+6
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | In main.index_merge_myisam we remove the test that was added in commit a2d24def8cc42d27c72d833abfb39ef24a2b96ba because it duplicates the test case that was added in commit 5af12e463549e4bbc2ce6ab720d78937d5e5db4e.
| * | | | MDEV-21673 Calling stored procedure twice in the same session causes MariaDB ↵Igor Babaev2020-04-041-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | to crash This bug could happen only with a stored procedure containing queries with more than one reference to a CTE that used local variables / parameters. This bug was the result of an incomplete merge of the fix for the bug MDEV-17154. The merge covered usage of parameter markers occurred in a CTE that was referenced more than once, but missed coverage of local variables.
* | | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2020-03-111-0/+1
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-15724 - Possible crash in parserAleksey Midenkov2020-03-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Parser: uninitialized Lex->create_last_non_select_table under mysql_unpack_partition() fix. Tested with main, parts suites.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2020-01-201-5/+5
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | The MDEV-17062 fix in commit c4195305b2a8431f39a4c75cc1c66ba43685f7a0 was omitted.
| * | | | MDEV-21341: Fix UBSAN failures: Issue Sixbb-10.3-mdev21341-issueSixSergei Petrunia2020-01-121-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Variant #2 of the patch, which keeps the sp_head object inside the MEM_ROOT that sp_head object owns) (10.3 version of the fix, with handling for class sp_package) sp_head::operator new() and operator delete() were dereferencing sp_head* pointers to memory that didn't hold a valid sp_head object (it was not created/already destroyed). This caused UBSan to crash when looking up type information. Fixed by providing static sp_head::create() and sp_head::destroy() methods.
* | | | | MDEV-21184 Assertion `used_tables_cache == 0' failed in Item_func::fix_fieldsIgor Babaev2020-01-151-5/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with condition_pushdown_from_having This bug could manifest itself for queries with GROUP BY and HAVING clauses when the HAVING clause was a conjunctive condition that depended exclusively on grouping fields and at least one conjunct contained an equality of the form fld=sq where fld is a grouping field and sq is a constant subquery. In this case the optimizer tries to perform a pushdown of the HAVING condition into WHERE. To construct the pushable condition the optimizer first transforms all multiple equalities in HAVING into simple equalities. This has to be done for a proper processing of the pushed conditions in WHERE. The multiple equalities at all AND/OR levels must be converted to simple equalities because any multiple equality may refer to a multiple equality at the upper level. Before this patch the conversion was performed like this: multiple_equality(x,f1,...,fn) => x=f1 and ... and x=fn. When an equality item for x=fi was constructed both the items for x and fi were cloned. If x happened to be a constant subquery that could not be cloned the conversion failed. If the conversions of multiple equalities previously performed had succeeded then the whole condition became in an inconsistent state that could cause different failures. The solution provided by the patch is: 1. to use a different conversion rule if x is a constant multiple_equality(x,f1,...,fn) => f1=x and f2=f1 and ... and fn=f1 2. not to clone x if it's a constant. Such conversions cannot fail and besides the result of the conversion preserves the equivalence of f1,...,fn that can be used for other optimizations. This patch also made sure that expensive predicates are not pushed from HAVING to WHERE.
* | | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2020-01-031-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.2' into 10.3Oleksandr Byelkin2020-01-031-1/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.1' into 10.2Oleksandr Byelkin2020-01-031-1/+1
| | |\ \ \ | | | |/ /
| | | * | MDEV-19680:: Assertion `!table || (!table->read_set || ↵Varun Gupta2019-12-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | bitmap_is_set(table->read_set, field_index) || (!(ptr >= table->record[0] && ptr < table->record[0] + table->s->reclength)))' or alike failed upon SELECT with mix of functions from simple view Set read_set bitmap for view from the JOIN::all_fields list instead of JOIN::fields_list as split_sum_func would have added items to the all_fields list.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-11-011-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Remove \n from DBUG_PRINT statementsMichael Widenius2019-10-211-1/+1
| | | | |
* | | | | MDEV-19956: Do not dereference an uninitialized pointerMarko Mäkelä2019-10-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LEX::parsed_select_expr_cont(): Replace a condition with an assertion DBUG_ASSERT(!s2->next_select()), and always initialize sel1=s2, because all subsequent code paths will assign to sel1->first_nested. This was flagged by GCC reporting -Wmaybe-uninitialized for the statement last->link_neighbour(sel1).
* | | | | MDEV-19956 Queries with subqueries containing UNION are not parsedIgor Babaev2019-09-231-184/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Shift-Reduce conflicts prevented parsing some queries with subqueries that used set operations when the subqueries occurred in expressions or in IN predicands. The grammar rules for query expression were transformed in order to avoid these conflicts. New grammar rules employ an idea taken from MySQL 8.0.
* | | | | MDEV-20634 Report disallowed subquery errors as such (instead of parse error)Alexander Barkov2019-09-201-7/+8
| | | | |
* | | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-09-021-6/+2
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-18501 Partition pruning doesn't work for historical queries (fix)Aleksey Midenkov2019-09-011-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Pruning fix for SYSTEM_TIME INTERVAL partitioning. Allocating one more element in range_int_array for CURRENT partition is required for RANGE pruning to work correctly (get_partition_id_range_for_endpoint()).
| * | | | MDEV-18501 Partition pruning doesn't work for historical queries (refactoring)Aleksey Midenkov2019-09-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SYSTEM_TYPE partitioning: COLUMN properties removed. Partitioning is now pure RANGE based on UNIX_TIMESTAMP(row_end). DECIMAL type is now allowed as RANGE partitioning, we can partition by UNIX_TIMESTAMP() (but not for DATETIME which depends on local timezone of course).
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-08-311-0/+1
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-20425: Fix -Wimplicit-fallthroughMarko Mäkelä2019-08-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With --skip-debug-assert, DBUG_ASSERT(false) will allow execution to continue. Hence, we will need /* fall through */ after them. Some DBUG_ASSERT(0) were replaced by break; when the switch () statement was followed by DBUG_ASSERT(0).
* | | | | Fixes based on warnings from gcc/clang and valgrindMonty2019-08-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Initialize variables that could be used uninitialized - Added extra end space to DbugStringItemTypeValue to get rid of warnings from c_ptr() - Session_sysvars_tracker::update() accessed unitialized memory if called with NULL value. - get_schema_stat_record() accessed unitialized memory if HA_KEY_LONG_HASH was used - parse_vcol_defs() accessed random memory for tables without keys.
* | | | | MDEV-20224: main.derived crashes with ASAN with error use-after-poisonVarun Gupta2019-08-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Make sure that the references in the GROUP BY clause that need to be considered for pushdown from having to where are of Item_field objects
* | | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-07-281-3/+15
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.2' into 10.3Oleksandr Byelkin2019-07-261-3/+2
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.1' into 10.2Oleksandr Byelkin2019-07-261-3/+2
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.1Oleksandr Byelkin2019-07-251-3/+2
| | | |\ \ | | | | |/
| | | | * MDEV-19429: Wrong query result with EXISTS and LIMIT 0bb-5.5-MDEV-19429Oleksandr Byelkin2019-07-191-3/+2
| | | | | | | | | | | | | | | | | | | | Check EXISTS LIMIT before rewriting.