summaryrefslogtreecommitdiff
path: root/sql/sp_head.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.3 into 10.4Marko Mäkelä2020-12-011-4/+4
|\
| * Merge 10.2 into 10.3Marko Mäkelä2020-12-011-4/+4
| |\
| | * MDEV 15532 Assertion `!log->same_pk' failed in row_log_table_apply_deleteMonty2020-11-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reason for the failure is that thd->mdl_context.release_transactional_locks() was called after commit & rollback even in cases where the current transaction is still active. For 10.2, 10.3 and 10.4 the fix is simple: - Replace all calls to thd->mdl_context.release_transactional_locks() with thd->release_transactional_locks(). The thd function will only call the mdl_context function if there are no active transactional locks. In 10.6 we will better fix where we will change the return value for some trans_xxx() functions to indicate if transaction did close the transaction or not. This will avoid the need of the indirect call. Other things: - trans_xa_commit() and trans_xa_rollback() will automatically call release_transactional_locks() if the transaction is closed. - We can't do that for the other functions as the caller of many of these are doing additional work (like close_thread_tables) before calling release_transactional_locks(). - Added missing abort_result_set() and missing DBUG_RETURN in select_create::send_eof() - Fixed wrong indentation in injector::transaction::commit()
* | | Merge 10.3 into 10.4Marko Mäkelä2020-06-061-0/+4
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2020-06-061-0/+93
| |\ \ | | |/
| | * MDEV-22042 Server crash in Item_field::print on ANALYZE FORMAT=JSONIgor Babaev2020-06-051-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When processing a query with a recursive CTE a temporary table is used for each recursive reference of the CTE. As any temporary table it uses its own mem-root for table definition structures. Due to specifics of the current implementation of ANALYZE stmt command this mem-root can be freed only at the very of query processing. Such deallocation of mem-root memory happens in close_thread_tables(). The function looks through the list of the tmp tables rec_tables attached to the THD of the query and frees corresponding mem-roots. If the query uses a stored function then such list is created for each query of the function. When a new rec_list has to be created the old one has to be saved and then restored at the proper moment. The bug occurred because only one rec_list for the query containing CTE was created. As a result close_thread_tables() freed tmp mem-roots used for rec_tables prematurely destroying some data needed for the output produced by the ANALYZE command.
| | * Merge 10.1 into 10.2Julius Goryavsky2020-06-051-0/+89
| | |\
| | | * MDEV-22763 backporting MDEV-20225 fix into 10.1sjaakola2020-06-031-0/+89
| | | | | | | | | | | | | | | | | | | | | | | | Backported the support for aborting and replaying stored procedure and fix for trigger key assigments from 10.4 version. Backported also two mtr tests: wsrep_sp_bf_abort and MDEV-20225
* | | | Merge 10.3 into 10.4Marko Mäkelä2020-05-161-1/+1
|\ \ \ \ | |/ / /
| * | | MDEV-18100: User defined aggregate functions not working correctly when the ↵Varun Gupta2020-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | schema is changed The issue here was that when the schema was changed the value for the THD::server_status is ored with SERVER_SESSION_STATE_CHANGED. For custom aggregate functions, currently we check if the server_status is equal to SERVER_STATUS_LAST_ROW_SENT then we should terminate the execution of the custom aggregate function as there are no more rows to fetch. So the check should be that if the server status has the bit set for SERVER_STATUS_LAST_ROW_SENT then we should terminate the execution of the custom aggregate function.
* | | | Merge 10.3 into 10.4Marko Mäkelä2020-01-201-37/+52
|\ \ \ \ | |/ / / | | | | | | | | | | | | The MDEV-17062 fix in commit c4195305b2a8431f39a4c75cc1c66ba43685f7a0 was omitted.
| * | | Fix another trivial merge errorSergei Petrunia2020-01-191-2/+2
| | | |
| * | | Merge branch '10.2' into 10.3Sergei Petrunia2020-01-171-3/+9
| |\ \ \ | | |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | # Conflicts: # mysql-test/suite/galera/r/MW-388.result # mysql-test/suite/galera/t/MW-388.test # mysql-test/suite/innodb/r/truncate_inject.result # mysql-test/suite/innodb/t/truncate_inject.test # mysql-test/suite/rpl/r/rpl_stop_slave.result # mysql-test/suite/rpl/t/rpl_stop_slave.test # sql/sp_head.cc # sql/sp_head.h # sql/sql_lex.cc # sql/sql_yacc.yy # storage/xtradb/buf/buf0dblwr.cc
| | * | Merge branch '10.1' into 10.2Sergei Petrunia2020-01-171-36/+27
| | |\ \ | | | |/ | | | | | | | | | | | | | | | | | | | | # Conflicts: # sql/sp_head.cc # sql/sql_select.cc # sql/sql_trigger.cc
| | | * MDEV-21341: Fix UBSAN failures: Issue SixSergei Petrunia2020-01-141-35/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
| * | | MDEV-21341: Fix UBSAN failures: Issue Sixbb-10.3-mdev21341-issueSixSergei Petrunia2020-01-121-34/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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.
* | | | Merge 10.3 into 10.4Marko Mäkelä2019-12-131-2/+4
|\ \ \ \ | |/ / / | | | | | | | | | | | | We disable the MDEV-21189 test galera.galera_partition because it times out.
| * | | MDEV-20667 Server crash on pop_cursorAlexander Barkov2019-12-121-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When backpatching a forward GOTO label, the old code erroneously used CURSOR/HANDLER difference between context frames "c" and "a" to tune a cpop/hpop command. So the cpop/hpop command later tried to pop all cursors/handlers declared between "a" and "c", but those between "b" and "c" were not cpushed/hpoped yet during the execution of "GOTO x". Fixing the code to use the difference between frames "b" and "a" only. BEGIN -- a ... GOTO x; -- b ... <<x>> -- c ... END -- d
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-12-091-5/+1
|\ \ \ \ | |/ / /
| * | | MDEV-18929 2nd execution of SP does not detect ER_VERS_NOT_VERSIONEDAleksey Midenkov2019-12-041-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Related to 87731177 and Bug#47649. Don't set Query_arena::STMT_EXECUTED for any error code. skip_setup_conds() depends on STMT_INITIALIZED_FOR_SP, but sp_lex_keeper::reset_lex_and_exec_core() sets it to STMT_EXECUTED on ER_TABLE_NOT_LOCKED_FOR_WRITE. There are other error codes that can break skip_setup_conds() (ER_IT_IS_A_VIEW, ER_NON_UPDATABLE_TABLE, etc).
* | | | Merge 10.3 into 10.4Marko Mäkelä2019-11-011-1/+5
|\ \ \ \ | |/ / /
| * | | MDEV-20074: Lost connection on update triggerOleksandr Byelkin2019-10-171-1/+5
| | | | | | | | | | | | | | | | | | | | Instead of checking lex->sql_command which does not corect in case of triggers mark tables for insert.
* | | | MDEV-20225 BF aborting SP execution (#1394)seppo2019-10-011-43/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * MDEV-20225 BF aborting SP execution When stored procedure execution was chosen as victim for a BF abort, the old implemnetationn called for rollback immediately when execution was inside SP isntruction. Technically this happened in wsrep_after_statement() call, which identified the need for a rollback. The problem was that MariaDB does not accept rollback (nor commit) inside sub statement, there are several asserts about it, checking for THD::in_sub_stmt. This patch contains a fix, which skips calling wsrep_after_statement() for SP execution, which is marked as BF must abort. Instead, we return error code to upper level, where rollback will eventually happen, ouside of SP execution. Also, appending the affected trigger table (dropped or created) in the populated key set for the write set, which prevents parallel applying of other transactions working on the same table. * MDEV-20225 BF aborting SP execution, second patch First PR missed 4 commits, which are now squashed in this patch: - Added galera_sp_bf_abort test. A MTR test case which will reproduce BF-BF conflict if all keys corresponding to affected tables are not assigned for DROP TRIGGER. - Fixed incorrect use of sync pointsin MDEV-20225 - Added condition for SQLCOM_DROP_TRIGGER in wsrep_can_run_in_toi() to make it replicate. * MDEV-20225 BF aborting SP execution, third patch The galera_trigger.test caused a situation, where SP invocation caused a trigger to fire, and the trigger executed as sub statement SP, and was BF aborted by applier. because of wsrep_after_statement() was called for the sub-statement level, it ended up in exeuting rollback and asserted there. Thus fix will catch sub-statement level SP execution, and avoids calling wsrep_after_statement()
* | | | Merge 10.3 into 10.4Marko Mäkelä2019-07-251-1/+1
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Eugene Kosov2019-07-161-1/+1
| |\ \ \ | | |/ /
| | * | Merge 10.1 into 10.2Eugene Kosov2019-07-091-1/+1
| | |\ \ | | | |/
| | | * MDEV-17963: Assertion `field_pos < field_count' failed in ↵Varun Gupta2019-07-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Protocol_text::store, Assertion `field_handlers == 0 || field_pos < field_count' The problem was that sp_head::MULTI_RESULTS was not set correctly for ANALYZE statement with SELECT ... INTO variable. This is a follow up fix for MDEV-7023
* | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-2/+2
|\ \ \ \ | |/ / /
| * | | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ \ | | |/ /
| | * | Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\ \ | | | |/
| | | * Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |\
| | | | * Update FSF AddressVicențiu Ciorbaru2019-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | * Update wrong zip-code
| | | | * MDEV-18507 can't update temporary table when joined with table with triggers ↵Sergei Golubchik2019-04-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | on read-only triggers are opened and tables used in triggers are prelocked in open_tables(). But multi-update can detect what tables will actually be updated only later, after all main tables are opened. Meaning, if a table is used in multi-update, but is not actually updated, its on-update treggers will be opened and tables will be prelocked, even if it's unnecessary. This can cause more tables to be write-locked than needed, causing read_only errors, privilege errors and lock waits. Fix: don't open/prelock triggers unless table->updating is true. In multi-update after setting table->updating=true, do a second open_tables() for newly added tables, if any.
| * | | | Merge branch '10.2' into 10.3Oleksandr Byelkin2019-05-121-1/+1
| |\ \ \ \ | | |/ / /
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-04-251-1/+2
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | In is_eits_usable(), we disable an assertion that fails due to MDEV-19334.
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-04-251-1/+2
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-04-251-1/+2
| | |\ \ \ | | | |/ /
| | | * | Fixing -Werror=format-overflow errors (found by gcc-8.3.1)Alexander Barkov2019-04-221-1/+1
| | | | |
| | | * | MDEV-17610 Unexpected connection abort after certain operations fromVladislav Vaintroub2019-04-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | within stored procedure Always set SERVER_MORE_RESULTS_EXIST when executing stored procedure. statements If statements produce a result, EOF packet needs this flag (SP ends with an OK packet). IF statetement does not produce a result, affected rows count are part of the final OK packet.
* | | | | Fixed wsrep replaying for stored procedures (#1256)mariadb-10.4.4Teemu Ollakka2019-04-061-24/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Changed replaying to always allocate a separate THD object for applying log events. This is to avoid tampering original THD state during replay process. - Return success from sp_instr_stmt::exec_core() if replaying succeeds. - Do not push warnings/errors into diagnostics area if the transaction must be replayed. This is to avoid reporting transient errors to the client. Added two tests galera_sp_bf_abort, galera_sp_insert_parallel. Wsrep-lib position updated.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-04-021-1/+2
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.2' into 10.3Sergei Golubchik2019-03-291-0/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge branch '10.1' into 10.2Sergei Golubchik2019-03-291-0/+1
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.1Sergei Golubchik2019-03-271-0/+1
| | | |\ \ | | | | |/
| | | | * MDEV-14784: Slave crashes in show_status_array upon running a trigger withSujatha Sivakumar2019-03-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | select from I_S Problem: ======== When applier thread tries to access 'variable_name' of INFORMATION_SCHEMA.SESSION_VARIABLES table through triggers, it results in an abnormal exit of slave server. Analysis: ======== At the time of replication of stored routines and triggers, their associated security context will be sent by the master. The applier thread on the slave server will use this information to set the required security context for the execution of stored routines and triggers. This is achieved as follows. ->The stored routine object has a member named 'm_security_ctx' which holds the security context received from master. ->The applier thread's security_ctx is stored into a 'backup' object. ->Set the applier thread's security_ctx to 'm_security_ctx'. ->Upon the completion of stored routine execution restore the original security context of applier thread from the backup. During the above process the 'm_security_ctx' object is not initialized properly. Hence the 'external_user' of 'm_security_ctx' has invalid value for this variable and accessing this variable results in abnormal exit of server. Fix: === Invoke the Security_context::init() call from the constructor of stored routine so that 'm_security_ctx' gets initialized properly.
| | | * | Merge branch '11.0' into 10.1Oleksandr Byelkin2018-09-061-27/+6
| | | |\ \
| | | | * | extend prelocking to FK-accessed tablesSergei Golubchik2018-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Backport of f1362910980
| | | | * | cleanup: sp_head::add_used_tables_to_table_list()Sergei Golubchik2018-09-041-27/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use TABLE::init_one_table(), don't duplicate it. Put additional initializations into TABLE::init_one_table_for_prelocking() Backport of f1362910980
* | | | | | MDEV-18837 Fixed stored procedure wsrep error handling and MW-388Teemu Ollakka2019-03-111-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed sync points in MW-388 and fixed SP wsrep error handling to avoid propagating wsrep errors via client-server protocol response.
* | | | | | MDEV-18813 PROCEDURE and anonymous blocks silently ignore FETCH GROUP NEXT ROWAlexander Barkov2019-03-071-2/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Part#2 (final): rewritting the code to pass the correct enum_sp_aggregate_type to the sp_head constructor, so sp_head never changes its aggregation type later on. The grammar has been simplified and defragmented. This allowed to check aggregate specific instructions right after a routine body has been scanned, by calling new LEX methods: sp_body_finalize_{procedure|function|trigger|event}() Moving some C++ code from *.yy to a few new helper methods in LEX.