Commit graph

3503 commits

Author SHA1 Message Date
Alexander Barkov
45e40892c5 MDEV-11134 Assertion `fixed' failed in Item::const_charset_converter(THD*, CHARSET_INFO*, bool, const char*)
Problem: Item_param::basic_const_item() returned true when fixed==false.
This unexpected combination made Item::const_charset_converter() crash
on asserts.

Fix:
- Changing all Item_param::set_xxx() to set "fixed" to true.
  This fixes the problem.
- Additionally, changing all Item_param::set_xxx() to set
  Item_param::item_type, to avoid duplicate code, and for consistency,
  to make the code symmetric between different constant types.
  Before this patch only set_null() set item_type.
- Moving Item_param::state and Item_param::item_type from public to private,
  to make sure easier that these members are in sync with "fixed" and to
  each other.
- Adding a new argument "unsigned_arg" to Item::set_decimal(),
  and reusing it in two places instead of duplicate code.
- Adding a new method Item_param::fix_temporal() and reusing it in two places.
- Adding methods has_no_value(), has_long_data_value(), has_int_value(),
  instead of direct access to Item_param::state.
2017-01-23 22:25:29 +04:00
Marko Mäkelä
b05bf8ff0f Merge 10.1 to 10.2.
Most notably, this includes MDEV-11623, which includes a fix and
an upgrade procedure for the InnoDB file format incompatibility
that is present in MariaDB Server 10.1.0 through 10.1.20.

In other words, this merge should address
MDEV-11202 InnoDB 10.1 -> 10.2 migration does not work
2017-01-19 12:06:13 +02:00
Alexander Barkov
ebb8c9fb26 MDEV-11030 Assertion `precision > 0' failed in decimal_bin_size
Fixing Item::decimal_precision() to return at least one digit.
This fixes the problem reported in MDEV.

Also, fixing Item_func_signed::fix_length_and_dec() to reserve
space for at least one digit (plus one character for an optional sign).
This is needed to have CONVERT(expr,SIGNED) and CONVERT(expr,UNSIGNED)
create correct string fields when they appear in string context, e.g.:
  CREATE TABLE t1 AS SELECT CONCAT(CONVERT('',SIGNED));
2017-01-12 16:37:58 +04:00
Sergei Golubchik
4a5d25c338 Merge branch '10.1' into 10.2 2016-12-29 13:23:18 +01:00
Igor Babaev
9b27d3e86e Fixed bug mdev-11608.
The fix for bug mdev-11488 introduced the virtual method
convert_to_basic_const_item for the class Item_cache.
The implementation of this method for the class Item_cache_str
was not quite correct: the server could crash if the cached item
was null.
A similar problem could appear for the implementation of
this method for the class Item_cache_decimal. Although I could not
reproduce the problem I decided to change the code appropriately.
2016-12-20 11:08:50 -08:00
Igor Babaev
441fa0056d Fixed bug mdev-11488.
The patch for bug mdev-10882 tried to fix it by providing an
implementation of the virtual method build_clone for the class
Item_cache. It's turned out that it is not easy provide a valid
implementation for Item_cache::build_clone(). At the same time
if the condition that can be pushed into a materialized view
contains a cached item this item can be substituted for a basic
constant of the same value. In such a way we can avoid building
proper clones for Item_cache objects when constructing pushdown
conditions.
2016-12-14 10:13:52 -08:00
Sergei Golubchik
180065ebb0 Item::print(): remove redundant parentheses
by introducing new Item::precedence() method and using it
to decide whether parentheses are required
2016-12-12 20:44:41 +01:00
Sergei Golubchik
2a0f7a34d6 bugfix: non-deterministic vcols in partitioning 2016-12-12 20:35:50 +01:00
Sergei Golubchik
a72f1deb2d rename Virtual_column_info::expr_item
now, when expr_str is gone, expr_item can be unambiguously
renamed to expr.
2016-12-12 20:35:48 +01:00
Sergei Golubchik
a411d7f4f6 store/show vcols as item->print()
otherwise we'd need to store sql_mode *per vcol*
(consider CREATE INDEX...) and how SHOW CREATE TABLE would
support that?

Additionally, get rid of vcol::expr_str, just to make sure
the string is always generated and never leaked in the
original form.
2016-12-12 20:35:41 +01:00
Sergei Golubchik
a418c99200 gcol mysql-test suite from 5.7
update tests and results, fix bugs
2016-12-12 20:27:36 +01:00
Sergei Golubchik
c2b2cb8acd TABLE::update_virtual_field to compute just one vcol
will be used later by storage engines (e.g. in MyISAM repair or in
InnoDB purge)
2016-12-12 20:27:35 +01:00
Sergei Golubchik
a632df9de0 improve Item_field::register_field_in_read_map()
make it to work when read_set == vcol_set, that is, when
the caller wants to get a one complete bitmap of all fields
a particular vcol depends on.
2016-12-12 20:27:32 +01:00
Sergei Golubchik
2f20d297f8 Merge branch '10.0' into 10.1 2016-12-11 09:53:42 +01:00
Sergei Golubchik
3e8155c637 Merge branch '5.5' into 10.0 2016-12-09 16:33:48 +01:00
Oleksandr Byelkin
d67ef7a2fb MDEV-10663: Use of Inline table columns in HAVING clause throws 1463 Error
check for VIEW/DERIVED fields
2016-12-06 19:34:25 +01:00
Alexander Barkov
46dee0d184 MDEV-10717 Assertion `!null_value' failed in virtual bool Item::send(Protocol*, String*)
The problem was that null_value was not set to "false" on a well-formed row.
If an ill-formed row was followed by a well-forned row, null_value remained
"true" in the call of Item::send() for the well-formed row.
2016-12-06 06:54:52 +04:00
Oleksandr Byelkin
098dff10ba MDEV-11359 Implement IGNORE for bulk operation 2016-11-29 08:29:46 +01:00
Alexander Barkov
9bfde897c3 MDEV-11360 Dynamic SQL: DEFAULT as a bind parameter
This patch adds DEFAULT as a possible dynamic SQL parameter, e.g.:
  EXECUTE IMMEDIATE 'INSERT INTO t1 (column) VALUES(?)' USING DEFAULT;
  EXECUTE IMMEDIATE 'UPDATE t1 SET column=?' USING DEFAULT;
and for similar PREPARE..EXECUTE queries.

This is done for symmetry with the STMT_INDICATOR_DEFAULT indicator in
the client-server PS protocol.

The changes include:
- Allowing DEFAULT as a possible option in execute USING clause (sql_yacc.yy)
- Adding "virtual bool Item::save_in_param(THD *thd, Item_param *param)",
  because "normal" items (that have real values) and Item_default_value
  have now different actions when assigning itself as an Item_param value.
- Fixing switch() statements in a few Item_param methods not to have "default",
  because it was easy to forget to add a new "case" when adding a new XXX_VALUE
  value into the enum Item_param::enum_item_param_state.
  This is important, as we'll be adding new values soon, e.g. for MDEV-11359.
  Removing "default" helped to find and report bugs MDEV-11361 and MDEV-11362,
  because DECIMAL_VALUE is obviously not properly handled in some cases.
2016-11-27 18:21:18 +04:00
Oleksandr Byelkin
e2d6912609 MDEV-9114: Bulk operations (Array binding)
(+ default values)
2016-11-02 15:07:52 +01:00
Alexey Botchkov
201c1e0f29 MDEV-9143 JSON_xxx functions.
Item_bool fixed to behave smarter with NOT operation.
2016-10-25 10:09:33 +04:00
Alexander Barkov
4c45b820aa MDEV-10709 Expressions as parameters to Dynamic SQL 2016-10-08 11:50:18 +04:00
Alexander Barkov
8ea2e143f0 MDEV-10772 Introduce Item_param::CONVERSION_INFO 2016-10-08 09:57:35 +04:00
Monty
7b96416f3c Use sql_mode_t for sql_mode.
This fixed several cases where we where using just ulong for sql_mode
2016-10-05 01:11:08 +03: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
Sergei Golubchik
66d9696596 Merge branch '10.0' into 10.1 2016-09-28 17:55:28 +02:00
Sergei Golubchik
77ce4ead81 Merge branch '5.5' into 10.0 2016-09-27 09:21:19 +02:00
Vicențiu Ciorbaru
5cb568786a MDEV-10669: Crash in SELECT with window function used
Make sure to call split_sum_func on all items that contain window
functions, so that all the column references are set up correctly.
2016-09-24 15:12:34 +02:00
Vicențiu Ciorbaru
2857ff3c98 MDEV-10815: Window Function Expressions Wrong Results
Fix window function expressions such as win_func() <operator> expr.
The problem was found in 2 places.
First, when we have complex expressions containing window functions, we
can only compute their final value _after_ we have computed the window
function's values. These values must be stored within the temporary
table that we are using, before sending them off.
This is done by performing an extra copy_funcs call before the final
end_send() call.

Second, such expressions need to have their inner arguments,
changed such that the references within those arguments point to fields within
the temporary table.
Ex: sum(t.a) over (order by t.b) + sum(t.a) over (order by t.b)
Before this fix, t.a pointed to the original table's a field. In order
to compute the sum function's value correctly, it needs to point to the
copy of this field inside the temp table.
This is done by calling split_sum_func for each argument in the
expression in turn.

The win.test results have also been updated as they contained wrong
values for such a use case.
2016-09-24 15:12:34 +02:00
Igor Babaev
3630a00e25 Fixed bug mdev-10782.
This bug in the code of Item_ref::build_clone could
cause corruption of items in where conditions.
Also made sure that equality predicates extracted
from multiple equality items to be pushed into
materialized views were cloned.
2016-09-12 00:07:02 -07:00
Sergei Golubchik
7ae555c114 Merge branch 'mysql/5.5' into 5.5
80% reverted
2016-09-11 20:51:09 +02:00
Oleksandr Byelkin
9810d5ea13 Helper function for debugging. 2016-09-11 11:55:57 +02:00
Sergei Golubchik
06b7fce9f2 Merge branch '10.1' into 10.2 2016-09-09 08:33:08 +02:00
Igor Babaev
dc9b0924d1 More cleanup. 2016-09-06 11:20:50 -07:00
Igor Babaev
2c6d620019 Merge branch '10.2' into bb-10.2-mdev9864 2016-09-06 10:57:14 -07:00
Alexander Barkov
e4f6fd5e12 MDEV-10743 LDML: a new syntax to reuse sort order from another 8bit simple collation 2016-09-06 12:37:11 +04:00
Igor Babaev
de02bfd373 The code that pushed conditions into derived did not
take into account that the list of equal items in
an Item_equal object may contain items with type() == REF_ITEM.
2016-09-05 22:10:50 -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
b9631e310b MDEV-8833 Crash of server on prepared statement with conversion to semi-join
Correct context chain made to allow outer fields pullout.
2016-09-02 18:34:37 +02:00
Igor Babaev
4de75afb45 Fixed the previous merge to be able to build mysqld.
Adjusted one result file.
2016-09-01 23:37:27 -07: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
Oleksandr Byelkin
a322651b8a MDEV-10017: Get unexpected Empty Set for correlated subquery with aggregate functions
take into account all arguments of aggregate function
2016-08-31 19:12:35 +02:00
Sergei Golubchik
7450cb7f69 re-fix vcols on demand, not always for every SELECT 2016-08-27 16:59:13 +02:00
Sergei Golubchik
cd51c7fb60 move away from TIMESTAMP_DNUN_FIELD/TIMESTAMP_DN_FIELD code
use the new approach with Field->default_value expressions.
But keep the old TIMESTAMP_UN_FIELD for ON UPDATE NOW().
2016-08-27 16:59:13 +02:00
Sergei Golubchik
12d2c4fcd0 optimize constant default expressions
to be calculated at the CREATE TABLE time and stored in
the default row image.
2016-08-27 16:59:12 +02:00
Galina Shalygina
eb2c147475 The consolidated patch for mdev-9197. 2016-08-23 00:39:12 +03:00
Sreeharsha Ramanavarapu
ac460e584d Bug #23280699: MYSQLD GOT SIGNAL 11 IN IS_NULL ON SELECT
FROM I_S

Issue:
------
There is a difference in the field type created when the
following DDLs are used:

1) CREATE TABLE t0 AS SELECT NULL;
2) CREATE TABLE t0 AS SELECT GREATEST(NULL,NULL);

The first statement creates field of type Field_string and
the second one creates a field of type Field_null.

This creates a problem when the query mentioned in this bug
is used. Since the null_ptr is calculated differently for
Field_null.

Solution:
---------
When there is a function returning null in the select list
as mentioned above, the field should be of type
Field_string.

This was fixed in 5.6+ as part of Bug#14021323. This is a
backport to mysql-5.5.

An incorrect comment in innodb_bug54044.test has been
corrected in all versions.
2016-07-22 07:33:43 +05:30
Alexander Barkov
59ec3973aa Removing duplicate code in double-to-longlong conversion.
Adding Converter_double_to_longlong and reusing it in:
1. Field_longlong::store(double nr)
2. Field_double::val_int()
3. Item::val_int_from_real()
4. Item_dyncol_get::val_int()
As a good side efferct, now overflow in conversion in the mentioned
val_xxx() methods return exactly the same warning.
2016-07-03 19:12:20 +04:00
Sergei Golubchik
932646b1ff Merge branch '10.1' into 10.2 2016-06-30 16:38:05 +02:00
Sergei Golubchik
3687edeec9 clarify the order of evaluation for INSERT 2016-06-30 11:43:02 +02:00