summaryrefslogtreecommitdiff
path: root/sql/sql_lex.h
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '10.6' into 10.7Oleksandr Byelkin2022-10-041-1/+1
|\
| * Merge branch '10.5' into 10.6Sergei Golubchik2022-10-021-1/+1
| |\
| | * Merge branch '10.4' into 10.5Sergei Golubchik2022-10-021-1/+1
| | |\
| | | * Merge branch '10.3' into 10.4Sergei Golubchik2022-10-011-1/+1
| | | |\
| | | | * MDEV-29022 add_slave destroy child list and has dead codeOleksandr Byelkin2022-09-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Nowdays subquery in a UNION's ORDER BY placed correctly in fake select, the only problem was incorrect Name_resolution_contect is fixed by this patch in parsing, so we do not need scanning/reseting of ORDER BY of a union.
* | | | | Merge 10.6 into 10.7Marko Mäkelä2022-08-301-0/+6
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2022-08-301-0/+6
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2022-08-301-0/+6
| | |\ \ \ | | | |/ /
| | | * | MDEV-18873 Server crashes in Compare_identifiers::operator or in ↵tmokmss2022-08-261-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | my_strcasecmp_utf8 upon ADD PERIOD IF NOT EXISTS with empty name empty identifier specified as `` ends up with a NULL LEX_CSTRING::str in lexer. This is not considered correct in upper layers, for example in Compare_identifiers::operator(). Empty column name is usually avoided by a check_column_name() call while parsing, and period name matches the column name completely. Hence, this fix uses the mentioned call for verification, too.
* | | | | Merge 10.6 into 10.7Marko Mäkelä2022-07-271-11/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2022-07-271-11/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2022-07-271-11/+1
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.3' into 10.4Oleksandr Byelkin2022-07-271-10/+1
| | | |\ \ | | | | |/
| | | | * table_count was present twice in one class of LEX.Oleksandr Byelkin2022-07-141-10/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove table_count from Query_tables_list (not used, moved to MYSQL_LOCK). Rename table_count from LEX to avoid mixing it with other counters of tables.
| | | * | MDEV-22001: Server crashes in st_select_lex_unit::exclude_level upon ↵Dmitry Shulga2022-07-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | execution of SP Running some statements that use IN subqueries outside context of a regular query could result in server abnormal termination. The reason for failure is that internal structures SELECT_LEX/SELECT_LEX_UNIT created on behalf of parsed query were initialized incorrectly. Incorrect initialization of the structures SELECT_LEX/SELECT_LEX_UNIT was introduced by the commit de745ecf29721795710910a19bd0ea3389da804c (MDEV-11953: support of brackets in UNION/EXCEPT/INTERSECT operations) pushed into 10.4, that is the reason this bug report is not reproduced in 10.3. To fix the issue the method SLECTE_LEX::register_unit is used for proper initialization of the data structures SELECT_LEX/SELECT_LEX_UNIT. Additionally, the method SELECT_LEX::get_slave() was removed from the source code base since for those use cases where it is used it can be replaced by the method first_inner_unit().
* | | | | Merge branch '10.6' into 10.7mariadb-10.7.4Sergei Golubchik2022-05-181-7/+5
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.5' into 10.6mariadb-10.6.8Sergei Golubchik2022-05-181-7/+5
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.4' into 10.5mariadb-10.5.16Sergei Golubchik2022-05-181-7/+5
| | |\ \ \ | | | |/ /
| | | * | enable -Wenum-compare -Wenum-conversionSergei Golubchik2022-05-151-7/+5
| | | | | | | | | | | | | | | | | | | | | | | | | to make the all headers -std=c++20 clean for those, who need c++20 (some plugins)
* | | | | Merge branch '10.6' into 10.7Sergei Golubchik2022-05-111-0/+40
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.5' into 10.6Sergei Golubchik2022-05-101-0/+40
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.4' into 10.5Sergei Golubchik2022-05-091-0/+40
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.3' into 10.4Sergei Golubchik2022-05-081-0/+23
| | | |\ \ | | | | |/
| | | | * MDEV-20077 Warning on full history partition is delayed until next DML statementAleksey Midenkov2022-04-291-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Moved LIMIT warning from vers_set_hist_part() to new call vers_check_limit() at table unlock phase. At that point read_partitions bitmap is already pruned by DML code (see prune_partitions(), find_used_partitions()) so we have to set corresponding bits for working history partition. Also we don't do my_error(ME_WARNING|ME_ERROR_LOG), because at that point it doesn't update warnings number, so command reports 0 warnings (but warning list is still updated). Instead we do push_warning_printf() and sql_print_warning() separately. Under LOCK TABLES external_lock(F_UNLCK) is not executed. There is start_stmt(), but no corresponding "stop_stmt()". So for that mode we call vers_check_limit() directly from close_thread_tables(). Test result has been changed according to new LIMIT and warning printing algorithm. For convenience all LIMIT warnings are marked with "You see warning above ^". TODO MDEV-20345 fixed. Now vers_history_generating() contains fine-grained list of DML-commands that can generate history (and TODO mechanism worked well).
| | | * | MDEV-28448 Assertion failure for SELECT with subquery using ON expressionIgor Babaev2022-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch corrects the fix for MDEV-26412. Note that when parsing an ON expression the pointer to the current select is always in select_stack[select_stack_top - 1]. So the pointer to the outer select (if any) is in select_stack[select_stack_top - 2]. The query manifesting this bug is added to the test case of MDEV-26412.
| | | * | MDEV-26412 Server crash in Item_field::fix_outer_field for INSERT SELECTIgor Babaev2022-04-271-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IF an INSERT/REPLACE SELECT statement contained an ON expression in the top level select and this expression used a subquery with a column reference that could not be resolved then an attempt to resolve this reference as an outer reference caused a crash of the server. This happened because the outer context field in the Name_resolution_context structure was not set to NULL for such references. Rather it pointed to the first element in the select_stack. Note that starting from 10.4 we cannot use the SELECT_LEX::outer_select() method when parsing a SELECT construct. Approved by Oleksandr Byelkin <sanja@mariadb.com>
* | | | | Merge 10.6 into 10.7Marko Mäkelä2022-03-301-0/+9
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2022-03-291-0/+9
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2022-03-291-1/+10
| | |\ \ \ | | | |/ /
| | | * | Merge 10.3 into 10.4Marko Mäkelä2022-03-291-0/+8
| | | |\ \ | | | | |/
| | | | * MDEV-19804 sql_mode=ORACLE: call procedure in packagesAlexander Barkov2022-03-251-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding support for the fully qualified package procedure calls: BEGIN CALL db.pkg.proc(args); -- SQL/PSM call style db.pkg.proc(args); -- PL/SQL call style END;
| | | | * MDEV-28166 sql_mode=ORACLE: fully qualified package function calls do not ↵Alexander Barkov2022-03-251-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | work: db.pkg.func() Also fixes MDEV-19328 sql_mode=ORACLE: Package function in VIEW
* | | | | Merge 10.6 into 10.7Marko Mäkelä2022-03-111-1/+6
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.5 into 10.6Marko Mäkelä2022-03-111-1/+6
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.4 into 10.5Marko Mäkelä2022-03-111-0/+5
| | |\ \ \ | | | |/ /
| | | * | Merge 10.3 into 10.4Marko Mäkelä2022-03-111-0/+5
| | | |\ \ | | | | |/
| | | | * MDEV-19577 Replication does not work with innodb_autoinc_lock_mode=2Vlad Lesin2022-03-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first step for deprecating innodb_autoinc_lock_mode(see MDEV-27844) is: - to switch statement binlog format to ROW if binlog format is MIXED and the statement changes autoincremented fields - issue warnings if innodb_autoinc_lock_mode == 2 and binlog format is STATEMENT
* | | | | Merge branch '10.6' into 10.7Oleksandr Byelkin2022-02-041-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.5' into 10.6Oleksandr Byelkin2022-02-031-1/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.4' into 10.5Oleksandr Byelkin2022-02-011-1/+1
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.3' into 10.4Oleksandr Byelkin2022-01-301-1/+1
| | | |\ \ | | | | |/
| | | | * Merge branch '10.2' into 10.3mariadb-10.3.33Oleksandr Byelkin2022-01-291-1/+1
| | | | |\
| | | | | * MDEV-25460: Assertion `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())'Rucha Deodhar2021-12-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | failed in Diagnostics_area::set_ok_status in my_ok from mysql_sql_stmt_prepare Analysis: Before PREPARE is executed, binlog_format is STATEMENT. This PREPARE had SET STATEMENT which sets binlog_format to ROW. Now after PREPARE is done we reset the binlog_format (back to STATEMENT). But we have temporary table, it doesn't let changing binlog_format=ROW to binlog_format=STATEMENT and gives error which goes unreported. This unreported error eventually causes assertion failure. Fix: Change return type for LEX::restore_set_statement_var() to bool and make it return error state.
| | | | | * MDEV-20411 Procedure containing CTE incorrectly stored in mysql.procIgor Babaev2021-06-251-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the first token of the body of a stored procedure was 'WITH' then the beginning of the body was determined incorrectly and that token was missing in the string representing the body of the SP in mysql.proc. As a resultnany call of such procedure failed as the string representing the body could not be parsed. The patch corrects the code of the functions get_tok_start() and get_cpp_tok_start() of the class Lex_input_stream to make them take into account look ahead tokens. The patch is needed only for 10.2 as this problem has neen resolved in 10.3+.
| | | | * | Merge 10.2 into 10.3Marko Mäkelä2021-05-241-1/+25
| | | | |\ \ | | | | | |/
| | | | | * MDEV-23886 Reusing CTE inside a function fails with table doesn't existIgor Babaev2021-05-211-1/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the code existed just before this patch binding of a table reference to the specification of the corresponding CTE happens in the function open_and_process_table(). If the table reference is not the first in the query the specification is cloned in the same way as the specification of a view is cloned for any reference of the view. This works fine for standalone queries, but does not work for stored procedures / functions for the following reason. When the first call of a stored procedure/ function SP is processed the body of SP is parsed. When a query of SP is parsed the info on each encountered table reference is put into a TABLE_LIST object linked into a global chain associated with the query. When parsing of the query is finished the basic info on the table references from this chain except table references to derived tables and information schema tables is put in one hash table associated with SP. When parsing of the body of SP is finished this hash table is used to construct TABLE_LIST objects for all table references mentioned in SP and link them into the list of such objects passed to a pre-locking process that calls open_and_process_table() for each table from the list. When a TABLE_LIST for a view is encountered the view is opened and its specification is parsed. For any table reference occurred in the specification a new TABLE_LIST object is created to be included into the list for pre-locking. After all objects in the pre-locking have been looked through the tables mentioned in the list are locked. Note that the objects referenced CTEs are just skipped here as it is impossible to resolve these references without any info on the context where they occur. Now the statements from the body of SP are executed one by one that. At the very beginning of the execution of a query the tables used in the query are opened and open_and_process_table() now is called for each table reference mentioned in the list of TABLE_LIST objects associated with the query that was built when the query was parsed. For each table reference first the reference is checked against CTEs definitions in whose scope it occurred. If such definition is found the reference is considered resolved and if this is not the first reference to the found CTE the the specification of the CTE is re-parsed and the result of the parsing is added to the parsing tree of the query as a sub-tree. If this sub-tree contains table references to other tables they are added to the list of TABLE_LIST objects associated with the query in order the referenced tables to be opened. When the procedure that opens the tables comes to the TABLE_LIST object created for a non-first reference to a CTE it discovers that the referenced table instance is not locked and reports an error. Thus processing non-first table references to a CTE similar to how references to view are processed does not work for queries used in stored procedures / functions. And the main problem is that the current pre-locking mechanism employed for stored procedures / functions does not allow to save the context in which a CTE reference occur. It's not trivial to save the info about the context where a CTE reference occurs while the resolution of the table reference cannot be done without this context and consequentially the specification for the table reference cannot be determined. This patch solves the above problem by moving resolution of all CTE references at the parsing stage. More exactly references to CTEs occurred in a query are resolved right after parsing of the query has finished. After resolution any CTE reference it is marked as a reference to to derived table. So it is excluded from the hash table created for pre-locking used base tables and view when the first call of a stored procedure / function is processed. This solution required recursive calls of the parser. The function THD::sql_parser() has been added specifically for recursive invocations of the parser.
* | | | | | MDEV-22166 CONVERT PARTITION: move out partition into a tableAleksey Midenkov2021-10-261-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Syntax for CONVERT keyword ALTER TABLE tbl_name [alter_option [, alter_option] ...] | [partition_options] partition_option: { ... | CONVERT PARTITION partition_name TO TABLE tbl_name } Examples: ALTER TABLE t1 CONVERT PARTITION p2 TO TABLE tp2; New ALTER_PARTITION_CONVERT_OUT command for fast_alter_partition_table() is done in alter_partition_convert_out() function which basically does ha_rename_table(). Partition to extract is marked with the same flag as dropped partition: PART_TO_BE_DROPPED. Note that we cannot have multiple partitioning commands in one ALTER. For DDL logging basically the principle is the same as for other fast_alter_partition_table() commands. The only difference is that it integrates late Atomic DDL functions and introduces additional phase of WFRM_BACKUP_ORIGINAL. That is required for binlog consistency because otherwise we could not revert back after WFRM_INSTALL_SHADOW is done. And before DDL log is complete if we crash or fail the altered table will be already new but binlog will miss that ALTER command. Note that this is different from all other atomic DDL in that it rolls back until the ddl_log_complete() is done even if everything was done fully before the crash. Test cases added to: parts.alter_table \ parts.partition_debug \ versioning.partition \ atomic.alter_partition
* | | | | | Removed CREATE/DROP TABLESPACE and related commandsMonty2021-09-141-7/+0
|/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - DISCARD/IMPORT TABLESPACE are the only tablespace commands left - TABLESPACE arguments for CREATE TABLE and ALTER ... ADD PARTITION are ignored. - Tablespace names are not shown anymore in .frm and not shown in information schema Other things - Removed end spaces from sql/CMakeList.txt
* | | | | Merge branch '10.5' into 10.6Oleksandr Byelkin2021-08-021-14/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.4' into 10.5Oleksandr Byelkin2021-07-311-14/+1
| |\ \ \ \ | | |/ / /