summaryrefslogtreecommitdiff
path: root/sql/item.cc
Commit message (Collapse)AuthorAgeFilesLines
* cleanup: move Virtual_column_info::print out of Virtual_column_infoSergei Golubchik2017-07-051-11/+0
|
* fix the comparison in st_select_lex::setup_ref_array()Sergei Golubchik2017-07-051-2/+1
| | | | | | | the array only needs to be reallocated if it's smaller than needed. Being larger is ok. also: remove a duplicated check (merge error)
* MDEV-13186: main.win failure post MDEV-12336Vicențiu Ciorbaru2017-06-281-3/+3
| | | | | | | | | | | | | | During statement preparation st_order::item gets set to a value in ref_ptr_array. During statement execution we were overriding that value, causing subsequent checks for window functions to return true. Whenever we do any setting from ref_ptr_array, make sure to always store the value in all_fields as well. For function items containing window functions, as MDEV-12336 has discovered, we don't need to create a separate Item_direct_ref or Item_aggregate_ref as they will be computed directly from the top-level item once the window function argument columns are computed.
* Fixed the bug mdev-13166.Igor Babaev2017-06-261-3/+2
| | | | This patch corrects the fix for mdev-12845.
* Fixed the bug mdev-12845.Igor Babaev2017-06-221-121/+178
| | | | | | | | | | | | | This patch fills in a serious flaw in the code that supports condition pushdown into materialized views / derived tables. If a predicate happened to contain a reference to a mergeable view / derived table and it does not depended directly on the target materialized view / derived table then the predicate was not considered as a subject to pusdown to this view / derived table.
* Fixed the bug mdev-13064.Igor Babaev2017-06-161-3/+2
| | | | | | | | This is another attempt to fix the bug mdev-12992. This patch introduces st_select_lex::context_analysis_place for the place in SELECT where context analysis is currently performed. It's similar to st_select_lex::parsing_place, but it is used at the preparation stage.
* MDEV-12471: BULK CommandOleksandr Byelkin2017-06-141-1/+1
| | | | BULK execution moved to a new command.
* Fixed the bug mdev12992.Igor Babaev2017-06-101-1/+2
| | | | | | | | | | When the SELECT query from a trigger that used a subquery in its SELECT list was prepared the counter select_n_having_items was incremented in the constructor Item::Item(THD *thd). As a result each invocation of the trigger required more and more memory for the ref_pointer_array for this SELECT. Made sure that the counter st_select_lex::select_n_having_items would be incremented only at the first execution of such trigger.
* Merge 10.1 into 10.2Marko Mäkelä2017-05-221-2/+2
|\
| * Silence bogus GCC 7 warnings -Wimplicit-fallthroughMarko Mäkelä2017-05-171-2/+2
| | | | | | | | | | | | | | | | Do not silence uncertain cases, or fix any bugs. The only functional change should be that ha_federated::extra() is not calling DBUG_PRINT to report an unhandled case for HA_EXTRA_PREPARE_FOR_DROP.
* | Merge branch '10.1' into 10.2Sergei Golubchik2017-05-091-1/+2
|\ \ | |/ | | | | | | Revert commit db0917f68f, because the fix for MDEV-12696 is coming from 5.5 and 10.1 in this merge.
| * Merge branch '10.0' 10.1Sergei Golubchik2017-04-281-1/+4
| |\
| | * MDEV-12495 Conditional jump depends on uninitialised value for: SELECT NULL ↵Alexander Barkov2017-04-221-1/+4
| | | | | | | | | | | | UNION geom_expression
* | | MDEV-10355 Weird error message upon CREATE TABLE with DEFAULTSergei Golubchik2017-04-301-18/+14
| | | | | | | | | | | | | | | | | | | | | post-fix for 0b52b28b91 * restore EXPLAIN output * remove redundant code
* | | MDEV-10355 Weird error message upon CREATE TABLE with DEFAULTbb-10.2-MDEV-10355Jacob Mathew2017-04-181-13/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed handling of default values with cached temporal functions so that the CREATE TABLE statement now succeeds. Fixed virtual column session cleanup. Fixed the error message. Added quoting of date/time values in cases when this was omitted. Added a test case in default.test. Updated test result files.
* | | MDEV-11117 CHECK constraint fails on intermediate step of ALTERbb-10.2-MDEV-11117Jacob Mathew2017-04-171-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | Fixed the bug by failing the statement with an error message that explains that an auto-increment column may not be used in an expression for a check constraint. Added a test case in check_constraint.test. Updated existing tests and results.
* | | Merge 10.1 into 10.2Marko Mäkelä2017-04-061-12/+0
|\ \ \ | |/ /
| * | Merge 10.0 into 10.1Marko Mäkelä2017-04-061-13/+0
| |\ \ | | |/
| | * MDEV-8642: WHERE Clause not applied on View - Empty result set returnedOleksandr Byelkin2017-04-051-13/+0
| | | | | | | | | | | | | | | | | | An attempt to mark reference as dependent lead to transfering this property to original view field and through it to other references of this field which can't be dependent.
* | | Fixed bug mdev-12336.Igor Babaev2017-03-291-0/+3
| | | | | | | | | | | | | | | | | | The function Item::split_sum_func2() incorrectly processed the function items with window functions that were not window functions themselfes and were used as arguments of other functions.
* | | MDEV-10352 Server crashes in Field::set_default on CREATE TABLESergei Golubchik2017-02-131-3/+5
| | | | | | | | | | | | | | | fix Item_default_value not to pretend being const_item if the field's default_value expression isn't parsed yet
* | | Race condition in DEFAULT() with expressionsSergei Golubchik2017-02-131-8/+14
| | | | | | | | | | | | | | | Item_default_value::calculate was updating table->s->default_values, but it is supposed to be read-only
* | | MDEV-10201 Bad results for CREATE TABLE t1 (a INT DEFAULT b, b INT DEFAULT 4)Sergei Golubchik2017-02-131-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Optionally do table->update_default_fields() even for INSERT that supposedly provides values for all column. Because these "values" might be DEFAULT, which would need table->update_default_fields() at the end. Also set Item_default_value::used_tables() from the default expression. Non-zero used_field() means that mysql_insert() will initialize all fields to their default values (with restore_record()) even if all columns are later provided with values. Because default expressions may refer to other columns and they must be initialized.
* | | Merge branch '10.1' into 10.2Sergei Golubchik2017-02-101-1/+40
|\ \ \ | |/ /
| * | Post merge review fixesVicențiu Ciorbaru2017-01-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | * Remove duplicate lines from tests * Use thd instead of current_thd * Remove extra wsrep_binlog_format_names * Correctly merge union patch from 5.5 wrt duplicate rows. * Correctly merge SELinux changes into 10.1
| * | Merge branch '10.0' into 10.1Vicențiu Ciorbaru2017-01-161-1/+40
| |\ \ | | |/
| | * Merge remote-tracking branch 'origin/5.5' into 10.0vicentiu2017-01-061-1/+40
| | |\
| | | * MDEV-10386 Assertion `fixed == 1' failed in virtual String* ↵Alexander Barkov2016-12-211-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Item_func_conv_charset::val_str(String*) The patch b96c196f1cd5d77e524cbf952539bdd33c65ffc1 added a new call for safe_charset_converter() without a corresponding fix_fields(). In case of a sub-query the created Item remained in non-fixed state. The problem did not show up with literal derived expressions, only subselects were affected. This patch adds a corresponding fix_fields() to the previously added safe_charset_converter().
| | | * MDEV-7691: Assertion `outer_context || !*from_field || *from_field == ↵Sergei Petrunia2016-12-191-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | not_found_field' ... The bug occurred when a subquery - has a reference to outside, to grand-parent query or further up - is converted to a semi-join (i.e. merged into its parent). Then the reference to outside had form Item_ref(Item_field(...)). - Conversion to semi-join would call item->fix_after_pullout() for the outside reference. - Item_ref::fix_after_pullout would call Item_field->fix_after_pullout - The Item_field would construct a new Name_resolution_context object This process ignored the fact that the Item_field does not belong to any of the subselects being flattened. The result was crash in the next call to Item_field::fix_fields(), where we would try to use an invalid Name_resolution_context object. Fixed by not creating Name_resolution_context object if the Item_field's context does not belong to the subselect(s) that were flattened.
* | | | MDEV-11780 Crash with PREPARE + SP out parameter + literalAlexander Barkov2017-01-241-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before "MDEV-10709 Expressions as parameters to Dynamic SQL" only user variables were syntactically allowed as EXECUTE parameters. User variables were OK as both IN and OUT parameters. When Item_param was bound to an actual parameter (a user variable), it automatically meant that the bound Item was settable. The DBUG_ASSERT() in Protocol_text::send_out_parameters() guarded that the actual parameter is really settable. After MDEV-10709, any kind of expressions are allowed as EXECUTE IN parameters. But the patch for MDEV-10709 forgot to check that only descendants of Settable_routine_parameter should be allowed as OUT parameters. So an attempt to pass a non-settable parameter as an OUT parameter made server crash on the above mentioned DBUG_ASSERT. This patch changes Item_param::get_settable_routine_parameter(), which previously always returned "this". Now, when Item_param is bound to some Item, it caches if the bound Item is settable. Item_param::get_settable_routine_parameter() now returns "this" only if the bound actual parameter is settable, and returns NULL otherwise.
* | | | MDEV-11134 Assertion `fixed' failed in Item::const_charset_converter(THD*, ↵Alexander Barkov2017-01-231-31/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | Merge 10.1 to 10.2.Marko Mäkelä2017-01-191-1/+8
|\ \ \ \ | |/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | | MDEV-11030 Assertion `precision > 0' failed in decimal_bin_sizeAlexander Barkov2017-01-121-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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));
* | | | Merge branch '10.1' into 10.2Sergei Golubchik2016-12-291-31/+65
|\ \ \ \ | |/ / /
| * | | Merge branch '10.0' into 10.1Sergei Golubchik2016-12-111-30/+44
| |\ \ \ | | |/ /
| | * | Merge branch '5.5' into 10.0Sergei Golubchik2016-12-091-30/+44
| | |\ \ | | | |/
| | | * MDEV-10663: Use of Inline table columns in HAVING clause throws 1463 ErrorOleksandr Byelkin2016-12-061-29/+43
| | | | | | | | | | | | | | | | check for VIEW/DERIVED fields
| | | * MDEV-10717 Assertion `!null_value' failed in virtual bool ↵Alexander Barkov2016-12-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| * | | Merge branch '10.0' into 10.1Sergei Golubchik2016-09-281-2/+21
| |\ \ \ | | |/ /
| | * | Merge branch '5.5' into 10.0Sergei Golubchik2016-09-271-2/+21
| | |\ \ | | | |/
| | | * Merge branch 'mysql/5.5' into 5.5Sergei Golubchik2016-09-111-4/+1
| | | |\ | | | | | | | | | | | | | | | 80% reverted
| | | | * Bug #23280699: MYSQLD GOT SIGNAL 11 IN IS_NULL ON SELECTSreeharsha Ramanavarapu2016-07-221-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
| | | | * Bug #23279858: MYSQLD GOT SIGNAL 11 ON SIMPLE SELECTSreeharsha Ramanavarapu2016-05-241-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NAME_CONST QUERY ISSUE: ------ Using NAME_CONST with a non-constant negated expression as value can result in incorrect behavior. SOLUTION: --------- The problem can be avoided by checking whether the argument is a constant value. The fix is a backport of Bug#12735545.
| | | * | MDEV-8833 Crash of server on prepared statement with conversion to semi-joinOleksandr Byelkin2016-09-021-2/+21
| | | | | | | | | | | | | | | | | | | | Correct context chain made to allow outer fields pullout.
* | | | | Fixed bug mdev-11608.Igor Babaev2016-12-201-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | Fixed bug mdev-11488.Igor Babaev2016-12-141-0/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | | | | Item::print(): remove redundant parenthesesSergei Golubchik2016-12-121-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | by introducing new Item::precedence() method and using it to decide whether parentheses are required
* | | | | bugfix: non-deterministic vcols in partitioningSergei Golubchik2016-12-121-0/+8
| | | | |
* | | | | rename Virtual_column_info::expr_itemSergei Golubchik2016-12-121-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | now, when expr_str is gone, expr_item can be unambiguously renamed to expr.
* | | | | store/show vcols as item->print()Sergei Golubchik2016-12-121-34/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.