summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\
| * 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-17362: SIGSEGV in JOIN::optimize_inner or Assertion `fixed == 0' failed ↵Oleksandr Byelkin2019-04-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | in Item_equal::fix_fields, server crashes after 2nd execution of PS Move reinitialisation of pushdown variables for every query, because it used now not only for derived tables.
* | | | | MDEV-19125 Change Send_field::type from enum_field_types to Type_handler*Alexander Barkov2019-04-021-0/+1
| | | | |
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-03-201-9/+22
|\ \ \ \ \ | |/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MDEV-17262 commit 26432e49d37a37d09b862bb49a021e44bdf4789c was skipped. In Galera 4, the implementation would seem to require changes to the streaming replication. In the tests archive.rnd_pos main.profiling, disable_ps_protocol for SHOW STATUS and SHOW PROFILE commands until MDEV-18974 has been fixed.
| * | | | Merge branch '10.2' into 10.3Sergei Golubchik2019-03-171-9/+22
| |\ \ \ \ | | |/ / /
| | * | | post-merge: --ps-protocol fixesSergei Golubchik2019-03-151-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Includes: MDEV-17302 Add support for ALTER USER command in prepared statement and MDEV-17673 main.cte_recursive fails in bb-10.4-ps branch in --ps Set correct SELECT_LEX linkage for recursive CTEs. Do not delegate this job to TABLE_LIST::set_as_with_table, because it is only run on prepare, while With_element::move_anchors_ahead is run both on prepare and execute (fix by Igor)
| | * | | Merge branch '10.1' into 10.2Sergei Golubchik2019-03-151-5/+36
| | |\ \ \ | | | |/ /
| | | * | MDEV-15945 --ps-protocol does not test some queriesSergei Golubchik2019-03-121-10/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make mysqltest to use --ps-protocol more use prepared statements for everything that server supports with the exception of CALL (for now). Fix discovered test failures and bugs. tests: * PROCESSLIST shows Execute state, not Query * SHOW STATUS increments status variables more than in text protocol * multi-statements should be avoided (see tests with a wrong delimiter) * performance_schema events have different names in --ps-protocol * --enable_prepare_warnings mysqltest.cc: * make sure run_query_stmt() doesn't crash if there's no active connection (in wait_until_connected_again.inc) * prepare all statements that server supports protocol.h * Protocol_discard::send_result_set_metadata() should not send anything to the client. sql_acl.cc: * extract the functionality of getting the user for SHOW GRANTS from check_show_access(), so that mysql_test_show_grants() could generate the correct column names in the prepare step sql_class.cc: * result->prepare() can fail, don't ignore its return value * use correct number of decimals for EXPLAIN columns sql_parse.cc: * discard profiling for SHOW PROFILE. In text protocol it's done in prepare_schema_table(), but in --ps it is called on prepare only, so nothing was discarding profiling during execute. * move the permission checking code for SHOW CREATE VIEW to mysqld_show_create_get_fields(), so that it would be called during prepare step too. * only set sel_result when it was created here and needs to be destroyed in the same block. Avoid destroying lex->result. * use the correct number of tables in check_show_access(). Saying "as many as possible" doesn't work when first_not_own_table isn't set yet. sql_prepare.cc: * use correct user name for SHOW GRANTS columns * don't ignore verbose flag for SHOW SLAVE STATUS * support preparing REVOKE ALL and ROLLBACK TO SAVEPOINT * don't ignore errors from thd->prepare_explain_fields() * use select_send result for sending ANALYZE and EXPLAIN, but don't overwrite lex->result, because it might be needed to issue execute-time errors (select_dumpvar - too many rows) sql_show.cc: * check grants for SHOW CREATE VIEW here, not in mysql_execute_command sql_view.cc: * use the correct function to check privileges. Old code was doing check_access() for thd->security_ctx, which is invoker's sctx, not definer's sctx. Hide various view related errors from the invoker. sql_yacc.yy: * initialize lex->select_lex for LOAD, otherwise it'll contain garbage data that happen to fail tests with views in --ps (but not otherwise).
| | | * | MDEV-11975: SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return ↵Oleksandr Byelkin2019-03-121-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | correct metadata info Added metadate info after prepare EXPLAIN/ANALYZE.
| | | * | MDEV-11966: Impossible to execute prepared ANALYZE SELECTOleksandr Byelkin2019-03-121-1/+1
| | | | | | | | | | | | | | | | | | | | Prepare os ANALYZE now respond as EXPLAIN.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-03-061-8/+14
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-03-051-8/+14
| |\ \ \ \ | | |/ / / | | | | | | | | | | | | | | | | | | | | FIXME: Properly resolve conflicts between MDEV-18883 and MDEV-7742/MDEV-8305, and record the correct result for main.log_slow
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-03-041-8/+14
| | |\ \ \ | | | |/ /
| | | * | Merge branch '10.0' into 10.1Oleksandr Byelkin2019-03-011-6/+15
| | | |\ \
| | | | * \ Merge branch '5.5' into 10.0Oleksandr Byelkin2019-02-281-6/+15
| | | | |\ \ | | | | | |/
| | | | | * MDEV-17055: Server crashes in find_order_in_list upon 2nd (3rd) execution of ↵Oleksandr Byelkin2019-02-281-6/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | SP with UPDATE 1. Always drop merged_for_insert flag on cleanup (there could be errors which prevent TABLE to be assigned) 2. Make more precise cleanup of select parts which was touched
| | | * | | MDEV-12060 Crash in EXECUTE IMMEDIATE with an expression returning a GRANT ↵Alexander Barkov2018-06-121-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | command Backporting (partially) the fix for MDEV-14603.
* | | | | | MDEV-18796 Synchronize PS grammar between sql_yacc.yy and sql_yacc_ora.yyAlexander Barkov2019-03-031-17/+19
| | | | | |
* | | | | | MDEV-7597 Expiration of user passwordsRobert Bindar2019-02-211-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for expiring user passwords. The following statements are extended: CREATE USER user@localhost PASSWORD EXPIRE [option] ALTER USER user@localhost PASSWORD EXPIRE [option] If no option is specified, the password is expired with immediate effect. If option is DEFAULT, global policy applies according to the default_password_lifetime system var (if 0, password never expires, if N, password expires every N days). If option is NEVER, the password never expires and if option is INTERVAL N DAY, the password expires every N days. The feature also supports the disconnect_on_expired_password system var and the --connect-expired-password client option. Closes #1166
* | | | | | MDEV-6111 Optimizer TraceVarun Gupta2019-02-131-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This task involves the implementation for the optimizer trace. This feature produces a trace for any SELECT/UPDATE/DELETE/, which contains information about decisions taken by the optimizer during the optimization phase (choice of table access method, various costs, transformations, etc). This feature would help to tell why some decisions were taken by the optimizer and why some were rejected. Trace is session-local, controlled by the @@optimizer_trace variable. To enable optimizer trace we need to write: set @@optimizer_trace variable= 'enabled=on'; To display the trace one can run: SELECT trace FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE; This task also involves: MDEV-18489: Limit the memory used by the optimizer trace introduces a switch optimizer_trace_max_mem_size which limits the memory used by the optimizer trace. This was implemented by Sergei Petrunia.
* | | | | | Galera4Brave Galera Crew2019-01-231-48/+0
| | | | | |
* | | | | | Merge 10.3 into 10.4Marko Mäkelä2018-11-191-0/+12
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge 10.2 into 10.3Marko Mäkelä2018-11-191-0/+12
| |\ \ \ \ \ | | |/ / / /
| | * | | | MDEV-13170: Database service (MySQL) stops after update with triggerVarun Gupta2018-11-161-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For prepare statemtent/stored procedures we rollback the items to original ones after prepare execution in the function reinit_stmt_before_use. This rollback is done for group by, order by clauses but is not done for the window specification containing the order by and partition by clause of the window function.
* | | | | | Merge 10.3 into 10.4mariadb-10.4.0Marko Mäkelä2018-11-081-1/+1
|\ \ \ \ \ \ | |/ / / / /
| * | | | | MDEV-16697: Fix difference between 32bit/windows and 64bit systems in ↵Oleksandr Byelkin2018-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | allowed select nest level
* | | | | | Merge 10.3 into 10.4Marko Mäkelä2018-10-101-1/+1
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge 10.2 into 10.3Marko Mäkelä2018-10-091-1/+1
| |\ \ \ \ \ | | |/ / / /
| | * | | | MDEV-17373 Windows: application verifier stop "Attempt to use an unknown SOCKET"Vladislav Vaintroub2018-10-051-1/+1
| | | | | |
* | | | | | Merge 10.3 into 10.4Marko Mäkelä2018-10-051-0/+12
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Merge branch '10.2' into 10.3Sergei Golubchik2018-09-281-0/+12
| |\ \ \ \ \ | | |/ / / /
| | * | | | MDEV-17154 Multiple selects from parametrized CTE fails with syntax errorIgor Babaev2018-09-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fills a serious flaw in the implementation of common table expressions. Before this patch an attempt to prepare a statement from a query with a parameter marker in a CTE that was used more than once in the query ended up with a bogus error message. Similarly if a statement in a stored procedure contained a CTE whose specification used a local variables and this CTE was referred to more than once in the statement then the server failed to execute the stored procedure returning a bogus error message on a non-existing field. The problems appeared due to incorrect handling of parameter markers / local variables in CTEs that were referred more than once. This patch fixes the problems by differentiating between the original occurrences of a parameter marker / local variable used in the specification of a CTE and the corresponding occurrences used in copies of this specification. These copies are substituted instead of non-first references to the CTE. The idea of the fix and even some code were taken from the MySQL implementation of the common table expressions.
| | * | | | MDEV-16992 Assertion `table_ref->table || table_ref->view' failed inIgor Babaev2018-08-301-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Field_iterator_table_ref::set_field_iterator Several functions that processed different prepare statements missed the DT_INIT flag in last parameter of the open_normal_and_derived_tables() calls. It made context analysis of derived tables dependent on the order in which the derived tables were processed by mysql_handle_derived(). This order was induced by the order of SELECTs in all_select_list. In 10.4 the order of SELECTs in all_select_list became different and lack of the DT_INIT flags in some open_normal_and_derived_tables() call became critical as some derived tables were not identified as such.
| * | | | | EV-16992 Assertion `table_ref->table || table_ref->view' failed inIgor Babaev2018-08-301-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Field_iterator_table_ref::set_field_iterator Several functions that processed different prepare statements missed the DT_INIT flag in last parameter of the open_normal_and_derived_tables() calls. It made context analysis of derived tables dependent on the order in which the derived tables were processed by mysql_handle_derived(). This order was induced by the order of SELECTs in all_select_list. In 10.4 the order of SELECTs in all_select_list became different and lack of the DT_INIT flags in some open_normal_and_derived_tables() call became critical as some derived tables were not identified as such.
* | | | | | EV-16992 Assertion `table_ref->table || table_ref->view' failed inIgor Babaev2018-09-061-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Field_iterator_table_ref::set_field_iterator Several functions that processed different prepare statements missed the DT_INIT flag in last parameter of the open_normal_and_derived_tables() calls. It made context analysis of derived tables dependent on the order in which the derived tables were processed by mysql_handle_derived(). This order was induced by the order of SELECTs in all_select_list. In 10.4 the order of SELECTs in all_select_list became different and lack of the DT_INIT flags in some open_normal_and_derived_tables() call became critical as some derived tables were not identified as such.
* | | | | | MDEV-16910 Add class VDecAlexander Barkov2018-08-071-10/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding classes VDec and VDec2_lazy, according to the task description. This patch removes around 250 duplicate code lines.
* | | | | | MDEV-11953: support of brackets in UNION/EXCEPT/INTERSECT operationsOleksandr Byelkin2018-07-041-24/+26
| | | | | |
* | | | | | Merge remote-tracking branch 'origin/10.3' into 10.4Alexander Barkov2018-06-051-4/+2
|\ \ \ \ \ \ | |/ / / / /
| * | | | | MDEV-16385 ROW SP variable is allowed in unexpected contextAlexander Barkov2018-06-051-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem described in the bug report happened because the code did not test check_cols(1) after fix_fields() in a few places. Additionally, fix_fields() could be called multiple times for SP variables, because they are all fixed at a early stage in append_for_log(). Solution: 1. Adding a few helper methods - fix_fields_if_needed() - fix_fields_if_needed_for_scalar() - fix_fields_if_needed_for_bool() - fix_fields_if_needed_for_order_by() and using it in many cases instead of fix_fields() where the "fixed" status is not definitely known to be "false". 2. Adding DBUG_ASSERT(!fixed) into Item_splocal*::fix_fields() to catch double execution. 3. Adding tests. As a good side effect, the patch removes a lot of duplicate code (~60 lines): if (!item->fixed && item->fix_fields(..) && item->check_cols(1)) return true;
* | | | | | mysys: rename ME_xxx flags to match plugin apiSergei Golubchik2018-06-041-3/+3
|/ / / / /
* | | | | Merge branch 'github/10.2' into 10.3Sergei Golubchik2018-05-221-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge branch '10.1' into 10.2Sergei Golubchik2018-05-201-1/+1
| |\ \ \ \ | | |/ / /
| | * | | MDEV-15347: Valgrind or ASAN errors in mysql_make_view on query from ↵Oleksandr Byelkin2018-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | information_schema Make each lex pointing to statement lex instead of global pointer in THD (no need store and restore the global pointer and put it on SP stack).
* | | | | MDEV-15813 ASAN use-after-poison in hp_hashnr upon HANDLER READ on a ↵Alexey Botchkov2018-05-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | versioned HEAP table. Check index capabilities before executing HANDLER READ command.
* | | | | MDEV-14820 System versioning is applied incorrectly to CTEsSergei Golubchik2018-05-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make sure that SELECT_LEX_UNIT::derived, behaves as documented (points to the "TABLE_LIST representing this union in the embedding select"). For recursive CTE this was not necessarily the case, it could've pointed to the TABLE_LIST inside the CTE, not in the embedding select. To fix: * don't update unit->derived in mysql_derived_prepare(), pass derived as an argument to st_select_lex_unit::prepare() * prefer to set unit->derived in TABLE_LIST::init_derived() to the TABLE_LIST in the embedding select, not to the recursive reference. Fail if there are many TABLE_LISTs in the embedding select with conflicting FOR SYSTEM_TIME clauses. cleanup: * remove redundant THD* argument from st_select_lex_unit::prepare()
* | | | | Merge branch '10.2' into 10.3Sergei Golubchik2018-05-111-4/+4
|\ \ \ \ \ | |/ / / /