Commit graph

2462 commits

Author SHA1 Message Date
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
Alexey Botchkov
27025221fe MDEV-9143 JSON_xxx functions.
strings/json_lib.c added as a JSON library.
        SQL frunction added with sql/item_jsonfunc.h/cc
2016-10-19 14:10:03 +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
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
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
Sergei Golubchik
3aff76f375 vcol flag rename VCOL_UNKNOWN -> VCOL_FIELD_REF 2016-08-27 16:59:12 +02:00
Sergei Golubchik
b48555e9c9 fix: DEFAULT() in a view should be not updatable
as in

create table t1 (a int);
create view v1 as select default(a) as NOT_UPDATABLE from t1;
2016-08-27 16:59:11 +02:00
Galina Shalygina
eb2c147475 The consolidated patch for mdev-9197. 2016-08-23 00:39:12 +03:00
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
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
Sergei Golubchik
c3e06381ab cannot use item->const_item() in open_table_from_share()
because table->map is set much later.
Use check_vcol_func_processor() to detect fields too.
2016-07-01 22:30:09 +02: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
7039077195 change vcol->non_deterministic to vcol->flags 2016-06-30 11:43:02 +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
Sergei Golubchik
e8bdb73ade function DEFAULT(x) now works for expression defaults 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
Monty
d99994a460 Ensure we print the most importaint violating function 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
Sergei Golubchik
23d03a1b1e parse negative numbers into one item
use Item->neg to convert generate negative Item_num's
instead of Item_func_neg(Item_num).

Based on the following commit:

  Author: Monty <monty@mariadb.org>
  Date:   Mon May 30 22:44:00 2016 +0300

    Make negative number their own token
    The negation (-) operator will call Item->neg() one underlying numeric constants
    and remove itself (like the NOT() function does today for other NOT functions.

    This simplifies things
    - -1 is not anymore an expression but a basic_const_item
      - improves optimizer
      - DEFAULT -1 doesn't need special handling anymore
      - When we add DEFAULT expressions, -1 will be treated exactly like 1
    - printing of items doesn't anymore put braces around all negative numbers

    Other things fixed:
    - Fixed that longlong converted to decimal's has a more appropriate size
    - Fixed that "-0.0" read into a decimal is interpreted as 0.0
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
Alexander Barkov
56a3496067 MDEV-10236 Where expression with NOT function gives incorrect result
Item_cache::is_null() erroneously returned null_value in a
non-cached state. Now Item_cache::is_null() uses has_value(),
which caches the value if not cached yet, similar to what other value methods do
(e.g. val_int, val_real, etc).
2016-06-28 13:11:04 +04:00
Monty
34eb10e406 MDEV-10138 Support for decimals up to 38 digits
Decimals with float, double and decimal now works the following way:

- DECIMAL_NOT_SPECIFIED is used when declaring DECIMALS without a firm number
  of decimals.  It's only used in asserts and my_decimal_int_part.
- FLOATING_POINT_DECIMALS (31) is used to mark that a FLOAT or DOUBLE
  was defined without decimals. This is regarded as a floating point value.
- Max decimals allowed for FLOAT and DOUBLE is FLOATING_POINT_DECIMALS-1
- Clients assumes that float and double with decimals >= NOT_FIXED_DEC are
  floating point values (no decimals)
- In the .frm decimals=FLOATING_POINT_DECIMALS are used to define
  floating point for float and double (31, like before)

To ensure compatibility with old clients we do:

- When storing float and double, we change NOT_FIXED_DEC to
  FLOATING_POINT_DECIMALS.
- When creating fields from .frm we change for float and double
  FLOATING_POINT_DEC to NOT_FIXED_DEC
- When sending definition for a float/decimal field without decimals
  to the client as part of a result set we convert NOT_FIXED_DEC to
  FLOATING_POINT_DECIMALS.
- variance() and std() has changed to limit the decimals to
  FLOATING_POINT_DECIMALS -1 to not get the double converted floating point.
  (This was to preserve compatiblity)
- FLOAT and DOUBLE still have 30 as max number of decimals.

Bugs fixed:

variance() printed more decimals than we support for double values.

New behaviour:
- Strings now have 38 decimals instead of 30 when converted to decimal
- CREATE ... SELECT with a decimal with > 30 decimals will create a column
  with a smaller range than before as we are trying to preserve the number of
  decimals.


Other changes
- We are now using the obsolete bit FIELDFLAG_LEFT_FULLSCREEN to specify
  decimals > 31
- NOT_FIXED_DEC is now declared in one place
- For clients, NOT_FIXED_DEC is always 31 (to ensure compatibility).
  On the server NOT_FIXED_DEC is DECIMAL_NOT_SPECIFIED (39)
- AUTO_SEC_PART_DIGITS is taken from DECIMAL_NOT_SPECIFIED
- DOUBLE conversion functions are now using DECIMAL_NOT_SPECIFIED instead of
  NOT_FIXED_DEC
2016-06-22 22:04:55 +03: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 Petrunia
59e5f5b47e Merge branch '10.2' into bb-10.2-mdev9543
- Make Window Functions errors use the MariaDB's extra error range.
- Fix a trivial bug in check_error_mesg
2016-04-07 00:54:39 +03:00
Alexander Barkov
777c2131dd MDEV-9862 Illegal mix of collation, when comparing column with CASE expression 2016-04-02 00:04:47 +04:00
Alexander Barkov
1d73005bf3 MDEV-8360 Clean-up CHARSET_INFO: strnncollsp: diff_if_only_endspace_difference
- Removing the "diff_if_only_endspace_difference" argument from
  MY_COLLATION_HANDLER::strnncollsp(), my_strnncollsp_simple(),
  as well as in the function template MY_FUNCTION_NAME(strnncollsp)
  in strcoll.ic

- Removing the "diff_if_only_space_different" from ha_compare_text(),
  hp_rec_key_cmp().

- Adding a new function my_strnncollsp_padspace_bin() and reusing
  it instead of duplicate code pieces in my_strnncollsp_8bit_bin(),
  my_strnncollsp_latin1_de(), my_strnncollsp_tis620(),
  my_strnncollsp_utf8_cs().

- Adding more tests for better coverage of the trailing space handling.

- Removing the unused definition of HA_END_SPACE_ARE_EQUAL
2016-03-31 11:04:48 +04:00
Sergei Petrunia
2bd4dc38e0 Merge branch '10.2' into bb-10.2-mdev9543 2016-03-28 22:18:38 +03:00
Igor Babaev
82cb35be11 Changed the base class for Item_window_func from Item_result_field to
Item_func_or_sum.
Implemented method update_used_tables for class Item_findow_func.
Added the flag Item::with_window_func.
Made sure that window functions could be used only in SELECT list
and ORDER BY clause.
Added test cases that checked different illegal placements of
window functions.
2016-03-23 16:09:58 -07:00
Sergei Golubchik
f67a2211ec Merge branch '10.1' into 10.2 2016-03-23 22:36:46 +01:00
Sergei Golubchik
3b0c7ac1f9 Merge branch '10.0' into 10.1 2016-03-21 13:02:53 +01:00
Sergei Petrunia
e859c2dbb8 MDEV-9676: RANGE-type frames for window functions
Add support for "RANGE n PRECEDING|FOLLOWING" frame bounds.
- n is currently limited to whatever Item and Item_sum_plus/minus
  can handle (i.e. no DATETIME intervals).
- Didn't check NULL value handling yet.
2016-03-13 03:34:31 +03:00
Sergei Petrunia
1fa12cdfb7 MDEV-9676: RANGE-type frames for window functions
Support RANGE ... CURRENT ROW as frame's first and second bound.
2016-03-06 23:10:20 +03:00
Otto Kekäläinen
1777fd5f55 Fix spelling: occurred, execute, which etc 2016-03-04 02:09:37 +02:00
Sergei Golubchik
00d1db7a38 Merge branch '10.1' into 10.2 2016-02-25 18:19:55 +01:00
Sergei Golubchik
a5679af1b1 Merge branch '10.0' into 10.1 2016-02-23 21:35:05 +01:00
Sergei Golubchik
271fed4106 Merge branch '5.5' into 10.0 2016-02-15 22:50:59 +01:00
Igor Babaev
9d9c60fb12 Initial patch for the implementation of window functions (MDEV-6115):
- All parsing problems look like resolved
- Stub performing name resolution of window functions
in simplest queries has been added.
2016-02-12 20:33:56 -08: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
Sergei Golubchik
f3444df415 Merge branch 'mysql/5.5' into 5.5
reverted about half of commits as either not applicable or
outright wrong
2016-02-09 11:27:40 +01:00
Monty
b2f8d7b410 Merge branch '10.1' into 10.2
Conflicts:
	VERSION
	cmake/plugin.cmake
	config.h.cmake
	configure.cmake
	plugin/server_audit/server_audit.c
	sql/sql_yacc.yy
2016-02-06 18:14:54 +02:00
Sreeharsha Ramanavarapu
718c787912 Bug #18823979: PS: UCS2 + CASE WHEN THEN ELSE CRASH IN
ITEM_PARAM::SAFE_CHARSET_CONVERTER

ISSUE:
------
Charset conversion on a null parameter is not handled
correctly.

SOLUTION:
---------
Item_param's charset converter does not handle the case
where it might have to deal with a null value. This is
fine for other charset converters since the value is not
supplied to them at runtime.

The fix is to check if the parameter is now set to null and
return an Item_null object. Also, there is no need to
initialize Item_param's cnvitem in the constructor to a
string. This can be done in
ITEM_PARAM::SAFE_CHARSET_CONVERTER itself.

Members of Item_param, cnvbuf and cnvstr, have been removed
and cnvitem has been made a local variable in
ITEM_PARAM::SAFE_CHARSET_CONVERTER.
2016-01-29 08:29:06 +05:30
Alexander Barkov
ce40ccaf24 MDEV-9181 (NULLIF(count(table.col)), 0) gives wrong result on 10.1.x
Wrapping args[0] and args[2] into an Item_cache for aggregate functions.
2016-01-28 13:58:39 +04:00
Alexander Barkov
7b50447aa6 MDEV-9407 Illegal mix of collation when using GROUP_CONCAT in a VIEW
MDEV-9408 CREATE TABLE SELECT MAX(int_column) creates different columns for table vs view

There were three almost identical pieces of the code:
- Field *Item_func::tmp_table_field();
- Field *Item_sum::create_tmp_field();
- Field *create_tmp_field_from_item();
with a difference in very small details (hence the bugs):
Only Item_func::tmp_table_field() was correct, the other two were not.
Removing the two incorrect pieces of the redundant code.
Joining these three functions/methods into a single virtual method
Item::create_tmp_field().
Additionally, moving Item::make_string_field() and
Item::tmp_table_field_from_field_type() from the public into the
protected section of the class declaration, as they are now not
needed outside of Item.
2016-01-16 18:45:26 +04:00
Alexander Barkov
5b9ee3f2ae MDEV-9220 Split filesort.cc:make_sortkey() and filesort.cc::sortlength() into virtual methods in Type_handler 2016-01-12 17:03:29 +04:00
Alexander Barkov
2ba7ed77aa Merge remote-tracking branch 'origin/10.1' into 10.2 2015-12-29 19:37:11 +04:00
Alexander Barkov
39fb94728f Changing the parameter of Field::eq_def() from "Field *" to "const Field *" 2015-12-24 11:37:16 +04:00
Alexander Barkov
b424420f10 MDEV-9316 Add Field::store_hex_hybrid() 2015-12-23 14:15:00 +04:00
Sergei Golubchik
0686c34d22 MDEV-8605 MariaDB not use DEFAULT value even when inserted NULL for NOT NULLABLE column
NOT NULL constraint must be checked *after* the BEFORE triggers.
That is for INSERT and UPDATE statements even NOT NULL fields
must be able to store a NULL temporarily at least while
BEFORE INSERT/UPDATE triggers are running.
2015-12-21 21:30:54 +01:00
Alexander Barkov
aee068085d MDEV-9238 Wrap create_virtual_tmp_table() into a class, split into different steps 2015-12-04 16:38:42 +04:00
Alexander Barkov
1040878233 MDEV-9215 Detect cmp_type() and result_type() from field_type()
Part8: Derive Item_copy from Type_handler_hybrid_field_type
2015-12-03 23:59:47 +04:00
Alexander Barkov
192c748c24 MDEV-9215 Detect cmp_type() and result_type() from field_type()
Part7: Derive Item_cache from Type_handler_hybrid_field_type
2015-12-03 23:42:05 +04:00
Alexander Barkov
f3ff8b3529 MDEV-9215 Detect cmp_type() and result_type() from field_type()
Part6: Deriving Item_type_holder from Type_handler_hybrid_real_field_type
2015-12-03 10:10:59 +04:00
Alexander Barkov
ee3a8cb023 MDEV-9215 Detect cmp_type() and result_type() from field_type()
Part5: Derive Item_param from Type_handler_hybrid_field_type
2015-12-02 16:22:19 +04:00
Alexander Barkov
47a8c6c397 - MDEV-9215 Detect cmp_type() and result_type() from field_type()
Part3: Deriving Item_splocal from Type_handler_hybrid_field_type
2015-12-02 09:26:34 +04:00
Alexander Barkov
3e471bf3e9 MDEV-9215 Detect cmp_type() and result_type() from field_type()
Part2: deriving Item_sum_sum from Type_handler_hybrid_field_type,
removing "Item_result Item_sum_sum::hybrid_type".
2015-12-01 14:20:09 +04:00
Alexander Barkov
607ef786fc MDEV-9215 Detect cmp_type() and result_type() from field_type()
(A dependency task for MDEV-4912 Add a plugin to field types)
2015-12-01 13:13:23 +04:00
Sergey Vojtovich
54689e1d5c MDEV-8715 - Obsolete sql_alloc() in favor of THD::alloc() and thd_alloc()
The following left in semi-improved state to keep patch size reasonable:
- Field operator new: left thd_alloc(current_thd)
- Sql_alloc operator new: left thd_alloc(thd_get_current_thd())
- Item_args constructors: left thd_alloc(thd)
- Item_func_interval::fix_length_and_dec(): no THD arg, have to call current_thd
- Item_func_dyncol_exists::val_int(): same
- Item_dyncol_get::val_str(): same
- Item_dyncol_get::val_int(): same
- Item_dyncol_get::val_real(): same
- Item_dyncol_get::val_decimal(): same
- Item_singlerow_subselect::fix_length_and_dec(): same
2015-11-26 11:34:17 +04:00
Sergey Vojtovich
753d1f868c MDEV-8716 - Obsolete sql_calloc() in favor of THD::calloc() and thd_calloc() 2015-11-26 11:34:16 +04:00
Sergey Vojtovich
0746a07708 MDEV-8718 - Obsolete sql_strmake() in favor of THD::strmake() and thd_strmake() 2015-11-26 11:34:16 +04:00
Chaithra Gopalareddy
a7fb5aecfd Bug#19941403: FATAL_SIGNAL(SIG 6) IN BUILD_EQUAL_ITEMS_FOR_COND | IN SQL/SQL_OPTIMIZER.CC:1657
Problem:
At the end of first execution select_lex->prep_where is pointing to
a runtime created object (temporary table field). As a result
server exits trying to access a invalid pointer during second
execution.

Analysis:
While optimizing the join conditions for the query, after the
permanent transformation, optimizer makes a copy of the new
where conditions in select_lex->prep_where. "prep_where" is what
is used as the "where condition" for the query at the start of execution.
W.r.t the query in question, "where" condition is actually pointing
to a field in the temporary table. As a result, for the  second
execution the pointer is no more valid resulting in server exit.

Fix:
At the end of the first execution, select_lex->where will have the
original item of the where condition.
Make prep_where the new place where the original item of select->where
has to be rolled back.
Fixed in 5.7 with the wl#7082 - Move permanent transformations from
JOIN::optimize to JOIN::prepare

Patch for 5.5 includes the following backports from 5.6:

Bugfix for Bug12603141 - This makes the first execute statement in the testcase
pass in 5.5

However it was noted later in in Bug16163596 that the above bugfix needed to
be modified. Although Bug16163596 is reproducible only with changes done for
Bug12582849, we have decided include the fix.

Considering that Bug12582849 is related to Bug12603141, the fix is
also included here. However this results in Bug16317817, Bug16317685,
Bug16739050. So fix for the above three bugs is also part of this patch.
2015-11-20 12:30:15 +05:30
Sergei Golubchik
beded7d9c9 Merge branch '10.0' into 10.1 2015-11-19 15:52:14 +01:00
Oleksandr Byelkin
fb4358f432 MDEV-7949: Item_field::used_tables() takes 0.29% in OLTP RO
small sixes of used_tables() usage
2015-10-29 21:05:00 +01:00
Oleksandr Byelkin
d88aaaa841 MDEV-8525 mariadb 10.0.20 crashing when data is read by Kodi media center (http://kodi.tv).
Item_direct_view_ref maintains its own item_const() method so should use it when asked of temporary table field to be in sync with it.
2015-10-28 11:13:31 +01:00
Sergei Golubchik
fb8713385f remove unneded #include's that had a dubious explanation 2015-10-24 19:58:34 +02:00
Alexander Barkov
b867ade591 Removing Used_tables_and_const_cache from "class udf_handler".
It was used only temporary, during udf_handler::fix_fields() time,
and then copied to the owner Item_func_or_sum object.
Changing the code to use the Used_tables_and_const_cache part
of the owner Item_sum_or_func object directly.
2015-10-14 18:33:16 +04:00
Alexander Barkov
0b4c3ad818 Moving Used_tables_and_const_chache from Item_func to Item_func_or_sum
and thus reusing Used_tables_and_const_cache for Item_sum instead of
declaring the same members inside Item_sum.
2015-10-12 10:49:37 +04:00
Alexander Barkov
16ad1fc540 MDEV-8921 Wrong result for CAST(AVG(double_column) AS SIGNED) 2015-10-08 20:48:46 +04:00
Alexander Barkov
8777724901 MDEV-8912 Wrong metadata or type for @c:=string_or_blob_field 2015-10-07 20:19:29 +04:00
Alexander Barkov
8afe96f011 MDEV-8910 Wrong metadata or field type for MAX(COALESCE(string_field)) 2015-10-07 11:42:23 +04:00
Sergei Petrunia
d6371d3a8e Combined fix for MDEV-7267 and MDEV-8864
The problem was that GROUP BY code created Item_field objects
that referred to fields in the temp. tables used for GROUP BY.

Item_ref and set_items_ref_array() call caused pointers to temp.
table fields to occur in many places.

This patch introduces Item_temptable_field, which can handle
item->print() calls made after the underlying table is freed.
2015-10-06 18:03:10 +03:00
Alexander Barkov
ba0b668551 A clean-up for MDEV-7950:
- Turning get_mm_tree_for_const() from a static function into
  a protected method in Item.
- Adding a new class Item_bool_func2_with_rev, for the functions and operators
  that have a reverse function and can use the range optimizer for
  to optimize "value OP field" as "field REV_OP value". Deriving
  Item_bool_rowready_func2 and Item_funt_spatial_rel from the new class.
- Removing Item_bool_func2::have_rev_func().
2015-10-04 09:37:57 +04:00
Alexander Barkov
cc9cfecab7 MDEV-8865 Wrong field type or metadata for COALESCE(signed_int_column, unsigned_int_column)
Item_func_hybrid_field_type did not return correct field_type(), cmp_type()
and result_type() in some cases, because cached_result_type and
cached_field_type were set in independent pieces of the code and
did not properly match to each other.
Fix:
- Removing Item_func_hybrid_result_type
- Deriving Item_func_hybrid_field_type directly from Item_func
- Introducing a new class Type_handler which guarantees that
  field_type(), cmp_type() and result_type() are always properly synchronized
  and using the new class in Item_func_hybrid_field_type.
2015-09-30 12:37:34 +04:00
Alexander Barkov
30711c6650 MDEV-8806 Numeric CAST produce different warnings for strings literals vs functions 2015-09-25 21:33:50 +04:00
Alexander Barkov
22cc8f990b Changing a number of functions to aggregate argument character sets
and collations from the global name space into private and protected
methods in Item_func_or_sum.
2015-09-21 19:04:32 +04:00
Alexander Barkov
afa1773439 Moving Item_args::arg_count from "public" to "protected". 2015-09-21 12:40:07 +04:00
Alexander Barkov
1956340247 Removing global function agg_item_charsets_for_string_result().
Moving agg_arg_charsets_for_string_result() and
agg_arg_charsets_for_string_result_with_comparison() inside
"protected" section in Item_func_or_sum.
2015-09-21 12:21:46 +04:00
Alexander Barkov
b75c003372 MDEV-8816 Equal field propagation is not applied for WHERE varbinary_column>=_utf8'a' COLLATE utf8_general_ci AND varbinary_column='A';
1. Removing the legacy code that disabled equal field propagation in cases
   when comparison is done as VARBINARY. This is now correctly handled by
   the new propagation code in Item_xxx::propagate_equal_fields() and
   Field_str::can_be_substituted_to_equal_item (the bug fix).
2. Also, removing legacy (pre-MySQL-4.1) Arg_comparator methods
   compare_binary_string() and compare_e_binary_string(), as VARBINARY
   comparison is correcty handled in compare_string() and compare_e_string() by
   the corresponding VARBINARY collation handler implemented in my_charset_bin.
   (not really a part of the bug fix)
2015-09-18 23:03:35 +04:00
Alexander Barkov
79140b0383 MDEV-8793 Wrong result set for SELECT ...
WHERE COALESCE(time_column)=TIME('00:00:00')
            AND COALESCE(time_column)=DATE('2015-09-11')
MDEV-8814 Wrong result for WHERE datetime_column > TIME('00:00:00')
2015-09-18 13:30:44 +04:00
Alexander Barkov
d9b25ae3db MDEV-8466 CAST works differently for DECIMAL/INT vs DOUBLE for empty strings
MDEV-8468 CAST and INSERT work differently for DECIMAL/INT vs DOUBLE for a string with trailing spaces
2015-09-17 11:05:07 +04:00
Alexander Barkov
6cc2e7ea5d MDEV-8795 Equal expression propagation does not work for temporal literals 2015-09-13 23:32:10 +04:00
Alexander Barkov
4aebba3aeb MDEV-8740 Wrong result for SELECT..WHERE year_field=10 AND NULLIF(year_field,2011.1)='2011'
MDEV-8754 Wrong result for SELECT..WHERE year_field=2020 AND NULLIF(year_field,2010)='2020'
Problems:
1. Item_func_nullif stored a copy of args[0] in a private member m_args0_copy,
   which was invisible for the inherited Item_func menthods, like
   update_used_tables(). As a result, after equal field propagation
   things like Item_func_nullif::const_item() could return wrong result
   and a non-constant NULLIF() was erroneously treated as a constant
   at optimize_cond() time.
   Solution: removing m_args0_copy and storing the return value item
   in args[2] instead.
2. Equal field propagation did not work well for Item_fun_nullif.
   Solution: using ANY_SUBST for args[0] and args[1], as they are in
   comparison, and IDENTITY_SUBST for args[2], as it's not in comparison.
2015-09-10 17:13:35 +04:00
Alexander Barkov
39b46ae934 MDEV-8706 Wrong result for SELECT..WHERE time_column=TIMESTAMP'2015-08-30 00:00:00' AND time_column='00:00:00' 2015-09-09 15:39:09 +04:00
Alexander Barkov
de269f2f1f MDEV-8766 Wrong result for SELECT..WHERE LENGTH(time_column)=8 AND time_column=TIMESTAMP'2001-01-01 10:20:31' 2015-09-08 16:02:29 +04:00
Alexander Barkov
1a36caf0e9 MDEV-8729 Wrong result for SELECT..WHERE HEX(enum_column)='61' AND enum_column='a ' 2015-09-06 18:49:17 +04:00
Alexander Barkov
e0df116056 A clean-up after the patch for MDEV-8747 and MDEV-8749:
removing IMPOSSIBLE_RESULT from Item_result, as it's not
needed any more. The fact that an Item is not in a comparison
context is now always designated by IDENTITY_SUBST in Subst_constraint.
Previously IMPOSSIBLE_RESULT and IDENTITY_SUBST co-existed but
actually meant the same thing.
2015-09-06 13:25:47 +04:00
Alexander Barkov
c108019a48 MDEV-8747 Wrong result for SELECT..WHERE derived_table_column='a' AND derived_table_column<>_latin1'A' COLLATE latin1_bin
MDEV-8749 Wrong result for SELECT..WHERE derived_table_enum_column='number' AND derived_table_enum_column OP number
2015-09-06 01:30:46 +04:00
Sergei Golubchik
530a6e7481 Merge branch '10.0' into 10.1
referenced_by_foreign_key2(), needed for InnoDB to compile,
was taken from 10.0-galera
2015-09-03 12:58:41 +02:00
Monty
56aa19989f MDEV-6152: Remove calls to current_thd while creating Item
Part 5: Removing calls to current_thd in net_read calls, creating fields,
        query_cache, acl and some other places where thd was available
2015-09-01 18:42:02 +03:00
Alexander Barkov
a3c24ee739 MDEV-8707 Wrong result for
SELECT..WHERE varchar_column=DATE'2001-01-01' AND varchar_column='2001-01-01'
2015-08-31 18:18:10 +04:00
Monty
3bca8db4f9 MDEV-6152: Remove calls to current_thd while creating Item
- Part 4: Removing calls to sql_alloc() and sql_calloc()

Other things:
- Added current_thd in some places to make it clear that it's called (easier to remove later)
- Move memory allocation from Item_func_case::fix_length_and_dec() to Item_func_case::fix_fields()
- Added mem_root to some new calls
- Fixed some wrong UNINIT_VAR() calls
- Fixed a bug in generate_partition_syntax() in case of errors
- Added mem_root to argument to new thread_info
- Simplified my_parse_error() call in sql_yacc.yy
2015-08-27 22:29:11 +03:00
Alexander Barkov
ba340d8c47 Making Item_field::can_be_substituted_to_equal_item() private. 2015-08-26 23:17:34 +04:00
Alexander Barkov
1b6b44b6b5 MDEV-8661 Wrong result for SELECT..WHERE a='a' AND a='a' COLLATE latin1_bin
MDEV-8679 Equal field propagation is not used for VARCHAR when it safely could
2015-08-26 22:32:01 +04:00
Alexander Barkov
98ba2bf424 Clean-up: moving compare_collation() from Item to Item_bool_func. 2015-08-21 17:08:55 +04:00
Monty
1bae0d9e56 Stage 2 of MDEV-6152:
- Added mem_root to all calls to new Item
- Added private method operator new(size_t size) to Item to ensure that
  we always use a mem_root when creating an item.

This saves use once call to current_thd per Item creation
2015-08-21 10:40:51 +04:00
Sergey Vojtovich
31e365efae MDEV-8010 - Avoid sql_alloc() in Items (Patch #1)
Added mandatory thd parameter to Item (and all derivative classes) constructor.
Added thd parameter to all routines that may create items.
Also removed "current_thd" from Item::Item. This reduced number of
pthread_getspecific() calls from 290 to 177 per OLTP RO transaction.
2015-08-21 10:40:39 +04:00
Jan Lindström
9a5787db51 Merge commit '96badb16afcf' into 10.0
Conflicts:
	client/mysql_upgrade.c
	mysql-test/r/func_misc.result
	mysql-test/suite/binlog/r/binlog_stm_mix_innodb_myisam.result
	mysql-test/suite/innodb/r/innodb-fk.result
	mysql-test/t/subselect_sj_mat.test
	sql/item.cc
	sql/item_func.cc
	sql/log.cc
	sql/log_event.cc
	sql/rpl_utility.cc
	sql/slave.cc
	sql/sql_class.cc
	sql/sql_class.h
	sql/sql_select.cc
	storage/innobase/dict/dict0crea.c
	storage/innobase/dict/dict0dict.c
	storage/innobase/handler/ha_innodb.cc
	storage/xtradb/dict/dict0crea.c
	storage/xtradb/dict/dict0dict.c
	storage/xtradb/handler/ha_innodb.cc
	vio/viosslfactories.c
2015-08-03 23:09:43 +03:00
Sergei Golubchik
4d5772c578 MDEV-7810 Wrong result on execution of a query as a PS (both 1st and further executions)
Alternative fix that doesn't cause view.test crash in --ps:
Remember when Item_ref was fixed right in the constructor
and did not have a full Item_ref::fix_fields() call. Later
in PS/SP, after Item_ref::cleanup, we use this knowledge
to avoid doing full fix_fields() for items that were never
supposed to be fix_field'ed.

Simplify the test case.
2015-07-31 17:17:33 +02:00
Sreeharsha Ramanavarapu
c773b320ff Merge branch 'mysql-5.1' into mysql-5.5 2015-07-10 07:54:55 +05:30
Sreeharsha Ramanavarapu
33a2e5abd8 Bug #20238729: ILLEGALLY CRAFTED UTF8 SELECT PROVIDES NO
WARNINGS

Backporting to 5.1 and 5.5
2015-07-10 07:52:00 +05:30
Monty
9bb8b74e99 Merge branch '10.1' of github.com:MariaDB/server into 10.1
Conflicts:
	sql/item_subselect.cc

Fixed also typo in comment
2015-07-09 14:47:32 +03:00
Monty
7332af49e4 - Renaming variables so that they don't shadow others (After this patch one can compile with -Wshadow and get much fewer warnings)
- Changed ER(ER_...) to ER_THD(thd, ER_...) when thd was known or if there was many calls to current_thd in the same function.
- Changed ER(ER_..) to ER_THD_OR_DEFAULT(current_thd, ER...) in some places where current_thd is not necessary defined.
- Removing calls to current_thd when we have access to thd

Part of this is optimization (not calling current_thd when not needed),
but part is bug fixing for error condition when current_thd is not defined
(For example on startup and end of mysqld)

Notable renames done as otherwise a lot of functions would have to be changed:
- In JOIN structure renamed:
   examined_rows -> join_examined_rows
   record_count -> join_record_count
- In Field, renamed new_field() to make_new_field()

Other things:
- Added DBUG_ASSERT(thd == tmp_thd) in Item_singlerow_subselect() just to be safe.
- Removed old 'tab' prefix in JOIN_TAB::save_explain_data() and use members directly
- Added 'thd' as argument to a few functions to avoid calling current_thd.
2015-07-06 20:24:14 +03:00
Monty
86377d078e Fixes done while working on MDEV-4119:
Fixed several optimizer issues relatied to GROUP BY:

a) Refering to a SELECT column in HAVING sometimes calculated it twice, which caused problems with non determinstic functions

b) Removing duplicate fields and constants from GROUP BY was done too late for "using index for group by" optimization to work

c) EXPLAIN SELECT ... GROUP BY did wrongly show 'Using filesort' in some cases involving "Using index for group-by"


a) was fixed by:
- Changed last argument to Item::split_sum_func2() from bool to int to allow more flags
- Added flag argument to Item::split_sum_func() to allow on to specify if the item was in the SELECT part
- Mark all split_sum_func() calls from SELECT with SPLIT_SUM_SELECT
- Changed split_sum_func2() to do nothing if called with an argument that is not a sum function and doesn't include sum functions, if we are not an argument to SELECT.

This ensures that in a case like
select a*sum(b) as f1 from t1 where a=1 group by c having f1 <= 10;

That 'a' in the SELECT part is stored as a reference in the temporary table togeher with sum(b) while the 'a' in having isn't (not needed as 'a' is already a reference to a column in the result)

b) was fixed by:
- Added an extra remove_const() pass for GROUP BY arguments before make_join_statistics() in case of one table SELECT.

This allowes get_best_group_min_max() to optimize things better.

c) was fixed by:
- Added test for group by optimization in JOIN::exec_inner for
  select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_GROUP_MIN_MAX

item.cc:
- Simplifed Item::split_sum_func2()
  - Split test to make them faster and easier to read
  - Changed last argument to Item::split_sum_func2() from bool to int to allow more flags
  - Added flag argument to Item::split_sum_func() to allow on to specify if the item was in the SELECT part
  - Changed split_sum_func2() to do nothing if called with an argument that is not a sum function and doesn't include sum functions, if we are not an argument to SELECT.

opt_range.cc:
- Simplified get_best_group_min_max() by calcuating first how many group_by elements.
- Use join->group instead of join->group_list to test if group by, as join->group_list may be NULL if everything was optimized away.

sql_select.cc:
- Added an extra remove_const() pass for GROUP BY arguments before make_join_statistics() in case of one table SELECT.
- Use group instead of group_list to test if group by, as group_list may be NULL if everything was optimized away.
- Moved printing of "Error in remove_const" to remove_const() instead of having it in caller.
- Simplified some if tests by re-ordering code.
- update_depend_map_for_order() and remove_const() fixed to handle the case where make_join_statistics() has not yet been called (join->join_tab is 0 in this case)
2015-07-05 12:39:46 +03:00
Sergei Petrunia
9d2aa2b309 MDEV-7811: EXPLAIN/ANALYZE FORMAT=JSON should show subquery cache
Fixes over the original patch:
- Fix variable/class/other names
- Fix the JSON output to be in line with the output of other JSON
  constructs we produce
2015-07-01 20:03:29 +03:00
Oleksandr Byelkin
c6aee27b73 MDEV-7811: EXPLAIN/ANALYZE FORMAT=JSON should show subquery cache 2015-06-30 23:07:14 +03:00
Sergei Golubchik
658992699b Merge tag 'mariadb-10.0.20' into 10.1 2015-06-27 20:35:26 +02:00
Monty
2e941fe9fc Fixed crashing bug when using ONLY_FULL_GROUP_BY in a stored procedure/trigger that is repeatedly executed.
This is MDEV-7601, including it's sub tasks MDEV-7594, MDEV-7555, MDEV-7590, MDEV-7581, MDEV-7589

The problem was that select_lex->non_agg_fields was not properly reset for re-execution and this caused an overwrite of a random memory position.
The fix was move non_agg_fields from select_lext to JOIN, which is properly reset.
2015-06-25 23:18:48 +03:00
Sergey Vojtovich
360176f397 MDEV-7943 - pthread_getspecific() takes 0.76% in OLTP RO
Pass THD to Item_field (and all derivatives) constructors.
This reduces number of pthread_getspecific() calls from 322 to 292.
2015-06-19 15:06:34 +04:00
Sergei Golubchik
810cf362ea Merge branch '5.5' into 10.0 2015-06-11 20:20:35 +02:00
Alexander Barkov
b1e10399f4 MDEV-8286 Likely a redundant declaration of Item_cache::used_table_map
Removing Item_cache::used_table_map, Item_cache::used_tables() and
Item_cache::set_used_tables(). Using the same inherited from
Item_basic_constant implementations instead.
2015-06-09 07:36:24 +04:00
Alexander Barkov
a765cca69f MDEV-8067 correct fix for MySQL Bug # 19699237: UNINITIALIZED VARIABLE IN ITEM_FIELD::STR_RESULT 2015-06-08 20:50:40 +04:00
Sergei Golubchik
5091a4ba75 Merge tag 'mariadb-10.0.19' into 10.1 2015-06-01 15:51:25 +02:00
Alexander Barkov
0dc14257cb MDEV-7950 Item_func::type() takes 0.26% in OLTP RO
Step #7 (mostly preparatory for the next step #8):
Splitting the function get_mm_parts() into a virtual method in Item.
This changes a virtual call for item->type() into a virtual call for item->get_mm_tree(),
but also *removes* one virtual call Item_cond::functype(), which used to distinguish
between COND_AND_FUNC vs COND_OR_FUNC.
2015-05-27 12:03:20 +04:00
Alexander Barkov
bb15b9e29b MDEV-7950 Item_func::type() takes 0.26% in OLTP RO 2015-05-19 17:03:18 +04:00
Alexander Barkov
632f2307f7 MDEV-7950 Item_func::type() takes 0.26% in OLTP RO
Step#5: changing the function remove_eq_conds() into a virtual method in Item.
It removes 6 virtual calls for Item_func::type(), and adds only 2
virtual calls for Item***::remove_eq_conds().
2015-05-14 17:42:40 +04:00
Alexander Barkov
be2038e3cb MDEV-7950 Item_func::type() takes 0.26% in OLTP RO
Step 4 (there will be more)
2015-05-13 17:08:24 +04:00
Alexander Barkov
2fe4d0e6cd MDEV-7950 Item_func::type() takes 0.26% in OLTP RO
Step #3: Splitting the function check_equality() into a method in Item.
Implementing Item::check_equality() and Item_func_eq::check_equality().
Implement Item_func_eq::build_equal_items() in addition to
Item_func::build_equal_items() and moving the call for check_equality()
from Item_func::build_equal_items() to Item_func_eq::build_equal_items().
2015-05-05 01:09:47 +04:00
Sergei Golubchik
49c853fb94 Merge branch '5.5' into 10.0 2015-05-04 22:00:24 +02:00
Alexander Barkov
462bca365a MDEV-7950 Item_func::type() takes 0.26% in OLTP RO
Step 2c:

After discussion with Igor, it appeared that Item_field and Item_ref
could not appear in this context in the old function build_equal_item_for_cond:

  else if (cond->type() == Item::FUNC_ITEM ||
           cond->real_item()->type() == Item::FIELD_ITEM)

The part of the condition checking for Item_field::FIELD_ITEM was a dead code.
- Moving implementation of Item_ident_or_func_or_sum::build_equal_items()
to Item_func::build_equal_items()
- Restoring deriving of Item_ident and Item_sum_or_func from Item_result_field.
  Removing Item_ident_or_func_or_sum.
2015-05-04 18:12:31 +04:00
Alexander Barkov
499deca7fc A clean-up for c8141f5314
MDEV-7950 Item_func::type() takes 0.26% in OLTP RO (Step#2)

- Item_ref was doing unnecessary extra job after the "MDEV-7950 Step#2" patch.
  Fallback to Item::build_equal_items() if real_type() is not FIELD_ITEM.
  Note, Item_ref::build_equal_items() will most likely be further simplified.
  Waiting for Sanja and Igor to check a possibly dead code.

- Safety: Adding Item_sum::build_equal_items() with ASSERT, as Item_sum
  should never appear in build_equal_items() context.
2015-04-29 17:53:27 +04:00
Sergei Golubchik
fbab0685a7 post-merge changes, fixes, and tests 2015-04-28 13:57:21 +02:00
Alexander Barkov
c8141f5314 MDEV-7950 Item_func::type() takes 0.26% in OLTP RO
Step#2:

1. Removes the function build_equal_items_for_cond() and
   introduces a new method Item::build_equal_items() instead,
   with specific implementations in the following Items:

   Item  (the default implementation)
   Item_ident_or_func_or_sum
   Item_cond
   Item_cond_and

2. Adds a new abstract class Item_ident_or_func_or_sum,
   a common parent for Item_ident and Item_func_or_sum,
   as they have exactly the same build_equal_items().

3. Renames Item_cond_and::cond_equal to Item_cond_and::m_cond_equal,
   to avoid confusion between the member and local variables named
   "cond_equal".
2015-04-28 14:06:07 +04:00
Sergei Golubchik
0f12ada6b6 Merge remote-tracking branch 'mysql/5.5' into 5.5 2015-04-27 21:04:06 +02:00
Alexander Barkov
ecb009b2cb Adding Type_std_attributes to reduce some duplicate code.
TODO: move some methods from Item to Type_std_attributes.
2015-04-25 00:54:00 +04:00
Alexander Barkov
04fb09d781 Deriving Item_row from Item_args and sharing more code
between Item_func, Item_sum, Item_row.
2015-04-24 12:59:21 +04:00
Oleksandr Byelkin
20109712ae MDEV-6892: WHERE does not apply
Taking into account implicit dependence of constant view field from nullable table of left join added.

Fixed finding real table to check if it turned to NULL (materialized view & derived taken into account)

Removed incorrect uninitialization.
2015-04-23 15:56:10 +02:00
Alexander Barkov
fc1f301e91 MDEV-8024 Remove excessive update_used_tables() calls 2015-04-22 12:40:23 +04:00
Alexander Barkov
22a7b4dee0 Removing duplicate code/declarations:
Removing "Field *result_field" from Item_field and Item_ref,
and deriving Item_ident and Item_ref from Item_result_field
instead.
2015-04-17 16:26:08 +04:00
Alexander Barkov
8125db1d9a Moving fix_length_and_dec() from Item_result_field to Item_func_or_sum,
as the other decendants of Item_result_field (Item_avg_field,
Item_variance_field, Item_cache_wrapper) don't need fix_length_and_dec().
2015-04-17 12:36:31 +04:00
Alexander Barkov
99898c6f76 Minor reorganization in Item hierarchy, to remove duplicate code.
- Adding a new class Item_args, represending regular function or
  aggregate function arguments array.

- Adding a new class Item_func_or_sum,
  a parent class for Item_func and Item_sum

- Moving Item_result_field::name() to Item_func_or_sum(),
  as name() is not needed on Item_result_field level.
2015-04-17 09:52:44 +04:00
Alexander Barkov
59df100922 Removing Item_string::m_cs_specified and
making Item_string::is_cs_specified() virtual instead.
2015-03-30 10:57:44 +04:00
Sreeharsha Ramanavarapu
c788e693e6 Bug #20730155: BACKPORT BUG#19699237 TO 5.1
Backport from mysql-5.5 to mysql-5.1

Bug# 19699237: UNINITIALIZED VARIABLE IN
               ITEM_FIELD::STR_RESULT LEADS TO INCORRECT
               BEHAVIOR

ISSUE:
------
When the following conditions are satisfied in a query, a
server crash occurs:
a) Two rows are compared using a NULL-safe equal-to operator.
b) Each of these rows belong to different charsets.

SOLUTION:
---------
When one charset is converted to another for comparision,
the constructor of "Item_func_conv_charset" is called.
This will attempt to use the Item_cache if the string is a
constant. This check succeeds because the "used_table_map"
of the Item_cache class is never set to the correct value.
Since it is mistakenly assumed to be a constant, it tries
to fetch the relevant null value related fields which are
yet to be initialized. This results in valgrind issues
and wrong results.

The fix is to update the "used_table_map" of "Item_cache".
This will allow "Item_func_conv_charset" to realise that
this is not a constant.
2015-03-26 07:40:35 +05:30
Alexander Barkov
e28a241907 MDEV-7661 Unexpected result for: CAST(0xHHHH AS CHAR CHARACTER SET xxx)
for incorrect byte sequences
2015-03-18 17:10:48 +04:00
Alexander Barkov
bd2105855a Adding "const" qualifier to Item::compare_collation() 2015-03-13 13:52:07 +04:00
Alexander Barkov
ba3573cae8 Clean-up:
- Renaming Item::is_bool_func() to is_bool_type(), to avoid assumption
  that the item is an Item_func derivant.
- Deriving Item_func_spatial_rel from Item_bool_func rather than Item_int_func
2015-03-12 13:40:52 +04:00
Sergei Golubchik
2db62f686e Merge branch '10.0' into 10.1 2015-03-07 13:21:02 +01:00
Alexander Barkov
f825b5a4ee MDEV-7629 Regression: Bit and hex string literals changed column names in 10.0.14 2015-02-25 14:13:32 +04:00
Alexander Barkov
2043e3d440 Removing the Hybrid_type_traits framework. It's not used since 5.5. 2015-02-12 17:10:59 +04:00
sreeharsha
17c9755305 Bug # 19699237: UNINITIALIZED VARIABLE IN ITEM_FIELD::STR_RESULT
LEADS TO INCORRECT BEHAVIOR

ISSUE:
------
When the following conditions are satisfied in a query, a
server crash occurs:
a) Two rows are compared using a NULL-safe equal-to operator.
b) Each of these rows belong to different charsets.

SOLUTION:
---------
When one charset is converted to another for comparision,
the constructor of "Item_func_conv_charset" is called.
This will attempt to use the Item_cache if the string is a
constant. This check succeeds because the "used_table_map"
of the Item_cache class is never set to the correct value.
Since it is mistakenly assumed to be a constant, it tries
to fetch the relevant null value related fields which are
yet to be initialized. This results in valgrind issues
and wrong results.

The fix is to update the "used_table_map" of "Item_cache".
This will allow "Item_func_conv_charset" to realise that
this is not a constant.
2015-02-05 15:22:24 +05:30
Sergei Golubchik
4b21cd21fe Merge branch '10.0' into merge-wip 2015-01-31 21:48:47 +01:00
Sergei Golubchik
d9c01e4b4a 5.5 merge 2015-01-21 12:03:02 +01:00
Michael Widenius
5257d71e0e MDEV-6855 Assertion `cond_type == Item::FUNC_ITEM' failed in check_group_min_max_predicates with GROUP BY, aggregate in WHERE SQ, multi-part key
mysql-test/r/group_by.result:
  Test for MDEV-6855
mysql-test/t/group_by.test:
  Test for MDEV-6855
sql/item.h:
  Fixed spelling error
sql/opt_range.cc:
  Added handling of cond_type == Item::CACHE_ITEM in WHERE clauses for MIN/MAX optimization.
  Fixed indentation
2014-12-15 17:13:47 +02:00
Sergei Golubchik
c4655cf862 cleanup: comments referring to non-extistent Item classes 2014-12-04 16:09:34 +01:00
Sergei Golubchik
0438f12540 MDEV-6980 OUT parameters in PREPARE
revert the patch for "out parameters in prepare"
2014-12-04 10:41:52 +01:00