Commit graph

66349 commits

Author SHA1 Message Date
Oleksandr Byelkin
f89a5c9a25 MDEV-11825: Make session variables TRACKING enabled by default 2017-04-18 17:15:44 +02:00
Michael Widenius
a05a610d60 Added "const" to new data for handler::update_row()
This was done to make it clear that a update_row() should not change the
row.
This was not done for handler::write_row() as this function still needs
to update auto_increment values in the row. This should at some point
be moved to handler::ha_write_row() after which write_row can also have
const arguments.
2017-04-18 12:23:53 +03:00
Michael Widenius
d82ac8eaaf Change "static int" to enum in classes
This was done when static int where used as bit fields or enums
2017-04-18 12:23:40 +03:00
Michael Widenius
00946f4331 Simple cleanups
Fixed compiler warning
Added comment
2017-04-18 12:23:18 +03:00
Jacob Mathew
38af34bb21 MDEV-11117 CHECK constraint fails on intermediate step of ALTER
Fixed the bug by failing the statement with an error message that explains
that an auto-increment column may not be used in an expression for a
check constraint.
Added a test case in check_constraint.test.
Updated existing tests and results.
2017-04-17 15:32:44 -07:00
Alexander Barkov
f2ccc595b6 Derive Item_func_makedate from Item_datefunc rather than Item_temporal_func 2017-04-15 15:51:57 +04:00
Alexander Barkov
64e63131f8 Moving implementation of Item_hybrid_func::fix_attributes() from item_cmpfunc.cc to item_func.cc 2017-04-14 21:27:33 +04:00
Alexander Barkov
e2fc1f0ad4 Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-04-13 07:12:50 +04:00
Alexander Barkov
45730fb11e MDEV-12238 Add Type_handler::Item_func_{plus|minus|mul|div|mod}_fix_length_and_dec() 2017-04-13 06:50:00 +04:00
Alexander Barkov
949faa2ec2 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-04-13 05:52:44 +04:00
Alexander Barkov
310ec63fd6 Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-04-12 22:09:55 +04:00
Alexander Barkov
012fbc15cf MDEV-12478 CONCAT function inside view casts values incorrectly with Oracle sql_mode 2017-04-11 19:32:55 +04:00
Sergei Golubchik
663068c6ee Merge remote-tracking branch 'mysql/5.5' into 5.5 2017-04-11 10:18:04 -04:00
Alexander Barkov
5bf7046fa7 Adding the const quafilier to "sp_name *" parameters in a few routine. 2017-04-11 16:15:08 +04:00
Kristian Nielsen
88613e1df6 MDEV-11201: gtid_ignore_duplicates incorrectly ignores statements when GTID replication is not enabled
When master_use_gtid=no, the IO thread loads the slave GTID state from
the master during connect. This races with the SQL thread when
gtid_ignore_duplicates=1. If an event is in the relay log from before
the new connect and has not been applied yet, moving the slave
position causes the SQL thread to think that event should be skipped
due to gtid_ignore_duplicates=1.

This patch simply disables gtid_ignore_duplicates when not using GTID,
which seems to be what one would expect.
2017-04-10 07:53:27 +02:00
Michael Widenius
597d1515da Merge branch 'bb-10.2-ext' into 10.3 2017-04-09 14:27:35 +03:00
Michael Widenius
958e634d25 Fixed failure in mtr --ps sql_sequence.create sql_sequence.read_only
Problem was that we got an error in sequence_insert while opening the
newly created sequence table in an prepared statement as the table id
didn't match.
Fixed by temporarly removing the reprepare observer during
sequence_insert as there can never be a table missmatch in this case.
2017-04-09 14:23:49 +03:00
Oleksandr Byelkin
d9484a2f60 MDEV-12395: DROP PARTITION does not work as expected when table has DEFAULT LIST partition
Data loss in case of partituon removing is documented => do not try to prevent it
2017-04-07 18:26:55 +02:00
Alexander Barkov
3edfe79712 Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-04-07 20:10:18 +04:00
Oleksandr Byelkin
27f6b11a97 MDEV-12379: Server crashes in TABLE_LIST::is_with_table on SHOW CREATE VIEW
In case of error on opening VIEW (absent table for example) it is still possible to print its definition but some variable is not set (table_list->derived->derived) so it is better do not try to test it when there is safer alternative (table_list itself).
2017-04-07 17:56:21 +02:00
Monty
0177a9c74a Simple binary cache optimizations
- Don't call my_chsize() for small (less than 64K) binary log tmp files
- Don't flush cache to disk on reset.
2017-04-07 19:12:58 +04:00
Monty
470c3fd98d Change error message when using DROP VIEW on a non existing view from
"Unknown table" to "Unknown view"
2017-04-07 18:22:06 +04:00
Monty
17a87d6063 MDEV-10139 Support for SEQUENCE objects
Working features:
CREATE OR REPLACE [TEMPORARY] SEQUENCE [IF NOT EXISTS] name
    [ INCREMENT [ BY | = ] increment ]
    [ MINVALUE [=] minvalue | NO MINVALUE ]
    [ MAXVALUE [=] maxvalue | NO MAXVALUE ]
    [ START [ WITH | = ] start ] [ CACHE [=] cache ] [ [ NO ] CYCLE ]
    ENGINE=xxx COMMENT=".."
SELECT NEXT VALUE FOR sequence_name;
SELECT NEXTVAL(sequence_name);
SELECT PREVIOUS VALUE FOR sequence_name;
SELECT LASTVAL(sequence_name);

SHOW CREATE SEQUENCE sequence_name;
SHOW CREATE TABLE sequence_name;
CREATE TABLE sequence-structure ... SEQUENCE=1
ALTER TABLE sequence RENAME TO sequence2;
RENAME TABLE sequence TO sequence2;
DROP [TEMPORARY] SEQUENCE  [IF EXISTS] sequence_names

Missing features
- SETVAL(value,sequence_name), to be used with replication.
- Check replication, including checking that sequence tables are marked
  not transactional.
- Check that a commit happens for NEXT VALUE that changes table data (may
  already work)
- ALTER SEQUENCE. ANSI SQL version of setval.
- Share identical sequence entries to not add things twice to table list.
- testing insert/delete/update/truncate/load data
- Run and fix Alibaba sequence tests (part of mysql-test/suite/sql_sequence)
- Write documentation for NEXT VALUE / PREVIOUS_VALUE
- NEXTVAL in DEFAULT
  - Ensure that NEXTVAL in DEFAULT uses database from base table
- Two NEXTVAL for same row should give same answer.
- Oracle syntax sequence_table.nextval, without any FOR or FROM.
- Sequence tables are treated as 'not read constant tables' by SELECT; Would
  be better if we would have a separate list for sequence tables so that
  select doesn't know about them, except if refereed to with FROM.

Other things done:
- Improved output for safemalloc backtrack
- frm_type_enum changed to Table_type
- Removed lex->is_view and replaced with lex->table_type. This allows
  use to more easy check if item is view, sequence or table.
- Added table flag HA_CAN_TABLES_WITHOUT_ROLLBACK, needed for handlers
  that want's to support sequences
- Added handler calls:
 - engine_name(), to simplify getting engine name for partition and sequences
 - update_first_row(), to be able to do efficient sequence implementations.
 - Made binlog_log_row() global to be able to call it from ha_sequence.cc
- Added handler variable: row_already_logged, to be able to flag that the
  changed row is already logging to replication log.
- Added CF_DB_CHANGE and CF_SCHEMA_CHANGE flags to simplify
  deny_updates_if_read_only_option()
- Added sp_add_cfetch() to avoid new conflicts in sql_yacc.yy
- Moved code for add_table_options() out from sql_show.cc::show_create_table()
- Added String::append_longlong() and used it in sql_show.cc to simplify code.
- Added extra option to dd_frm_type() and ha_table_exists to indicate if
  the table is a sequence. Needed by DROP SQUENCE to not drop a table.
2017-04-07 18:09:56 +04:00
Monty
546e7aa96f MDEV-8203 Assert in Query_log_event::do_apply_event()
This happens because the master writes a table_map event to the binary log, but no row event.
The slave has a check that there should always be a row event if there was a table_map event, which
causes a crash.

Fixed by remembering in the cache what kind of events are logged
and ignore cached statements which is just a table map event.
2017-04-07 15:58:17 +04:00
Alexander Barkov
dedb022047 Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-04-07 14:22:50 +04:00
Alexander Barkov
ed305c0fd5 MDEV-12461 TYPE OF and ROW TYPE OF anchored data types 2017-04-07 13:40:27 +04:00
Sergei Golubchik
cd79be82d1 cleanup: unused method LOGGER::flush_logs 2017-04-07 09:55:54 +02:00
Sergei Golubchik
06ee58a7dd ASAN error in rpl.mysql-wsrep#110-2
Annotate_rows_log_event again. When a new annotate event comes,
the server applies it first (which backs up thd->query_string),
then frees the old annotate event, if any. Normally there isn't.

But with sub-statements (e.g. triggers) new annotate event comes
before the first one is freed, so the second event backs up
thd->query_string that was set by the first annotate event. Then
the first event is freed, together with its query string. And then
the second event restores thd->query_string to this freed memory.

Fix: free old annotate event before applying the new one.
2017-04-07 09:55:54 +02:00
Sergei Golubchik
30ed99cb82 ASAN errors in many rpl tests
Annotate_rows_log_event should always restore thd->query_string
if it was backed up. Even if the backed up value is NULL.
2017-04-07 09:55:54 +02:00
Sergei Golubchik
82196f0131 MDEV-11995 ALTER TABLE proceeds despite reporting ER_TOO_LONG_KEY error
automatic shortening of a too-long non-unique key should
be not a warning, but a note. It's a normal optimization,
doesn't affect correctness, and should never be converted to
an error, no matter how strict sql_mode is.
2017-04-07 09:55:54 +02:00
Alexander Barkov
113a980ff1 MDEV-12457 Cursors with parameters 2017-04-07 06:30:16 +04:00
Alexander Barkov
75d1962a24 Using the -t command line to bison instead of %name-prefix
Needed to compile on machines with older bison versions.
Adding a new parameter "name_prefix" to RUN_BISON() cmake macro.
2017-04-07 06:30:05 +04:00
Igor Babaev
428a922cd0 Fixed the bug mdev-12440.
When a CTE referring to another CTE from the same with clause
was used twice then the server could not find the second CTE and
reported a bogus error message.
This happened because for any unit that was created as a clone of
a CTE specification the pointer to the WITH clause that owned this CTE
was not set.
2017-04-06 12:08:58 -07:00
Alexander Barkov
dadb76521d Using the -t command line to bison instead of %name-prefix
Needed to compile on machines with older bison versions.
Adding a new parameter "name_prefix" to RUN_BISON() cmake macro.
2017-04-06 20:58:12 +04:00
Alexander Barkov
06fede98a5 MDEV-12457 Cursors with parameters 2017-04-06 17:05:42 +04:00
Sachin Setiya
969fc61120 Fix build on windows
Signed-off-by: Sachin Setiya <sachinsetia1001@gmail.com>
2017-04-06 15:41:54 +05:30
Sachin Setiya
bd2064e820 MW-313 Enforce wsrep_max_ws_rows also when binlog is enabled
Signed-off-by: Sachin Setiya <sachinsetia1001@gmail.com>
2017-04-06 15:41:54 +05:30
Sachin Setiya
ff7426290c MW-329 Fix incorrect affected rows count after replay
Fixes wsrep_replay_transaction so that it preserves affected rows,
last insert id, and message from diagnostics area.
2017-04-06 15:41:54 +05:30
sjaakola
836727c971 refs: MW-319
* silenced the WSREP_ERROR, this fires for all replication filtered DDL,
  and is false positive
2017-04-06 15:41:54 +05:30
Marko Mäkelä
1494147cf6 Merge 10.1 into 10.2 2017-04-06 09:52:25 +03:00
Marko Mäkelä
8d4871a953 Merge 10.0 into 10.1 2017-04-06 08:53:59 +03:00
Alexander Barkov
ea751857db Merge bb-10.2-compatibility into 10.3 2017-04-06 08:34:28 +04:00
Oleksandr Byelkin
57a699b0a0 MDEV-8642: WHERE Clause not applied on View - Empty result set returned
An attempt to mark reference as dependent lead to transfering this property to
original view field and through it to other references of this field which
can't be dependent.
2017-04-05 20:46:19 +02:00
Jan Lindström
cd494f4cef fix warning "ignoring return value" of fwrite.
Merge pull request https://github.com/MariaDB/server/pull/343

contributed by Eric Herman.
2017-04-05 14:45:17 +03:00
Alexander Barkov
e1cff0ac5d MDEV-12441 Variables declared after cursors with parameters lose values
Parse context frames (sp_pcontext) can have holes in variable run-time offsets,
the missing offsets reside on the children contexts in such cases.

Example:

  CREATE PROCEDURE p1() AS
    x0 INT:=100;        -- context 0, position 0, run-time 0
    CURSOR cur(
      p0 INT,           -- context 1, position 0, run-time 1
      p1 INT            -- context 1, position 1, run-time 2
    ) IS SELECT p0, p1;
    x1 INT:=101;        -- context 0, position 1, run-time 3
  BEGIN
    ...
  END;

Fixing a few methods to take this into account:
- sp_pcontext::find_variable()
- sp_pcontext::retrieve_field_definitions()
- LEX::sp_variable_declarations_init()
- LEX::sp_variable_declarations_finalize()
- LEX::sp_variable_declarations_rowtype_finalize()
- LEX::sp_variable_declarations_with_ref_finalize()

Adding a convenience method:

  sp_pcontext::get_last_context_variable(uint offset_from_the_end);

to access variables from the end, rather than from the beginning.
This helps to loop through the context variable array (m_vars)
on the fragment that does not have any holes.

Additionally, renaming sp_pcontext::find_context_variable() to
sp_pcontext::get_context_variable(). This method simply returns
the variable by its index. So let's rename to avoid assumptions
that some heavy lookup is going on inside.
2017-04-05 15:03:02 +04:00
Alexander Barkov
d433277f53 A cleanup for MDEV-10914 ROW data type for stored routine variables
Addressing Monty's review suggestions
2017-04-05 15:03:02 +04:00
Alexander Barkov
cae6bf2b9c Cleanup for MDEV-10581 sql_mode=ORACLE: Explicit cursor FOR LOOP
Addressing Monty's review suggestions.
2017-04-05 15:03:02 +04:00
Alexander Barkov
ce4b291b51 A cleanup patch for MDEV-12011 sql_mode=ORACLE: cursor%ROWTYPE in variable declarations
Addressing Monty's review suggestions
2017-04-05 15:03:02 +04:00
Alexander Barkov
48a7ea6da3 Uninitialized Column_definition::pack_flag for ROW-type SP variables and their fields
Fixed that the Column_definition::pack_flag member corresponding to
ROW-type SP variables and their fields was not properly initialized.
This lead to sporadic test failures. Valgrind complained about jumps
depending on uninitialized value in VALGRIND builds.

This patch makes sure that sp_head::fill_spvar_definition() is always
called for ROW variables and their fields.

Additionally, fixed that a function with a scalar parameter
erroneously acceptes ROWs with one fields. Now an error is returned.
2017-04-05 15:03:01 +04:00
Alexander Barkov
281f8a42ee MDEV-12089 sql_mode=ORACLE: Understand optional routine name after the END keyword 2017-04-05 15:03:01 +04:00
Alexander Barkov
01457ec280 MDEV-12347 Valgrind reports invalid read errors in Item_field_row::element_index_by_name 2017-04-05 15:03:01 +04:00
Alexander Barkov
ec19e48021 MDEV-12314 Implicit cursor FOR LOOP for cursors with parameters 2017-04-05 15:03:00 +04:00
Alexander Barkov
e0451941cc MDEV-12291 Allow ROW variables as SELECT INTO targets 2017-04-05 15:03:00 +04:00
Alexander Barkov
9dfe7bf86d MDEV-10598 Variable declarations can go after cursor declarations
Based on a contributed patch from Jerome Brauge.
2017-04-05 15:03:00 +04:00
Alexander Barkov
84c55a5668 MDEV-10581 sql_mode=ORACLE: Explicit cursor FOR LOOP
MDEV-12098 sql_mode=ORACLE: Implicit cursor FOR loop
2017-04-05 15:02:59 +04:00
Alexander Barkov
f429b5a834 MDEV-12011 sql_mode=ORACLE: cursor%ROWTYPE in variable declarations
Implementing cursor%ROWTYPE variables, according to the task description.

This patch includes a refactoring in how sp_instr_cpush and sp_instr_copen
work. This is needed to implement MDEV-10598 later easier, to allow variable
declarations go after cursor declarations (which is currently not allowed).

Before this patch, sp_instr_cpush worked as a Query_arena associated with
the cursor. sp_instr_copen::execute() switched to the sp_instr_cpush's
Query_arena when executing the cursor SELECT statement.

Now the Query_arena associated with the cursor is stored inside an instance
of a new class sp_lex_cursor (a LEX descendand) that contains the cursor SELECT
statement.

This simplifies the implementation, because:
- It's easier to follow the code when everything related to execution
  of the cursor SELECT statement is stored inside the same sp_lex_cursor
  object (rather than distributed between LEX and sp_instr_cpush).
- It's easier to link an sp_instr_cursor_copy_struct to
  sp_lex_cursor rather than to sp_instr_cpush.
- Also, it allows to perform sp_instr_cursor_copy_struct::exec_core()
  without having a pointer to sp_instr_cpush, using a pointer to sp_lex_cursor
  instead. This will be important for MDEV-10598, because sp_instr_cpush will
  happen *after* sp_instr_cursor_copy_struct.

After MDEV-10598 is done, this declaration:

DECLARE
  CURSOR cur IS SELECT * FROM t1;
  rec cur%ROWTYPE;
BEGIN
  OPEN cur;
  FETCH cur INTO rec;
  CLOSE cur;
END;

will generate about this code:

+-----+--------------------------+
| Pos | Instruction              |
+-----+--------------------------+
|   0 | cursor_copy_struct rec@0 | Points to sp_cursor_lex through m_lex_keeper
|   1 | set rec@0 NULL           |
|   2 | cpush cur@0              | Points to sp_cursor_lex through m_lex_keeper
|   3 | copen cur@0              | Points to sp_cursor_lex through m_cursor
|   4 | cfetch cur@0 rec@0       |
|   5 | cclose cur@0             |
|   6 | cpop 1                   |
+-----+--------------------------+

Notice, "cursor_copy_struct" and "set" will go before "cpush".
Instructions at positions 0, 2, 3 point to the same sp_cursor_lex instance.
2017-04-05 15:02:59 +04:00
Alexander Barkov
1b8a0c879d MDEV-12133 sql_mode=ORACLE: table%ROWTYPE in variable declarations 2017-04-05 15:02:59 +04:00
Alexander Barkov
400de20279 MDEV-12209 sql_mode=ORACLE: Syntax error in a OPEN cursor with parameters makes the server crash
The bug was introduced in the patch for "MDEV-10597 Cursors with parameters".
The LEX created in assignment_source_expr was not put into
thd->lex->sphead->m_lex (the stack of LEX'es), so syntax error in "expr"
caused a wrong memory cleanup in sp_head::~sp_head().

The fix changes the code to use sp_head::push_lex() followed by
sp_head::restore_lex(), like it happens in all other similar cases.
2017-04-05 15:02:58 +04:00
Alexander Barkov
7ca2f816a8 Part#2 for MDEV-12107 sql_mode=ORACLE: Inside routines the CALL keywoard is optional
Allowing qualified procedure names to be used without the CALL keyword:

BEGIN
  test.p1(10);
  test.p2;
END;

Note:
- COMMIT and ROLLBACK cannot be used in a direct assignment anymore:
    COMMIT:= 10;
    ROLLBACK:= 10;
  But as they are reserved keywords in Oracle anyway, this is not a problem.
- SHUTDOWN now also cannot be used in direct a direct assignment:
    SHUTDOWN:=10;
  If this causes migration problems in the future, the grammar should
  be modified.

Note:
  Variables with names COMMIT, ROLLBACK and SHUTDOWN can still be assigned
  with the SET statement, e.g. SET COMMIT=10;
2017-04-05 15:02:58 +04:00
Alexander Barkov
29e7cf01c3 MDEV-12107 sql_mode=ORACLE: Inside routines the CALL keywoard is optional 2017-04-05 15:02:58 +04:00
Alexander Barkov
839e0947ee MDEV-12143 sql_mode=ORACLE: make the CONCAT function ignore NULL arguments 2017-04-05 15:02:57 +04:00
Alexander Barkov
915c5df865 MDEV-12088 sql_mode=ORACLE: Do not require BEGIN..END in multi-statement exception handlers in THEN clause 2017-04-05 15:02:57 +04:00
Alexander Barkov
99df09ecab MDEV-12086 sql_mode=ORACLE: allow SELECT UNIQUE as a synonym for SELECT DISTINCT 2017-04-05 15:02:57 +04:00
halfspawn
af7f287b3b MDEV-10697 GOTO statement 2017-04-05 15:02:57 +04:00
Alexander Barkov
d836f52be5 MDEV-12007 Allow ROW variables as a cursor FETCH target 2017-04-05 15:02:56 +04:00
Alexander Barkov
72f43df623 MDEV-10914 ROW data type for stored routine variables 2017-04-05 15:02:56 +04:00
Alexander Barkov
81f32145fa MDEV-10655 Anonymous blocks 2017-04-05 15:02:55 +04:00
Alexander Barkov
08799831cc MDEV-11880 sql_mode=ORACLE: Make the concatenation operator ignore NULL arguments
Now when sql_mode=ORACLE, the concatenation operator || treats
NULLs as empty strings.

Based on the contributed patch from Jérôme Brauge.
2017-04-05 15:02:55 +04:00
Alexander Barkov
46255b0c0d Fixing that LEX::sp_add_for_loop_variable() did not initialize pack_flag
This fixes compat/oracle.sp test failure in release builds.
2017-04-05 15:02:55 +04:00
Alexander Barkov
46d076d67a MDEV-10577 sql_mode=ORACLE: %TYPE in variable declarations 2017-04-05 15:02:54 +04:00
Alexander Barkov
cd1afe0aac MDEV-10588 sql_mode=ORACLE: TRUNCATE TABLE t1 [ {DROP|REUSE} STORAGE ] 2017-04-05 15:02:54 +04:00
Alexander Barkov
c0576ba5ec MDEV-11275 sql_mode=ORACLE: CAST(..AS VARCHAR(N)) 2017-04-05 15:02:54 +04:00
Alexander Barkov
f8a714c848 MDEV-10597 Cursors with parameters 2017-04-05 15:02:53 +04:00
Alexander Barkov
4ed804aa4d MDEV-10587 sql_mode=ORACLE: User defined exceptions 2017-04-05 15:02:53 +04:00
Alexander Barkov
4d3818d30d MDEV-11037 Diagnostics_area refactoring for user defined exceptions
Part 2:

Moving the part of Sql_condition that contain condition items
(such as m_class_origin, m_cursor_name, etc) into a separate
class Sql_condition_items. This allows to remove duplicate code in
different Sql_condition constructors.

Also, introducing new Sql_condition constructors and removing the method
Sql_condition::set(). All code sequences that called an Sql_condition
constructor followed by Sql_condition::set() are now replaced to
the new constructor calls. This gives light performance improvement,
as the relevant members are now initialized only one time.
2017-04-05 15:02:53 +04:00
Alexander Barkov
6010662cb3 MDEV-11037 Diagnostics_area refactoring for user defined exceptions 2017-04-05 15:02:53 +04:00
Alexander Barkov
ffca1e4830 MDEV-10578 sql_mode=ORACLE: SP control functions SQLCODE, SQLERRM 2017-04-05 15:02:52 +04:00
Alexander Barkov
de6d40592c MDEV-10411 Providing compatibility for basic PL/SQL constructs
An additional change for "Part 9: EXCEPTION handlers"

This construct:
  EXCEPTION WHEN OTHERS THEN ...;
now catches warning-alike conditions, e.g. NO_DATA_FOUND.
2017-04-05 15:02:52 +04:00
Alexander Barkov
054d00a9a3 A fix for MDEV-10411 Providing compatibility for basic PL/SQL constructs (Part 6: Assignment operator)
Fixed that a crash in this script:

SET sql_mode=ORACLE;
max_sort_length:= 1024;
2017-04-05 15:02:52 +04:00
Alexander Barkov
7fa1ad14dc MDEV-10840 sql_mode=ORACLE: RAISE statement for predefined exceptions 2017-04-05 15:02:51 +04:00
Alexander Barkov
76714a5c9a MDEV-10582 sql_mode=ORACLE: explicit cursor attributes %ISOPEN, %ROWCOUNT, %FOUND, %NOTFOUND 2017-04-05 15:02:51 +04:00
Alexander Barkov
4bb87996b9 DEV-10583 sql_mode=ORACLE: SQL%ROWCOUNT
Fixed that EXPLAIN EXTENDED erroneously returned
"SQL%%ROWCOUNT" instead of "SQL%ROWCOUNT"
2017-04-05 15:02:51 +04:00
Alexander Barkov
a699a5f967 MDEV-10583 sql_mode=ORACLE: SQL%ROWCOUNT 2017-04-05 15:02:50 +04:00
Alexander Barkov
ccb91eb3ce MDEV-10839 sql_mode=ORACLE: Predefined exceptions: TOO_MANY_ROWS, NO_DATA_FOUND, DUP_VAL_ON_INDEX 2017-04-05 15:02:50 +04:00
Alexander Barkov
c8822d71ef MDEV-10342 Providing compatibility for basic SQL built-in functions
Adding the Oracle style DECODE function:

  DECODE(operand, search, result [, search, result ...] [, default_result])
2017-04-05 15:02:49 +04:00
Alexander Barkov
02a72cf87c MDEV-10596 Allow VARCHAR and VARCHAR2 without length as a data type of routine parameters and in RETURN clause 2017-04-05 15:02:49 +04:00
Alexander Barkov
ec527face3 MDEV-10801 sql_mode: dynamic SQL placeholders 2017-04-05 15:02:49 +04:00
Alexander Barkov
f564ceb473 Fixed a crash in a EXIT/CONTINUE with an unknown identifier in the WHEN clause
The crash happened because of a wrong reset_lex() .. restore_lex() sequence.
The Item in WHERE clause and the corresponding sp_instr_jump_if_not() were
erroneously created using different LEX.
2017-04-05 15:02:48 +04:00
Alexander Barkov
cfb6345982 Fixed that 'FOR i IN 1..10' with no spaces around '..' returned a syntax error.
This is a fix for "MDEV-10580 sql_mode=ORACLE: FOR loop statement"
The tokenizer now treats digits followed by two dots (e.g. '1..')
as an integer number '1' followed by DOT_DOT_SYM.
Previously this sequence was treated as a double number '1.' followed by '.'.
2017-04-05 15:02:48 +04:00
Alexander Barkov
bf573e21c7 MDEV-10580 sql_mode=ORACLE: FOR loop statement
Fixed a crash when trying to use a FOR loop as a compound statement
outside of an SP. A bug in 051e415d8a251bd70e9b73619dbcc40f3c65371d.
2017-04-05 15:02:48 +04:00
Alexander Barkov
30bec863cf MDEV-10342 Providing compatibility for basic SQL built-in functions
Adding functions NVL() and NVL2().
2017-04-05 15:02:48 +04:00
Alexander Barkov
5721ea6ab7 MDEV-10579 sql_mode=ORACLE: Triggers: Understand :NEW.c1 and :OLD.c1 instead of NEW.c1 and OLD.c1 2017-04-05 15:02:47 +04:00
Alexander Barkov
ca242117ce MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 19: CONTINUE statement
2017-04-05 15:02:47 +04:00
Alexander Barkov
442ea81ed3 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Fixed that the ITERATE statement inside a FOR LOOP statement did not
increment the index variable before jumping to the beginning
of the loop, which caused the loop to repeat endlessly.
2017-04-05 15:02:47 +04:00
Alexander Barkov
2ea63492f7 MDEV-10580 sql_mode=ORACLE: FOR loop statement
Adding labeled FOR LOOP
2017-04-05 15:02:46 +04:00
Alexander Barkov
c570636ba2 MDEV-10580 sql_mode=ORACLE: FOR loop statement
Adding non-labeled FOR LOOP statement.
2017-04-05 15:02:46 +04:00
Alexander Barkov
71a0a12e61 Changing a LEX::sp_variable_declarations_finalize() parameter
from "const Lex_field_type_st &" to "const Column_definition &".
2017-04-05 15:02:46 +04:00
Alexander Barkov
8ec4cf1f01 Refactoring for MDEV-10580 sql_mode=ORACLE: FOR loop statement
Adding methods:
- LEX::sp_while_loop_expression()
- LEX::sp_while_loop_finalize()

to reuse code between sql_yacc.yy and sql_yacc_ora.yy.
FOR loop will also reuse these methods.
2017-04-05 15:02:45 +04:00
Alexander Barkov
28f2859136 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 18: WHILE syntax
2017-04-05 15:02:45 +04:00
Alexander Barkov
4212039db7 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 17: RETURN in stored procedures
2017-04-05 15:02:45 +04:00
Alexander Barkov
ed19ed6a4b MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 16: CURSOR declaration
2017-04-05 15:02:45 +04:00
Alexander Barkov
6cd24d124f MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 15: ELSIF vs ELSEIF

Also, moving tests for Oracle keywords in sql_mode=DEFAULT
from "parser.test" to a better place "keywords.test".
2017-04-05 15:02:44 +04:00
Alexander Barkov
a83d0aee96 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 5: EXIT statement

Adding optional WHEN clause:

EXIT [label] [WHEN expr]
2017-04-05 15:02:44 +04:00
Alexander Barkov
8feb984211 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 5: EXIT statement

Adding unconditional EXIT statement:

  EXIT [ label ]

Conditional EXIT statements with WHERE clause
will be added in a separate patch.
2017-04-05 15:02:44 +04:00
Alexander Barkov
765d9d6429 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Moving similar code from sql_yacc.yy and sql_yacc_ora.yy to methods:
  LEX::maybe_start_compound_statement()
  LEX::sp_push_loop_label()
  LEX::sp_push_loop_empty_label()
  LEX::sp_pop_loop_label()
  LEX::sp_pop_loop_empty_label()

The EXIT statement will also reuse this code.
2017-04-05 15:02:44 +04:00
Alexander Barkov
f37a943f49 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Moving the code from *.yy to methods:
LEX::sp_change_context()
LEX::sp_leave_statement()
LEX::sp_iterate_statement()
to reuse the same code between LEAVE and ITERATE statements.
EXIT statement will also reuse the same code.
2017-04-05 15:02:43 +04:00
Alexander Barkov
4b61495576 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 9: EXCEPTION handlers

EXCEPTION is now supported in inner blocks.
2017-04-05 15:02:43 +04:00
Alexander Barkov
d2b007d6bc Optimization for MDEV-10411 Providing compatibility for basic PL/SQL constructs
When processing an SP body:

CREATE PROCEDURE p1 (parameters)
AS [ declarations ]
BEGIN statements
[ EXCEPTION exceptions ]
END;

the parser generates two "jump" instructions:
- from the end of "declarations" to the beginning of EXCEPTION
- from the end of EXCEPTION to "statements"

These jumps are useless if EXCEPTION does not exist.
This patch makes sure that these two "jump" instructions are
generated only if EXCEPTION really exists.
2017-04-05 15:02:43 +04:00
Alexander Barkov
81ba971d03 MDEV-10411 Providing compatibility for basic PL/SQL constructs
- Part 9: EXCEPTION handlers

  The top-most stored routine blocks now support EXCEPTION clause
  in its correct place:
  AS [ declarations ]
  BEGIN statements
  [ EXCEPTION exceptions ]
  END

  Inner block will be done in a separate commit.

- Part 14: IN OUT instead of INOUT (in SP parameter declarations)
2017-04-05 15:02:42 +04:00
Alexander Barkov
0040b0f380 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 13: RETURN vs RETURNS in function definition:

  CREATE FUNCTION f1(a INT) RETURN INT ...

Part 12:  No parentheses if no arguments:

  CREATE FUNCTION f1 RETURN INT ...
2017-04-05 15:02:42 +04:00
Alexander Barkov
bd76d44564 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 12: No parentheses if no arguments
Now "CREATE PROCEDURE p1 AS" is supported with no parentheses after the name.
Note, "CREATE FUNCTION f1 AS" is not supported yet, due to grammar conflict
with UDFs. Functions will be done in a separate patch.
2017-04-05 15:02:42 +04:00
Alexander Barkov
f3a0df72f2 Reusing code: Adding LEX::make_sp_head() and LEX::make_sp_head_no_recursive() 2017-04-05 15:02:41 +04:00
Alexander Barkov
dc292bc6eb MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 11: NULL as a statement
2017-04-05 15:02:41 +04:00
Alexander Barkov
0c9c4b84b7 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 10: Default variable value: x INT := 10;
2017-04-05 15:02:41 +04:00
Alexander Barkov
8fdc1f0147 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 9: EXCEPTION handlers

- Adding exception handler syntax:
  WHEN exception_name THEN statement
- Adding EXCEPTION section intoi the top BEGIN..END SP block.
  Note, currently EXCEPTION goes in the beginning of the top BEGIN..END
  SP block.

TODO:
- add EXCEPTION section into inner blocks
- move EXCEPTION to the end of the block
2017-04-05 15:02:41 +04:00
Alexander Barkov
a44e90ae05 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 7: variable declarations
2017-04-05 15:02:40 +04:00
Alexander Barkov
e399949bfe Adding Lex_spblock_st::init() and Lex_spblock_st::join(). 2017-04-05 15:02:40 +04:00
Alexander Barkov
365e0b3178 sql_lex.yy / sql_yacc_ora.yy refactoring for MDEV-10411.
1. Adding const qualifiers into a few method parameters.

2. Adding methods:
- sp_label::block_label_declare()
- LEX::sp_block_init()
- LEX::sp_block_finalize()
  to share more code between the files sql_yacc.yy and sql_yacc_ora.yy,
  as well as between the rules sp_labeled_block, sp_unlabeled_block,
  sp_unlabeled_block_not_atomic.

3. sql_yacc.yy, sql_yacc_ora.yy changes:
- Removing sp_block_content
- Reorganizing the grammar so the rules sp_labeled_block,
  sp_unlabeled_block, sp_unlabeled_block_not_atomic now
  contain both BEGIN_SYM and END keywords. Previously,
  BEGIN_SYM and END resided in different rules.
  This change makes the grammar easier to read,
  as well as simplifies adding Oracle-style DECLARE section (coming soon):
    DECLARE
      ..
    BEGIN
      ..
    END;

  Good side effects:
  - SP block related grammar does not use Lex->name any more.
  - The "splabel" member was removed from %union
2017-04-05 15:02:40 +04:00
Alexander Barkov
36b80caed1 Moving the code from *.yy to new methods to LEX and sp_context
Adding:
  LEX::sp_variable_declarations_init()
  LEX::sp_variable_declarations_finalize()
  LEX::sp_handler_declaration_init()
  LEX::sp_handler_declaration_finalize()
  LEX::sp_declare_cursor()
  sp_context::declare_condition()
2017-04-05 15:02:39 +04:00
Alexander Barkov
f71a1f736d MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part 4: AS/IS keyword before a function or a procedure body
2017-04-05 15:02:39 +04:00
Alexander Barkov
892af78085 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part6: assignment operator

  var:= 10;
2017-04-05 15:02:39 +04:00
Alexander Barkov
7e10e38825 MDEV-10411 Providing compatibility for basic PL/SQL constructs
Part2: Different order of IN, OUT, INOUT keywords in CREATE PROCEDURE params
2017-04-05 15:02:38 +04:00
Alexander Barkov
47a75ed7cb MDEV-10411 Providing compatibility for basic PL/SQL constructs
Changing label syntax from "label:" to "<<label>>".
2017-04-05 15:02:38 +04:00
Alexander Barkov
4de26a8e0e MDEV-10343 Providing compatibility for basic SQL data types
Based on the patch by Dmitry Tolpeko.
2017-04-05 15:02:38 +04:00
Alexander Barkov
decc550fa9 Making sp_create_assignment_lex() and sp_create_assignment_lex() non-static
Reusing sp_create_assignment_lex() and sp_create_assignment_lex() in
sql_yacc.yy and sql_yacc_ora.yy
2017-04-05 15:02:38 +04:00
Alexander Barkov
c21fc0085b Moving the code from my_parse_error() to THD::parse_error().
Reusing THD::parse_error() in sql_yacc.yy and sql_yacc_ora.yy
2017-04-05 15:02:37 +04:00
Alexander Barkov
9f6aca198c Adding an alternative grammar file sql_yacc_ora.yy for sql_mode=ORACLE
- Adding a new grammar file sql_yacc_ora.yy, which is currently
  almost a full copy of sql_yacc.yy.

  Note, it's now assumed that sql_yacc.yy and sql_yacc_ora.yy
  use the same set of %token directives and exactly the same
  %union directive.
  These declarations should eventually be moved into a shared
  included file, to make sure that sql_yacc.h and sql_yacc_ora.h
  are compatible.

- Removing the "-p MYSQL" flag from cmake/bison.cmake, using
  the %name-prefix directive inside sql_yacc.yy and sql_yacc_ora.yy instead

- Adding other CMake related changes to build sql_yacc_ora.o
  form sql_yacc_ora.yy

- Adding NUMBER(M,N) as a synonym to DECIMAL(M,N) as the first
  Oracle compatibility syntax understood in sql_mode=ORACLE.

- Adding prototypes to functions add_virtual_expression()
  and handle_sql2003_note184_exception(), so they can be used
  in both sql_yacc.yy and sql_yacc_ora.yy.

- Adding a new test suite compat/oracle, with the first test "type_number".
  Use this:
   ./mtr compat/oracle.type_number   # to run a single test
   ./mtr --suite=compat/oracle       # to run the entire new suite

- Adding compat/oracle into the list of default suites,
  so BuildBot can run it automatically on pushes.
2017-04-05 15:01:59 +04:00
Alexander Barkov
3d004de31d Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-04-05 14:47:06 +04:00
Alexander Barkov
e34acc838b Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-04-05 14:42:14 +04:00
Igor Babaev
b0395d8701 Fixed the bug mdev-12429 and its duplicates mdev-12145 and mdev-9886.
Also fixed a wrong result for a test case for mdev-7691
(the alternative one).
The test  cases for all these bug have materialized semi-joins used
inside dependent sub-queries.

The patch actually reverts the change inroduced by Monty in 2003.
It looks like this change is not valid anymore after the implementation
of semi-joins.
Adjusted output from EXPLAIN for many other test cases.
2017-04-04 10:04:52 -07:00
Sergei Petrunia
fb0b3640fe Merge branch '10.2' of github.com:MariaDB/server into bb-10.2-mariarocks 2017-04-04 17:12:06 +03:00
Alexander Barkov
d5c77fba20 Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-04-04 18:02:23 +04:00
Alexander Barkov
17309c4c12 MDEV-12303 Add Type_handler::Item_xxx_fix_length_and_dec() for CAST classes 2017-04-04 17:59:48 +04:00
Alexander Barkov
b7fb644622 Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-04-04 16:54:51 +04:00
Alexander Barkov
f1b0b04651 MDEV-12411 Remove Lex::text_string_is_7bit 2017-04-04 16:54:02 +04:00
Igor Babaev
00ab154d49 Fixed bug mdev-10454.
The patch actually fixes the old defect of the optimizer that
could not extract keys for range access from IN predicates
with row arguments.

This problem was resolved in the mysql-5.7 code. The patch
supersedes what was done there:
 - it can build range access when not all components of
 the first row argument are refer to the columns of the table
 for which the range access is constructed.
 - it can use equality predicates to build range access
 to the table that is not referred to in this argument.
2017-04-03 15:59:38 -07:00
Vladislav Vaintroub
f2dc04abea Compiling, Windows . Avoid unnecessary rebuilds with MSVC.
To export symbols from the mysqld.exe, use lib.exe with /DEF, rather than
pre-link step when building mysqld.exe.

This helps to avoid relinking all plugins, if mysqld.exe was recompiled
but the list of its exports has not changed.

Also removed unnecessary DEPENDS in some ADD_CUSTOM_COMMAND (gen_lex_token,
gen_lex_hash etc). They confuse VS generator which tends to
recreate headers and do unnecessary recompilations.
2017-04-03 18:48:48 +00:00
Alexander Barkov
15d98ddc2a Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-04-03 17:35:55 +04:00
Alexander Barkov
015868e7da Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-04-03 17:22:10 +04:00
Sergei Petrunia
5e0ed6912f Merge 10.2 into bb-10.2-mariarocks 2017-04-03 13:48:05 +03:00
Sergei Golubchik
22d8bb2706 MDEV-12421 Check constraint with query crashes server and renders DB unusable
parse CHECK constraint *before* Column_definition validity checks
2017-04-01 18:59:29 +02:00
Sergei Golubchik
143e771dee ha_start_consistent_snapshot() did not check for errors 2017-03-31 19:28:58 +02:00
Sergei Golubchik
6e899642fe move rocksdb specific changes into rocksdb 2017-03-31 19:28:57 +02:00
Sergei Golubchik
76a262cdf8 remove my_hash_const_element(), use Hash_set in C++ code 2017-03-31 19:22:19 +02:00
Sergei Golubchik
63798a6ea8 remove DB_TYPE_ROCKSDB 2017-03-31 19:22:19 +02:00
Alexander Barkov
f00a314f9a Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-03-31 16:40:29 +04:00
Sergei Golubchik
6fbcf4134a properly close the table in fill_schema_table_from_frm()
this closes the memory leak, that started to appear after da5c3e03f6
2017-03-31 14:16:28 +02:00
Alexander Barkov
2f3d4bd566 MDEV-12416 OOM in create_virtual_tmp_table() makes the server crash 2017-03-31 15:18:28 +04:00
Alexander Barkov
e191833d75 MDEV-12415 Remove sp_name::m_qname 2017-03-31 14:26:43 +04:00
Sergei Petrunia
5210c69e71 Merge 10.2 into bb-10.2-mariarocks 2017-03-31 01:14:00 +03:00
Sergei Golubchik
da4d71d10d Merge branch '10.1' into 10.2 2017-03-30 12:48:42 +02:00
Jacob Mathew
3c422e60bb MDEV-11115 CHECK constraints are not shown in I_S.TABLE_CONSTRAINTS
Added CHECK constraints to I_S.TABLE_CONSTRAINTS.
Fixed a bug regarding virtual column definitions whose name is the field name.
Added test case: check_constraint_show
2017-03-29 12:07:33 -07:00
Alexander Barkov
94d643ac22 Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-03-29 21:02:18 +04:00
Alexander Barkov
0d8dc74d30 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-03-29 20:51:54 +04:00
Igor Babaev
4ebdef2bcd Fixed bug mdev-12336.
The function Item::split_sum_func2() incorrectly processed the function
items with window functions that were not window functions themselfes
and were used as arguments of other functions.
2017-03-29 08:46:00 -07:00
Igor Babaev
f381e73f7d Fixed bug mdev-11907.
With the current design the function copy_funcs() should ignore
the items with window functions from the array **func_ptr.
2017-03-29 08:46:00 -07:00
Alexander Barkov
1694c0e8d8 MDEV-12394 Add function is_native_function_with_warn() 2017-03-29 18:15:28 +04:00
Alexander Barkov
8af5dcb0d8 MDEV-12393 Add function mysql_create_routine 2017-03-29 17:33:27 +04:00
Alexander Barkov
2361f835ae MDEV-12392 Duplicate code cleanup: add function normalize_db_name() 2017-03-29 17:22:49 +04:00
Alexander Barkov
fb43180c4f Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-03-29 07:24:05 +04:00
Alexander Barkov
c5520a37d6 MDEV-12390 Wrong error line numbers reported with sql_mode=IGNORE_SPACE 2017-03-29 07:21:34 +04:00
Sergei Golubchik
7a1b0582d6 MDEV-11114 Cannot drop column referenced by CHECK constraint: Unknown column 'a' in 'virtual column function'
clarify the error message
2017-03-29 00:40:21 +02:00
Sergei Golubchik
33ec445975 MDEV-10370 Check constraints on virtual columns fails on INSERT when column not specified
add columns needed for CHECK constraints not only to read_set,
but also to vcol_set.
2017-03-29 00:40:21 +02:00
Sergei Golubchik
98a5ee9d75 MDEV-12105 MySQL 5.7 and MariaDB 10.2 error codes are out of sync 2017-03-29 00:40:21 +02:00
Sergei Golubchik
bf40e8069c MDEV-11059 don't build the server with jemalloc
don't build the server with jemalloc.
only build tokudb with it.
move tokudb into a separate package, because it brings a new dependency
2017-03-29 00:40:21 +02:00
Alexey Botchkov
da5c3e03f6 MDEV-9255 Add generation_expression to information_schema.columns.
Added IS_GENERATED and GENERATION_EXPRESSION columns required by
        the SQL standard
2017-03-28 23:36:33 +04:00
Igor Babaev
93dd70ced8 Fixed bug mdev-12375.
The function st_select_lex_unit::exec_recursive() incorrectly determined
that a CTE mutually recursive with some others was stabilized in the case
when the non-recursive part of the CTE returned an empty set. As a result
the server fell into an infinite loop when executing a query using
this CTE.
2017-03-27 14:41:17 -07:00
Igor Babaev
ad7da60ded Fixed bug mdev-12368.
Mutually recursive CTE could cause a crash of the server in the case
when they were not Standard compliant. The crash happened in
mysql_derived_prepare(), because the destructor the derived_result
object created for a CTE that was mutually recursive with some others
was called twice. Yet this destructor should not be called for resursive
references.
2017-03-26 23:00:28 -07:00
Igor Babaev
5a4537f092 Fixed bug mdev-12360.
The method With_element::check_unrestricted_recursive() icorrectly performed
the check that no recursive reference is not encountered in inner parts of
outer joins. As a result the server reported errors for valid specifications
with outer joins.
2017-03-26 23:00:28 -07:00
Alexander Barkov
ab96710bb7 Merge remote-tracking branch 'origin/bb-10.2-ext' into 10.3 2017-03-24 18:48:40 +04:00
Alexander Barkov
48c59f394b MDEV-12338 Split Item_type_holder::get_real_type() into virtual Item::real_type_handler() 2017-03-24 17:52:55 +04:00
Alexander Barkov
1b3bd00c6b Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-03-24 16:14:30 +04:00
Alexander Barkov
a1e5201488 MDEV-12357 Invalid read of size 8 in Type_aggregator::Type_aggregator() 2017-03-24 15:59:58 +04:00
Vladislav Vaintroub
716188f1d4 Fix some warnings on Windows compilation
- silence warnings in ed25519 reference implementation
- fix signed/unsigned warning in popular header item_func.h
2017-03-24 10:10:36 +01:00
Vladislav Vaintroub
e5b67a46bc MDEV-12345 Performance : replace calls to clock() inside trx_start_low() by THD::start_utime 2017-03-23 11:50:22 +00:00
Sergey Vojtovich
af22a70df9 MDEV-11418 - AliSQL: [Feature] Issue#1 KILL IDLE TRANSACTIONS
Terminate idle transactions safely in server layer by setting up socket timeout
parameter. Percona provides another patch to resolve similar problem, but it
calls server layer's callback in InnoDB plugin to close THD, which crashes in
some testcases. See https://bugs.launchpad.net/percona-server/+bug/901060 for
more detailed information.

  1. export parameter trx_idle_timeout to handle all kinds of transactions, the priority is highest
  2. export parameter trx_readonly_idle_timeout to handle read-only transactions
  3. export parameter trx_changes_idle_timeout to handle read-write transactions
2017-03-22 19:08:24 +04:00
Sergey Vojtovich
8026cd6202 MDEV-11379, MDEV-11388 - [WAIT n|NOWAIT]
Extended syntax so that it is now possible to set lock_wait_timeout for the
following statements:
SELECT ... FOR UPDATE [WAIT n|NOWAIT]
SELECT ... LOCK IN SHARED MODE [WAIT n|NOWAIT]
LOCK TABLE ... [WAIT n|NOWAIT]
CREATE ... INDEX ON tbl_name (index_col_name, ...) [WAIT n|NOWAIT] ...
ALTER TABLE tbl_name [WAIT n|NOWAIT] ...
OPTIMIZE TABLE tbl_name [WAIT n|NOWAIT]
DROP INDEX ... [WAIT n|NOWAIT]
TRUNCATE TABLE tbl_name [WAIT n|NOWAIT]
RENAME TABLE tbl_name [WAIT n|NOWAIT] ...
DROP TABLE tbl_name [WAIT n|NOWAIT] ...

Valid range of lock_wait_timeout and innodb_lock_wait_timeout was extended so
that 0 is acceptable value (means no wait).

This is amended AliSQL patch. We prefer Oracle syntax for [WAIT n|NOWAIT]
instead of original [WAIT [n]|NO_WAIT].
2017-03-22 19:08:24 +04:00
Alexey Botchkov
92f18bdede MDEV-11177 mysqlbinlog exits silently without error when another
instance connects to server.

        New thread kill status added KILL_SLAVE_SAME_ID, and the related
        error message.
2017-03-22 01:48:22 +04:00
Sergei Golubchik
09a2107b1b Merge branch '10.0' into 10.1 2017-03-21 19:20:44 +01:00
Sergei Golubchik
0d622bed4f Merge branch '5.5' into 10.0 2017-03-21 11:35:50 +01:00
Alexey Botchkov
76f6c1e1ed MDEV-12262 Assertion `!null_value' failed in virtual bool Item::send on
JSON_REMOVE.

        null_value wasn't properly set in Item_json_func_remove::val_str.
2017-03-20 15:18:06 +04:00
Alexander Barkov
552072e4d1 MDEV-12239 Add Type_handler::Item_sum_{sum|avg|variance}_fix_length_and_dec() 2017-03-19 23:39:42 +04:00
Alexander Barkov
7d0c354f5c Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-03-18 14:20:06 +04:00
Vladislav Vaintroub
8efdf89e42 MDEV-12126 Correct German error message. 2017-03-17 20:07:39 +00:00
Vladislav Vaintroub
6c5cfbbf33 Fix crash (race condition) in DBUG in connect2 test case.
When "simulate_failed_connection_1"  DBUG keyword is set, current thread's
DBUG stack points to global variable in dbug (init_settings).
This global variable could be overriden while current THD is still active,
producing crash in worst scenario.

Added DBUG_SET()so that the current thread own dbug
context that cannot concurrently modified by anyone else.
2017-03-17 19:20:08 +00:00
Vladislav Vaintroub
66905f6dcb Fix several compile warnings on Windows 2017-03-17 08:56:57 +00:00
Monty
2d0c579a86 Wait for slave threads to start during startup
- Before this patch during startup all slave threads was started without
  any check that they had started properly.
- If one did a START SLAVE, STOP SLAVE or CHANGE MASTER as first command to the server
  there was a chance that server could access structures that where not
  properly  initialized which could lead to crashes in
  Log_event::read_log_event
- Fixed by waiting for slave threads to start up properly also during
  server startup, like we do with START SLAVE.
2017-03-16 14:21:33 +02:00
Monty
e7f55fde88 Removed wrong assert
The following is an updated commit message for the following commit
that was pushed before I had a chance to update the commit message:
c5e25c8b40

Fixed dead locks when doing stop slave while slave was starting.

- Added a separate lock for protecting start/stop/reset of a specific slave.
  This solves some possible dead locks when one calls stop slave while
  the slave is starting as the old run_locks was over used for other things.
- Set hash->records to 0 before calling free of all hash elements.
  This was set to stop concurrent threads to loop over hash elements and
  access members that was already freed.
  This was a problem especially in start_all_slaves/stop_all_slaves
  as the mutex protecting the hash was temporarily released while a slave
  was started/stopped.
- Because of change to hash->records during hash_reset(),
  any_slave_sql_running() will return 1 during shutdown as one can't
  loop over master_info_index->master_info_hash while hash_reset() of it
  is in progress.
  This also fixes a potential old bug in any_slave_sql_running() where
  during shutdown and ~Master_info_index(), my_hash_free() we could
  potentially try to access elements that was already freed.
2017-03-16 14:21:32 +02:00
Oleksandr Byelkin
4c6ae99285 Merge branch 'bb-10.2-ext' into 10.3-merge-10.2-ext 2017-03-16 11:21:06 +01:00
Sergei Golubchik
2c2bd8c155 MDEV-12261 build failure without P_S
restore mysql_file_delete_with_symlink() but let it use
new my_handler_delete_with_symlink() mysys helper.
2017-03-15 17:48:30 +01:00
Varun Gupta
6ac754163c MDEV-10766: Queries which start with WITH clause do not get inserted into query cache
Added conditions so that the WITH queries are also added to the query cache
2017-03-15 20:15:31 +05:30
Eric Herman
6a9e2e1979 fix 32bit redefine of char_to_byte_length_safe (#337)
* fix 32bit redefine of char_to_byte_length_safe

Error can be seen here: https://hastebin.com/azomatocoq.scala

sql/item.h: defined uint32 char_to_byte_length_safe(size_t, uint32)
sql/sql_type.h: defined uint32 char_to_byte_length_safe(uint32, uint32)

As @knielsen observed, C++ overloading allows this on 64bit
 because size_t and uint32 differ.

Since item.h does a #include "sql_type.h", there is no point in
redifining this function in item.h

* avoid -Wconversion warnings, fix spacing; thanks @svoj

From IRC:
<svoj> EricHerman: nice, thanks! I believe we also should use function body as in item.h. It was fixed by dr-m recently.
<EricHerman> svoj, so you suggest the "return tmp > UINT_MAX32 ? UINT_MAX32 : static_cast<uint32>(tmp);"
<EricHerman> I can use that, sure.
<svoj> EricHerman: yes, please! And fix indentation on these lines (should be 2 spaces instead of 3).
<svoj> EricHerman: the patch where this hunk comes from: git show 89d80c1b0 sql/item.h
2017-03-15 17:30:27 +04:00
Oleksandr Byelkin
122d0701f7 MDEV-11761: CLIENT_DEPRECATE_EOF : Client must identify a "stored procedure output resultset"
fix proposed by Diego
2017-03-15 13:45:14 +01:00
Alexey Botchkov
af6eee1fc5 MDEV-11833 JSON functions don't seem to respect max_allowed_packet.
Now let's check JSON length to fit the max_allowed packet.
2017-03-14 17:31:14 +04:00
Alexey Botchkov
d0e8b427a1 MDEV-12078 Using spatial index changes type from point to geometry
In get_mm_tree we have to change Field_geom::geom_type to
        GEOMETRY as we have to let storing all types of the spatial features
        in the field. So now we restore the original geom_type as it's
        done.
2017-03-14 16:35:39 +04:00
Varun Gupta
adbe1c5fe9 MDEV-6486: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))'
failed with SELECT SQ, TEXT field

The functon find_all_keys does call Item_subselect::walk, which calls walk() for the subquery
The issue is that when a field is represented by Item_outer_ref(Item_direct_ref(Item_copy_string( ...))).
Item_copy_string does have a pointer to an Item_field in Item_copy::item but does not implement Item::walk method, so we are not
able to set the bitmap for that field. This is the reason why the assert fails.

Fixed by adding the walk method to Item_copy class.
2017-03-14 17:31:29 +05:30
Alexey Botchkov
7c7c0696e7 MDEV-11856 json_search doesn't search for values with double quotes
character (").

        The my_wildcmp function doesn't expect the string parameter to
        have escapements, only the template. So the string
        should be unescaped if necessary.
2017-03-14 15:25:02 +04:00
Oleksandr Byelkin
05d3c3d3f7 MDEV-10141: Add support for INTERSECT (and common parts for EXCEPT)
MDEV-10140: Add support for EXCEPT
2017-03-14 11:52:00 +01:00
Vladislav Vaintroub
98be67266d Fix truncation of affected rows and insert id in select_insert::send_ok_packet 2017-03-13 23:13:24 +00:00
Vicențiu Ciorbaru
06f1f1aa6e Make ELOOP be considered a File Not Found error when it comes from handlerton
Fix symlink-aria && symlink-myisam to account for this possibility.
2017-03-14 00:25:26 +02:00