Commit graph

2234 commits

Author SHA1 Message Date
Oleksandr Byelkin
7aa09a5ed2 MDEV-10141: Add support for INTERSECT (and common parts for EXCEPT)
MDEV-10140: Add support for EXCEPT
2017-03-13 12:07:47 +01:00
Alexander Barkov
ec8c38a82e Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-03-08 23:47:20 +04:00
Marko Mäkelä
89d80c1b0b Fix many -Wconversion warnings.
Define my_thread_id as an unsigned type, to avoid mismatch with
ulonglong.  Change some parameters to this type.

Use size_t in a few more places.

Declare many flag constants as unsigned to avoid sign mismatch
when shifting bits or applying the unary ~ operator.

When applying the unary ~ operator to enum constants, explictly
cast the result to an unsigned type, because enum constants can
be treated as signed.

In InnoDB, change the source code line number parameters from
ulint to unsigned type. Also, make some InnoDB functions return
a narrower type (unsigned or uint32_t instead of ulint;
bool instead of ibool).
2017-03-07 19:07:27 +02:00
Alexander Barkov
47b7ffb396 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-02-27 10:07:59 +04:00
Nirbhay Choubey
185d140f19 MDEV-7635: Renamed standards_compliant_cte to standard_compliant_cte 2017-02-10 06:30:42 -05:00
Oleksandr Byelkin
25f6d1dad7 Unused code removed. 2017-02-10 10:22:03 +01:00
Oleksandr Byelkin
ae3072c0af MDEV-10554: Assertion `!derived->first_select()->exclude_from_table_unique_test || derived->outer_select()-> exclude_from_table_unique_test' failed in TABLE_LIST::set_check_merged()
Mark and check excluded because of merging derived tables and views.
2017-02-10 10:22:03 +01:00
Alexander Barkov
1c1d8fe9e4 Moving LEX::set_last_field_type() to Column_definition::set_attributes()
This is an extraction from the patch for MDEV-10577, which is not
directly related to %TYPE implementation. This patch does the following:
- Moves LEX::set_last_field_type() to Column_definition::set_attributes()
- Adds initialization of Column_definition members length, decimals,
  charset, on_update into the constructor.
- Column_definition::set_attributes() now does not set length and decimal
  to 0 any more, as they are not initialized in the constructor.
- Move Column_definition::prepare_interval_field() from field.h to field.cc,
  as it's too huge.
2016-12-16 18:33:57 +04:00
Alexander Barkov
352ff9cc96 MDEV-11347 Move add_create_index_prepare(), add_key_to_list(), set_trigger_new_row(), set_local_variable(), set_system_variable(), create_item_for_sp_var() as methods to LEX
Moving another banch of functions implemented in sql_yacc.yy as methods to LEX,
to be able to reuse them between sql_yacc.yy and sql_yacc_ora.yy easier.
The list of functions:
- add_create_index_prepare()
- add_key_to_list()
- set_trigger_new_row()
- set_local_variable()
- set_system_variable()
- create_item_for_sp_var()
2016-12-16 18:23:21 +04:00
Alexander Barkov
4b4efb0485 MDEV-11346 Move functions case_stmt_xxx and add_select_to_union_list as methods to LEX
The full list of functions moved:
int case_stmt_action_expr(LEX *, Item* expr);
int case_stmt_action_when(LEX *, Item *when, bool simple);
int case_stmt_action_then(LEX *);
bool add_select_to_union_list(LEX *,bool is_union_distinct,  bool is_top_level);

This is a preparatory change for "MDEV-10142 PL/SQL parser",
to reuse the code easier between sql_yacc.yy and coming soon sql_yacc_ora.yy.
2016-12-16 18:23:20 +04:00
Sergei Golubchik
a3614d33e8 cleanup: FOREIGN_KEY_INFO
instead of returning strings for CASCADE/RESTRICT
from every storage engine, use enum values
2016-12-12 20:27:39 +01:00
Sergei Golubchik
94462aa9e6 bugfix: remove broken insert t values () optimization
* wrong results for 5.7 and 10.1- vcols, and for indexed vcols
* only helps in rare cases and only minimally
2016-12-12 20:27:39 +01:00
Igor Babaev
665045f985 Fixed bug mdev-11081.
The idea of this fix was taken from the patch by Roy Lyseng
for mysql-5.6 bug iBug#14740889: "Wrong result for aggregate
functions when executing query through cursor".

Here's Roy's comment for his patch:
"
The problem was that a grouped query did not behave properly when
executed using a cursor. On further inspection, the query used one
intermediate temporary table for the grouping.
Then, Select_materialize::send_result_set_metadata created a temporary
table for storing the query result. Notice that get_unit_column_types()
is used to retrieve column meta-data for the query. The items contained
in this list are later modified so that their result_field points to
the row buffer of the materialized temporary table for the cursor.
But prior to this, these result_field objects have been prepared for
use in the grouping operation, by JOIN::make_tmp_tables_info(), hence
the grouping operation operates on wrong column buffers.

The problem is solved by using the list JOIN::fields when copying data
to the materialized table. This list is set by JOIN::make_tmp_tables_info()
and points to the columns of the last intermediate temporary table of
the executed query. For a UNION, it points to the temporary table
that is the result of the UNION query.

Notice that we have to assign a value to ::fields early in JOIN::optimize()
in case the optimization shortcuts due to a const plan detection.

A more optimal solution might be to avoid creating the final temporary
table when the query result is already stored in a temporary table.
"
The patch does not contain a test case, but the description of the
problem corresponds exactly what could be observed in the test
case for mdev-11081.
2016-11-21 10:33:39 -08:00
Alexander Barkov
39d2c7b18d Removing LEX::interval_list, as it's not used since parser cleanups
made in 227510e039.
We now use lex->last_field->interval_list directly instead.
2016-10-27 06:37:21 +04:00
Kristian Nielsen
e1ef99c3dc MDEV-7145: Delayed replication
Merge feature into 10.2 from feature branch.

Delayed replication adds an option

  CHANGE MASTER TO master_delay=<seconds>

Replication will then delay applying events with that many
seconds. This creates a replication slave that reflects the state of
the master some time in the past.

Feature is ported from MySQL source tree.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2016-10-16 23:44:44 +02:00
Kristian Nielsen
19abe79fd1 MDEV-7145: Delayed replication, intermediate commit.
Initial merge of delayed replication from MySQL git.

The code from the initial push into MySQL is merged, and the
associated test case passes. A number of tasks are still pending:

1. Check full test suite run for any regressions or .result file updates.

2. Extend the feature to also work for parallel replication.

3. There are some todo-comments about future refactoring left from
MySQL, these should be located and merged on top.

4. There are some later related MySQL commits, these should be checked
and merged. These include:
    e134b9362ba0b750d6ac1b444780019622d14aa5
    b38f0f7857c073edfcc0a64675b7f7ede04be00f
    fd2b210383358fe7697f201e19ac9779879ba72a
    afc397376ec50e96b2918ee64e48baf4dda0d37d

5. The testcase from MySQL relies heavily on sleep and timing for
testing, and seems likely to sporadically fail on heavily loaded test
servers in buildbot or distro build farms.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2016-10-14 23:15:58 +02:00
Alexander Barkov
46dc7bdf1d MDEV-10866 Extend PREPARE and EXECUTE IMMEDIATE to understand expressions
MDEV-10867 PREPARE..EXECUTE is not consistent about non-ASCII characters
2016-10-08 13:06:15 +04:00
Alexander Barkov
e1a212ebbc MDEV-10585 EXECUTE IMMEDIATE statement 2016-10-08 12:32:52 +04:00
Alexander Barkov
4c45b820aa MDEV-10709 Expressions as parameters to Dynamic SQL 2016-10-08 11:50:18 +04:00
Monty
8be53a389c MDEV-6112 multiple triggers per table
This is similar to MysQL Worklog 3253, but with
a different implementation. The disk format and
SQL syntax is identical with MySQL 5.7.

Fetures supported:
- "Any" ammount of any trigger
- Supports FOLLOWS and PRECEDES to be
  able to put triggers in a certain execution order.

Implementation details:
- Class Trigger added to hold information about a trigger.
  Before this trigger information was stored in a set of lists in
  Table_triggers_list and in Table_triggers_list::bodies
- Each Trigger has a next field that poinst to the next Trigger with the
  same action and time.
- When accessing a trigger, we now always access all linked triggers
- The list are now only used to load and save trigger files.
- MySQL trigger test case (trigger_wl3253) added and we execute these
  identically.
- Even more gracefully handling of wrong trigger files than before. This
  is useful if a trigger file uses functions or syntax not provided by
  the server.
- Each trigger now has a "Created" field that shows when the trigger was
  created, with 2 decimals.

Other comments:
- Many of the changes in test files was done because of the new "Created"
  field in the trigger file. This shows up in SHOW ... TRIGGER and when
  using information_schema.trigger.
- Don't check if all memory is released if on uses --gdb;  This is needed
  to be able to get a list from safemalloc of not freed memory while
  debugging.
- Added option to trim_whitespace() to know how many prefix characters
  was skipped.
- Changed a few ulonglong sql_mode to sql_mode_t, to find some wrong usage
  of sql_mode.
2016-10-05 01:11:07 +03:00
Igor Babaev
1f1990a161 Fixed bug mdev-10884.
If a materialized derived table / view is specified by a unit
with SELECTs containing ORDER BY ... LIMIT then condition pushdown
cannot be done for these SELECTs.
If a materialized derived table / view is specified by a unit
containing global ORDER BY ... LIMIT then condition pushdown
cannot be done for this unit.
2016-09-25 17:29:10 -07:00
Igor Babaev
c22d307afa Fixed bug mdev-10785.
The condition pushed into WHERE/HAVING of a materialized
view/derived table may differ for different executions of
the same prepared statement. That's why the should be
ANDed with the existing WHERE/HAVING conditions only after all
permanent transformations of these conditions has been
performed.
2016-09-14 01:06:45 -07:00
Igor Babaev
a2b8bdfbb9 Merge branch '10.2' into bb-10.2-mdev9864 2016-09-07 15:49:56 -07:00
Alexander Barkov
dd283db6bc MDEV-8909 union parser cleanup
This is the final patch removing some old remainders that are
not needed anymore.

(Other clean-ups were done in earlier commits)
2016-09-07 11:36:22 +04:00
Igor Babaev
2c6d620019 Merge branch '10.2' into bb-10.2-mdev9864 2016-09-06 10:57:14 -07:00
Alexey Botchkov
225440047d MDEV-10421 duplicate CHECK CONSTRAINTs.
mysql_prepare_create_table fixed so it doesn't let duplicating
        constraint names. Syntax for CONSTRAINT IF NOT EXISTS added
        and handled in mysql_alter_table.
2016-09-06 14:42:33 +04:00
Igor Babaev
8ae65920fa Fixed bug mdev-10737.
This bug in st_select_lex_node::move_node could result
in invalid select lists in recursive units that could
cause falling into infinite loops when iterating over
selects in such units.
2016-09-05 23:07:31 -07:00
Igor Babaev
7faff4de82 Merge branch '10.2' into 10.2-mdev9197 2016-09-04 20:42:07 -07:00
Igor Babaev
3b40f78ede Fixed a flaw in the implementation of condition push-down
for materialized views and derived tables: there were no
push-down if the view was defined as union of selects
without aggregation. Added test cases with such unions.

Adjusted result files after the merge of the code for mdev-9197.
2016-09-04 20:11:58 -07:00
Oleksandr Byelkin
1da21cd4a5 MDEV-10035: DBUG_ASSERT on CREATE VIEW v1 AS SELECT * FROM t1 FOR UPDATE
Ability to print lock type added.
Restoring correct lock type for CREATE VIEW added.
2016-09-04 14:15:21 +02:00
Igor Babaev
3fb4f9bb93 Merge branch '10.2-mdev9197-cons' of github.com:shagalla/server
into branch 10.2-mdev9197.
2016-08-31 16:16:54 -07:00
Igor Babaev
2250e9ea26 Merge 10.2 into 10.2-mdev9864. 2016-08-30 16:14:51 -07:00
Igor Babaev
c8f85bf263 mdev-9864: cleanup, re-factoring.
Added comments.
2016-08-26 16:09:22 -07:00
Galina Shalygina
eb2c147475 The consolidated patch for mdev-9197. 2016-08-23 00:39:12 +03:00
Igor Babaev
2f9555c40f Removed the parameter from st_select_lex_unit::exec_recursive.
Moved checking whether the limit set for the number of iterations
when executing a recursive query has been reached from
st_select_lex_unit::exec_recursive to TABLE_LIST::fill_recursive.
Changed the name of the system variable max_recursion_level for
max_recursive_iterations.
Adjusted test cases.
2016-08-10 15:51:40 -07:00
Igor Babaev
f982d1074a Fixed the following problem:
Temporary tables created for recursive CTE
were instantiated at the prepare phase. As
a result these temporary tables missed
indexes for look-ups and optimizer could not
use them.
2016-07-26 22:58:33 -07:00
Sergei Golubchik
8f9530a9ab revert second lookahead in the lexer
it's not enough to look for NOT NULL IS, this also fails queries like
SELECT NOT NULL <=> NULL;
and adds no value anymore, as the grammar now requires parentheses
2016-06-30 11:43:02 +02:00
Sergei Golubchik
f93a2a3b3b various cleanups
* remove a confusing method name - Field::set_default_expression()
* remove handler::register_columns_for_write()
* rename stuff
* add asserts
* remove unlikely unlikely
* remove redundant if() conditions
* fix mark_unsupported_function() to report the most important violation
* don't scan vfield list for default values (vfields don't have defaults)
* move handling for DROP CONSTRAINT IF EXIST where it belongs
* don't protect engines from Alter_inplace_info::ALTER_ADD_CONSTRAINT
* comments
2016-06-30 11:43:02 +02:00
Michael Widenius
fb67cde237 Use default character set for expressions
- Force usage of () around complex DEFAULT expressions
- Give error if DEFAULT expression contains invalid characters
- Don't use const_charset_conversion for stored Item_func_sysconf expressions
  as the result is not constaint over different executions
- Fixed Item_func_user() to not store calculated value in str_value
2016-06-30 11:43:02 +02:00
Michael Widenius
db7edfed17 MDEV-7563 Support CHECK constraint as in (or close to) SQL Standard
MDEV-10134 Add full support for DEFAULT

- Added support for using tables with MySQL 5.7 virtual fields,
  including MySQL 5.7 syntax
- Better error messages also for old cases
- CREATE ... SELECT now also updates timestamp columns
- Blob can now have default values
- Added new system variable "check_constraint_checks", to turn of
  CHECK constraint checking if needed.
- Removed some engine independent tests in suite vcol to only test myisam
- Moved some tests from 'include' to 't'. Should some day be done for all tests.
- FRM version increased to 11 if one uses virtual fields or constraints
- Changed to use a bitmap to check if a field has got a value, instead of
  setting HAS_EXPLICIT_VALUE bit in field flags
- Expressions can now be up to 65K in total
- Ensure we are not refering to uninitialized fields when handling virtual fields or defaults
- Changed check_vcol_func_processor() to return a bitmap of used types
- Had to change some functions that calculated cached value in fix_fields to do
  this in val() or getdate() instead.
- store_now_in_TIME() now takes a THD argument
- fill_record() now updates default values
- Add a lookahead for NOT NULL, to be able to handle DEFAULT 1+1 NOT NULL
- Automatically generate a name for constraints that doesn't have a name
- Added support for ALTER TABLE DROP CONSTRAINT
- Ensure that partition functions register virtual fields used. This fixes
  some bugs when using virtual fields in a partitioning function
2016-06-30 11:43:02 +02:00
Igor Babaev
9606525666 Simplified the code that fills recursive tables. 2016-06-25 21:38:40 -07:00
Oleksandr Byelkin
7166069537 MDEV-3944: Allow derived tables in VIEWS 2016-05-28 14:44:21 +02:00
Galina Shalygina
6c6c3af6aa Merge branch '10.2' into 10.2-mdev9864 2016-05-25 00:34:13 +03:00
Galina Shalygina
b4f1f42062 Fixed the problem of wrong identification of WITH tables defined in WITH clauses without RECURSIVE.
Added test cases to check the fix.
Fixed the problem of wrong types of recursive tables when the type of anchor part does not coincide with the
type of recursive part.
Prevented usage of marerialization and subquery cache for subqueries with recursive references.
Introduced system variables 'max_recursion_level'.
Added a test case to test usage of this variable.
2016-05-24 21:29:52 +03:00
Alexander Barkov
9a25c01f78 MDEV-10102 Disallow CREATE VIEW .. PROCEDURE ANALYSE() syntactically 2016-05-23 16:25:51 +04:00
Galina Shalygina
46a2e41398 Fixed many problems in the code of With_element::check_unrestricted_recursive().
Added the check whether there are set functions in the specifications of recursive CTE.
Added the check whether there are recursive references in subqueries.
Introduced boolean system variable 'standards_compliant_cte'. By default it's set to 'on'.
When it's set to 'off' non-standard compliant CTE can be executed.
2016-05-19 22:07:53 +03:00
Galina Shalygina
f516b966e1 Main patch for mdev-9864 2016-05-09 23:39:10 +03:00
Galina Shalygina
be1d06c8a5 Merge branch '10.2' into 10.2-mdev9864 2016-05-08 23:04:41 +03:00
Igor Babaev
3b6a64c247 Fixed bug mdev-9937.
When the specification of a WITH table referred to a view
that used a based table with the same name as the WITH table
the server went into an infinite loop because it erroneously
resolved the reference to the base table as the reference to
the WITH table.

With tables used in a view cannot be searched for beyond the
scope the view.
2016-04-20 10:55:53 -07:00
Sergei Petrunia
fbf0364c26 MDEV-9780: Window functions: interplay between window function and other constructs
Implement the "DISTINCT must not be converted into GROUP BY when window
functions are present" part.
2016-04-10 17:22:24 +02:00