Commit graph

1310 commits

Author SHA1 Message Date
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
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
7d0c354f5c Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-03-18 14:20:06 +04:00
Vladislav Vaintroub
f2fe5cb282 Fix several compile warnings on Windows 2017-03-10 19:07:07 +00:00
Alexander Barkov
a4a48a37c4 MDEV-12199 Split Item_func_{abs|neg|int_val}::fix_length_and_dec() into methods in Type_handler 2017-03-10 16:12:58 +04:00
Alexander Barkov
47b7ffb396 Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-02-27 10:07:59 +04:00
Sergei Golubchik
6f6d0531dc MDEV-11439 No data type JSON, but CAST(something AS JSON) pretends to work
Use JSON_COMPACT(X) instead of CAST(X AS JSON).
Bonus - X is validated to be a valid JSON.
Fix a typo in the error message.
2017-02-14 20:43:41 +01:00
Sergei Golubchik
2195bb4e41 Merge branch '10.1' into 10.2 2017-02-10 17:01:45 +01:00
Alexander Barkov
3f83801d82 MDEV-12001 Split Item_func_round::fix_length_and_dec to virtual methods in Type_handler
This patch makes the following changes (according to the task description):
- Adds Type_handler::Item_func_round_fix_length_and_dec().
- Splits the code from Item_func_round::fix_length_and_dec() into new
  Item_func_round methods fix_arg_int(), fix_arg_decimal(), fix_arg_double().
- Calls the new Item_func_round methods from the relevant implementations of
  Type_handler_xxx::Item_func_round_fix_length_and_dec().
- Adds a new error message ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
- Makes ROUND() return the new error for GEOMETRY

Additionally:
- Inherits Item_func_round directly from Item_func_numhybrid as it
  uses nothing from Item_func_num1.
- Fixes "MDEV-12000 ROUND(expr,const_expr_returning_NULL) creates DOUBLE(0,0)".
  Now if args[1] returns NULL, the data type is set to DOUBLE with
  NOT_FIXED_DEC decimals instead of 0 decimals.
2017-02-07 21:07:28 +04:00
Alexander Barkov
d333e3ad9c Merge remote-tracking branch 'origin/10.2' into bb-10.2-ext 2017-02-02 08:21:42 +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
Sergei Golubchik
f7d030489d Merge branch '10.0' into 10.1 2017-01-17 20:17:35 +01:00
Sergei Golubchik
6728aae3b3 Merge branch '5.5' into 10.0 2017-01-17 16:22:25 +01:00
Sergei Golubchik
b948b5f7c6 bugfix: Item_func_min_max stored thd internally
It was used for get_datetime_value() and for thd->is_error().

But in fact, get_datetime_value() never used thd argument, because the
cache ptr argument was NULL. And thd->is_error() check was not needed
at that place at all.
2017-01-15 00:12:16 +01: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
Alexander Barkov
9b2bcf19f4 MDEV-11528 Split Item_func_min_max::val_xxx() and Item_func_min_max::get_date() into methods in Type_handler 2016-12-30 15:39:33 +04:00
Alexander Barkov
8aa044e674 MDEV-11478 Result data type aggregation for pluggable data types 2016-12-29 11:53:14 +04:00
Alexander Barkov
d8c695ead4 MDEV-11615 Split Item_hybrid_func::fix_attributes into virtual methods in Type_handler 2016-12-27 09:32:54 +04:00
Alexander Barkov
2f6fede8d5 MDEV-10524 Assertion `arg1_int >= 0' failed in Item_func_additive_op::result_precision()
This change is a backport from 10.0 to 5.5 for:
1. The full patch for:
     MDEV-4841 Wrong character set of ADDTIME() and DATE_ADD()
     9adb6e991e

2. A small fragment of:
     MDEV-5298 Illegal mix of collations on timestamp
     03f6778d61
   which overrides Item_temporal_hybrid_func::cmp_type(),
   and adds a new line into cache_temporal_4265.result.
2016-12-19 14:28:08 +04:00
Alexander Barkov
6be678608f MDEV-11330 Split Item_func_hybrid_field_type::val_xxx() into methods in Type_handler 2016-12-16 18:33:57 +04:00
Alexander Barkov
8b4f181c60 MDEV-10811 Change design from "Item is Type_handler" to "Item has Type_handler" 2016-12-16 17:31:40 +04: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
Alexey Botchkov
ebe5ebba16 MDEV-9143 JSON_xxx functions.
The rest of mysql/json functions implemented.
        CAST AS JSON implemented.
2016-11-15 17:04:31 +04:00
Sergei Golubchik
06b7fce9f2 Merge branch '10.1' into 10.2 2016-09-09 08:33:08 +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
Sergei Golubchik
3aff76f375 vcol flag rename VCOL_UNKNOWN -> VCOL_FIELD_REF 2016-08-27 16:59:12 +02:00
Sergei Golubchik
73a220aac3 session-state dependent functions in DEFAULT/CHECK/vcols
* revert part of the db7edfe that moved calculations from
  fix_fields to val_str for Item_func_sysconst and descendants
* mark session state dependent functions in check_vcol_func_processor()
* re-run fix_fields for all such functions for every statement
* fix CURRENT_USER/CURRENT_ROLE not to use Name_resolution_context
  (that is allocated on the stack in unpack_vcol_info_from_frm())

Note that NOW(), CURDATE(), etc use lazy initialization and do *not*
force fix_fields to be re-run. The rule is:
* lazy initialization is *not* allowed, if it changes metadata (so,
   e.g. DAYNAME() cannot use it)
* lazy initialization is *preferrable* if it has side effects (e.g.
  NOW() sets thd->time_zone_used=1, so it's better to do it when
  the value of NOW is actually needed, not when NOW is simply prepared)
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
Alexander Barkov
d1b2589074 Removing class Item_func_integer. It's not used since MySQL-5.0. 2016-07-05 15:23:22 +04:00
Alexander Barkov
3ccf8218bc Partial backporting of 7b50447aa6
(MDEV-9407, MDEV-9408) from 10.1

Needed to fix MDEV-10317 easier.
2016-07-03 11:20:46 +04:00
Alexander Barkov
f832b47833 Removing the "thd" argument from Item::create_field_for_create_select().
"thd" is available through the "table" argument, as table->in_use.

Backporting (partially) from 10.2.
2016-07-03 10:41:16 +04:00
Alexander Barkov
675d8a94f5 Removing the "thd" argument from Item::create_field_for_create_select().
"thd" is available through the "table" argument, as table->in_use.
2016-07-01 21:45:57 +04:00
Sergei Golubchik
932646b1ff Merge branch '10.1' into 10.2 2016-06-30 16:38:05 +02:00
Sergei Golubchik
0a056c9b53 better ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED 2016-06-30 11:43:02 +02:00
Sergei Golubchik
ed77ee1aab cleanup: change Item::walk() to take void* not uchar*
and remove all related casts to uchar*
also remove a couple of unused methods
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
2fe8dd0f90 various cleanups 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
Alexander Barkov
afbd28aeff Preparing the CAST(..AS [UN]SIGNED) related code to fix a number
of bugs easier (MDEV-8919, MDEV-10304, MDEV-10305, MDEV-10307)

- Adding Item::push_note_converted_to_negative_complement() and
  Item::push_note_converted_to_positive_complement()
- Adding virtual methods Item::val_int_signed_typecast() and
  Item::val_int_unsigned_typecast()
- Moving COLUMN_GET() related code from
  Item_func_signed::val_int() and Item_func_unsigned::val_int() to
  Item_dyncol_get::val_int_signed_typecast() and
  Item_dyncol_get::val_int_unsigned_typecast()
- Moving Item_func_signed::val_int_from_str() to Item::val_int_from_str()
  and changing it to get the value from "this" instead of args[0].

The patch does not change behaviour. It's only to simplify fixing of the
mentioned bugs. It will also simplify switching the CAST related code to
use the type handler infrastructure easier (soon).
2016-06-29 18:25:51 +04:00
Sergei Golubchik
87e3e67f43 Merge branch '10.0' into 10.1 2016-05-04 15:23:26 +02:00
Sergei Golubchik
872649c7ba Merge branch '5.5' into 10.0 2016-04-26 23:05:26 +02:00
Sergei Golubchik
0991e19e9d Merge branch 'bb-5.5-serg' into 5.5 2016-04-20 20:25:46 +02:00
Sergei Golubchik
b069d19284 Merge branch 'mysql/5.5' into 5.5 2016-04-20 15:25:55 +02:00
Alexander Barkov
9a987142f9 MDEV-9745 Crash with CASE WHEN TRUE THEN COALESCE(CAST(NULL AS UNSIGNED)) ELSE 4 END
This is a backport of the patch for MDEV-9653 (fixed earlier in 10.1.13).

The code in Item_func_case::fix_length_and_dec() did not
calculate max_length and decimals properly.

In case of any numeric result (DECIMAL, REAL, INT) a generic method
Item_func_case::agg_num_lengths() was called, which could erroneously result
into a DECIMAL item with max_length==0 and decimals==0, so the constructor of
Field_new_decimals tried to create a field of DECIMAL(0,0) type,
which caused a crash.

Unlike Item_func_case, the code responsible for merging attributes in
Item_func_coalesce::fix_length_and_dec() works fine: it has specific execution
branches for all distinct numeric types and correctly creates a DECIMAL(1,0)
column instead of DECIMAL(0,0) for the same set of arguments.

The fix does the following:
- Moves the attribute merging code from Item_func_coalesce::fix_length_and_dec()
  to a new method Item_func_hybrid_result_type::fix_attributes()
- Removes the wrong code from Item_func_case::fix_length_and_dec()
  and reuses fix_attributes() in both Item_func_coalesce::fix_length_and_dec()
  and Item_func_case::fix_length_and_dec()
- Fixes count_real_length() and count_decimal_length() to get an array
  of Items as an argument, instead of using Item::args directly.
  This is needed for Item_func_case::fix_length_and_dec().
- Moves methods Item_func::count_xxx_length() from "public" to "protected".
- Removes Item_func_case::agg_num_length(), as it's not used any more.
- Additionally removes Item_func_case::agg_str_length(),
  as it also was not used (dead code).
2016-04-20 08:53:30 +04:00
Sergei Petrunia
2bd4dc38e0 Merge branch '10.2' into bb-10.2-mdev9543 2016-03-28 22:18:38 +03:00
Sergei Golubchik
f67a2211ec Merge branch '10.1' into 10.2 2016-03-23 22:36:46 +01:00
Alexander Barkov
b25373beb5 MDEV-9653 Assertion `length || !scale' failed in uint my_decimal_length_to_precision(uint, uint, bool)
MDEV-9752 Wrong data type for COALEASCE(?,1) in prepared statements
2016-03-18 17:50:18 +04:00
Igor Babaev
2cfc450bf7 This is the consolidated patch for mdev-8646:
"Re-factor the code for post-join operations".

The patch mainly contains the code ported from mysql-5.6 and
created for two essential architectural changes:
1. WL#5558: Resolve ORDER BY execution method at the optimization stage
2. WL#6071: Inline tmp tables into the nested loops algorithm

The first task was implemented for mysql-5.6 by Ole John Aske.
It allows to make all decisions on ORDER BY operation at the optimization
stage.

The second task implemented for mysql-5.6 by Evgeny Potemkin adds JOIN_TAB
nodes for post-join operations that require temporary tables. It allows
to execute these operations within the nested loops algorithm that used to
be used before this task only for join queries. Besides these task moves
all planning on the execution of these operations from the execution phase
to the optimization phase.

Some other re-factoring changes of mysql-5.6 were pulled in, mainly because
it was easier to pull them in than roll them back. In particular all
changes concerning Ref_ptr_array were incorporated.

The port required some changes in the MariaDB code that concerned the
functionality of EXPLAIN and ANALYZE. This was done mainly by Sergey
Petrunia.
2016-02-09 12:35:59 -08:00